Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[beta] backports #90938

Merged
merged 32 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f7acd9f
Fix assertion failures in `OwnedHandle` with `windows_subsystem`.
sunfishcode Sep 9, 2021
2df9cc5
Fix Windows compilation errors.
sunfishcode Sep 9, 2021
0693aa1
Document the valid values for `HandleOrNull` and `HandleOrInvalid`.
sunfishcode Oct 5, 2021
9654d52
Ensure that pushing empty path works as before
seanyoung Oct 8, 2021
427b6a7
Feature gate and make must_not_suspend allow-by-default
guswynn Oct 12, 2021
4b4b56d
Only use `clone3` when needed for pidfd
cuviper Oct 15, 2021
aaa8f4e
Update another comment on fork vs. clone3
cuviper Oct 15, 2021
462002b
Also note tool expectations of fork vs clone3
cuviper Oct 15, 2021
d658d6d
Revert "Do not call getpid wrapper after fork in tests"
cuviper Oct 15, 2021
d19aeb2
Fix documentation header sizes
jsha Oct 22, 2021
3374d0d
Fixes incorrect handling of ADT's drop requirements
JakobDegen Oct 23, 2021
4f9474c
Add regresstion test for #90024.
JakobDegen Oct 24, 2021
d092236
Clean up debug statements in needs_drop
JakobDegen Oct 26, 2021
2039a92
Fix ICE when forgetting to `Box` a parameter to a `Self::func` call
JakobDegen Oct 24, 2021
7a83694
expose default substs in param_env
b-naber Oct 25, 2021
96fd370
add tests
b-naber Oct 25, 2021
dc73bdc
Update odht crate to 0.3.1 (big-endian bugfix)
michaelwoerister Oct 29, 2021
640bfaf
Add more missing methods to `IntraLinkCrateLoader`
jyn514 Nov 8, 2021
5fd4bb4
Go back to loading all external crates unconditionally
jyn514 Nov 1, 2021
082accd
Split doc_cfg and doc_auto_cfg features
GuillaumeGomez Nov 2, 2021
fb40f17
Also check for feature gates in "src/test/rustdoc"
GuillaumeGomez Nov 2, 2021
fed62b2
Apply adjustments for field expression even if inaccessible
nbdd0121 Nov 2, 2021
5de0c84
introduce an enum for tracking the 2229 migration causes
nikomatsakis Nov 4, 2021
042c837
rework diagnostic reporting to be more structured
nikomatsakis Nov 4, 2021
34cd4ef
handle case of a variable not captured
nikomatsakis Nov 5, 2021
d9ddee4
apply suggestions from code review
nikomatsakis Nov 5, 2021
e63c3b5
Properly register text_direction_codepoint_in_comment lint.
hkratz Nov 5, 2021
cba2546
Bump stage0 to stable 1.56.1
cuviper Nov 16, 2021
236bc61
Use ubuntu image to download openssl, curl sources, cacert.pem
hkratz Oct 31, 2021
69b4a85
Ignore files copied from previous stage when generating hash.
hkratz Nov 1, 2021
4d156c3
Android is not GNU
cuviper Nov 12, 2021
a4a72e7
Update llvm submodule
Amanieu Nov 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2315,9 +2315,9 @@ dependencies = [

[[package]]
name = "odht"
version = "0.3.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2504d29fda40b3f2f9ef525392435ab660e407c188196cb664b116ebcca0142"
checksum = "5a518809ac14b25b569624d0268eba1e88498f71615893dca57982bed7621abb"
dependencies = [
"cfg-if 1.0.0",
]
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,9 @@ declare_features! (
/// Allows using the `non_exhaustive_omitted_patterns` lint.
(active, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554), None),

/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
(active, doc_auto_cfg, "1.57.0", Some(43781), None),

// -------------------------------------------------------------------------
// feature-group-end: actual feature gates
// -------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ rustc_serialize = { path = "../rustc_serialize" }
rustc_ast = { path = "../rustc_ast" }
tracing = "0.1"
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
odht = { version = "0.3.0", features = ["nightly"] }
odht = { version = "0.3.1", features = ["nightly"] }
1 change: 0 additions & 1 deletion compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
UNUSED_LABELS,
UNUSED_PARENS,
UNUSED_BRACES,
MUST_NOT_SUSPEND,
REDUNDANT_SEMICOLONS
);

Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ declare_lint! {
///
/// ```rust
/// #![feature(must_not_suspend)]
/// #![warn(must_not_suspend)]
///
/// #[must_not_suspend]
/// struct SyncThing {}
Expand All @@ -349,8 +350,9 @@ declare_lint! {
/// `MutexGuard`'s)
///
pub MUST_NOT_SUSPEND,
Warn,
Allow,
"use of a `#[must_not_suspend]` value across a yield point",
@feature_gate = rustc_span::symbol::sym::must_not_suspend;
}

declare_lint! {
Expand Down Expand Up @@ -3052,6 +3054,7 @@ declare_lint_pass! {
BREAK_WITH_LABEL_AND_LOOP,
UNUSED_ATTRIBUTES,
NON_EXHAUSTIVE_OMITTED_PATTERNS,
TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
DEREF_INTO_DYN_SUPERTRAIT,
]
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ doctest = false

[dependencies]
libc = "0.2"
odht = { version = "0.3.0", features = ["nightly"] }
odht = { version = "0.3.1", features = ["nightly"] }
snap = "1"
tracing = "0.1"
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ symbols! {
div_assign,
doc,
doc_alias,
doc_auto_cfg,
doc_cfg,
doc_cfg_hide,
doc_keyword,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/android_base.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::spec::{LinkerFlavor, TargetOptions};

pub fn opts() -> TargetOptions {
let mut base = super::linux_gnu_base::opts();
let mut base = super::linux_base::opts();
base.os = "android".to_string();
// Many of the symbols defined in compiler-rt are also defined in libgcc.
// Android's linker doesn't like that by default.
Expand Down
101 changes: 56 additions & 45 deletions compiler/rustc_ty_utils/src/needs_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ use rustc_span::{sym, DUMMY_SP};
type NeedsDropResult<T> = Result<T, AlwaysRequiresDrop>;

fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
let adt_components =
move |adt_def: &ty::AdtDef, _| tcx.adt_drop_tys(adt_def.did).map(|tys| tys.iter());

// If we don't know a type doesn't need drop, for example if it's a type
// parameter without a `Copy` bound, then we conservatively return that it
// needs drop.
let res =
NeedsDropTypes::new(tcx, query.param_env, query.value, adt_components).next().is_some();
let adt_has_dtor =
|adt_def: &ty::AdtDef| adt_def.destructor(tcx).map(|_| DtorType::Significant);
let res = drop_tys_helper(tcx, query.value, query.param_env, adt_has_dtor).next().is_some();

debug!("needs_drop_raw({:?}) = {:?}", query, res);
res
Expand All @@ -29,12 +27,10 @@ fn has_significant_drop_raw<'tcx>(
tcx: TyCtxt<'tcx>,
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> bool {
let significant_drop_fields = move |adt_def: &ty::AdtDef, _| {
tcx.adt_significant_drop_tys(adt_def.did).map(|tys| tys.iter())
};
let res = NeedsDropTypes::new(tcx, query.param_env, query.value, significant_drop_fields)
.next()
.is_some();
let res =
drop_tys_helper(tcx, query.value, query.param_env, adt_consider_insignificant_dtor(tcx))
.next()
.is_some();
debug!("has_significant_drop_raw({:?}) = {:?}", query, res);
res
}
Expand Down Expand Up @@ -145,10 +141,8 @@ where
Ok(tys) => tys,
};
for required_ty in tys {
let subst_ty = tcx.normalize_erasing_regions(
self.param_env,
required_ty.subst(tcx, substs),
);
let subst_ty =
tcx.normalize_erasing_regions(self.param_env, required_ty);
queue_type(self, subst_ty);
}
}
Expand Down Expand Up @@ -187,23 +181,24 @@ enum DtorType {
// Depending on the implentation of `adt_has_dtor`, it is used to check if the
// ADT has a destructor or if the ADT only has a significant destructor. For
// understanding significant destructor look at `adt_significant_drop_tys`.
fn adt_drop_tys_helper<'tcx>(
fn drop_tys_helper<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
ty: Ty<'tcx>,
param_env: rustc_middle::ty::ParamEnv<'tcx>,
adt_has_dtor: impl Fn(&ty::AdtDef) -> Option<DtorType>,
) -> Result<&ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
) -> impl Iterator<Item = NeedsDropResult<Ty<'tcx>>> {
let adt_components = move |adt_def: &ty::AdtDef, substs: SubstsRef<'tcx>| {
if adt_def.is_manually_drop() {
debug!("adt_drop_tys: `{:?}` is manually drop", adt_def);
debug!("drop_tys_helper: `{:?}` is manually drop", adt_def);
return Ok(Vec::new().into_iter());
} else if let Some(dtor_info) = adt_has_dtor(adt_def) {
match dtor_info {
DtorType::Significant => {
debug!("adt_drop_tys: `{:?}` implements `Drop`", adt_def);
debug!("drop_tys_helper: `{:?}` implements `Drop`", adt_def);
return Err(AlwaysRequiresDrop);
}
DtorType::Insignificant => {
debug!("adt_drop_tys: `{:?}` drop is insignificant", adt_def);
debug!("drop_tys_helper: `{:?}` drop is insignificant", adt_def);

// Since the destructor is insignificant, we just want to make sure all of
// the passed in type parameters are also insignificant.
Expand All @@ -212,34 +207,27 @@ fn adt_drop_tys_helper<'tcx>(
}
}
} else if adt_def.is_union() {
debug!("adt_drop_tys: `{:?}` is a union", adt_def);
debug!("drop_tys_helper: `{:?}` is a union", adt_def);
return Ok(Vec::new().into_iter());
}
Ok(adt_def.all_fields().map(|field| tcx.type_of(field.did)).collect::<Vec<_>>().into_iter())
Ok(adt_def
.all_fields()
.map(|field| {
let r = tcx.type_of(field.did).subst(tcx, substs);
debug!("drop_tys_helper: Subst into {:?} with {:?} gettng {:?}", field, substs, r);
r
})
.collect::<Vec<_>>()
.into_iter())
};

let adt_ty = tcx.type_of(def_id);
let param_env = tcx.param_env(def_id);
let res: Result<Vec<_>, _> =
NeedsDropTypes::new(tcx, param_env, adt_ty, adt_components).collect();

debug!("adt_drop_tys(`{}`) = `{:?}`", tcx.def_path_str(def_id), res);
res.map(|components| tcx.intern_type_list(&components))
NeedsDropTypes::new(tcx, param_env, ty, adt_components)
}

fn adt_drop_tys(tcx: TyCtxt<'_>, def_id: DefId) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> {
// This is for the "needs_drop" query, that considers all `Drop` impls, therefore all dtors are
// significant.
let adt_has_dtor =
|adt_def: &ty::AdtDef| adt_def.destructor(tcx).map(|_| DtorType::Significant);
adt_drop_tys_helper(tcx, def_id, adt_has_dtor)
}

fn adt_significant_drop_tys(
tcx: TyCtxt<'_>,
def_id: DefId,
) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> {
let adt_has_dtor = |adt_def: &ty::AdtDef| {
fn adt_consider_insignificant_dtor<'tcx>(
tcx: TyCtxt<'tcx>,
) -> impl Fn(&ty::AdtDef) -> Option<DtorType> + 'tcx {
move |adt_def: &ty::AdtDef| {
let is_marked_insig = tcx.has_attr(adt_def.did, sym::rustc_insignificant_dtor);
if is_marked_insig {
// In some cases like `std::collections::HashMap` where the struct is a wrapper around
Expand All @@ -256,8 +244,31 @@ fn adt_significant_drop_tys(
// treat this as the simple case of Drop impl for type.
None
}
};
adt_drop_tys_helper(tcx, def_id, adt_has_dtor)
}
}

fn adt_drop_tys(tcx: TyCtxt<'_>, def_id: DefId) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> {
// This is for the "adt_drop_tys" query, that considers all `Drop` impls, therefore all dtors are
// significant.
let adt_has_dtor =
|adt_def: &ty::AdtDef| adt_def.destructor(tcx).map(|_| DtorType::Significant);
drop_tys_helper(tcx, tcx.type_of(def_id), tcx.param_env(def_id), adt_has_dtor)
.collect::<Result<Vec<_>, _>>()
.map(|components| tcx.intern_type_list(&components))
}

fn adt_significant_drop_tys(
tcx: TyCtxt<'_>,
def_id: DefId,
) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> {
drop_tys_helper(
tcx,
tcx.type_of(def_id),
tcx.param_env(def_id),
adt_consider_insignificant_dtor(tcx),
)
.collect::<Result<Vec<_>, _>>()
.map(|components| tcx.intern_type_list(&components))
}

pub(crate) fn provide(providers: &mut ty::query::Providers) {
Expand Down
12 changes: 12 additions & 0 deletions compiler/rustc_ty_utils/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ fn trait_of_item(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
}

/// See `ParamEnv` struct definition for details.
#[instrument(level = "debug", skip(tcx))]
fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
// The param_env of an impl Trait type is its defining function's param_env
if let Some(parent) = ty::is_impl_trait_defn(tcx, def_id) {
Expand Down Expand Up @@ -275,9 +276,20 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
predicates.extend(environment);
}

// It's important that we include the default substs in unevaluated
// constants, since `Unevaluated` instances in predicates whose substs are None
// can lead to "duplicate" caller bounds candidates during trait selection,
// duplicate in the sense that both have their default substs, but the
// candidate that resulted from a superpredicate still uses `None` in its
// `substs_` field of `Unevaluated` to indicate that it has its default substs,
// whereas the other candidate has `substs_: Some(default_substs)`, see
// issue #89334
predicates = tcx.expose_default_const_substs(predicates);

let unnormalized_env =
ty::ParamEnv::new(tcx.intern_predicates(&predicates), traits::Reveal::UserFacing);

debug!("unnormalized_env caller bounds: {:?}", unnormalized_env.caller_bounds());
let body_id = def_id
.as_local()
.map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id))
Expand Down
9 changes: 6 additions & 3 deletions compiler/rustc_typeck/src/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1698,15 +1698,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Save the index of all fields regardless of their visibility in case
// of error recovery.
self.write_field_index(expr.hir_id, index);
let adjustments = self.adjust_steps(&autoderef);
if field.vis.is_accessible_from(def_scope, self.tcx) {
let adjustments = self.adjust_steps(&autoderef);
self.apply_adjustments(base, adjustments);
self.register_predicates(autoderef.into_obligations());

self.tcx.check_stability(field.did, Some(expr.hir_id), expr.span, None);
return field_ty;
}
private_candidate = Some((base_def.did, field_ty));
private_candidate = Some((adjustments, base_def.did, field_ty));
}
}
ty::Tuple(tys) => {
Expand All @@ -1729,7 +1729,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
self.structurally_resolved_type(autoderef.span(), autoderef.final_ty(false));

if let Some((did, field_ty)) = private_candidate {
if let Some((adjustments, did, field_ty)) = private_candidate {
// (#90483) apply adjustments to avoid ExprUseVisitor from
// creating erroneous projection.
self.apply_adjustments(base, adjustments);
self.ban_private_field_access(expr, expr_t, field, did);
return field_ty;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
..
},
method,
)) if Some(recv_ty.def_id()) == pin_did && method.ident.name == sym::new => {
)) if recv_ty.opt_def_id() == pin_did && method.ident.name == sym::new => {
err.span_suggestion(
fn_name.span,
"use `Box::pin` to pin and box this expression",
Expand Down
Loading