Skip to content

Commit 7611e64

Browse files
committed
Auto merge of #90938 - cuviper:beta-next, r=Mark-Simulacrum
[beta] backports - Fix assertion failures in OwnedHandle with windows_subsystem. #88798 - Ensure that pushing empty path works as before on verbatim paths #89665 - Feature gate + make must_not_suspend allow-by-default #89826 - Only use clone3 when needed for pidfd #89930 - Fix documentation header sizes #90186 - Fixes incorrect handling of ADT's drop requirements #90218 - Fix ICE when forgetting to Box a parameter to a Self::func call #90221 - Prevent duplicate caller bounds candidates by exposing default substs in Unevaluated #90266 - Update odht crate to 0.3.1 (big-endian bugfix) #90403 - rustdoc: Go back to loading all external crates unconditionally #90489 - Split doc_cfg and doc_auto_cfg features #90502 - Apply adjustments for field expression even if inaccessible #90508 - Warn for variables that are no longer captured #90597 - Properly register text_direction_codepoint_in_comment lint. #90626 - CI: Use ubuntu image to download openssl, curl sources, cacert.pem for x86 dist builds #90457 - Android is not GNU #90834 - Update llvm submodule #90954 Additionally, this bumps the stage 0 compiler from beta to stable 1.56.1. r? `@Mark-Simulacrum`
2 parents 708d57e + a4a72e7 commit 7611e64

File tree

78 files changed

+1459
-744
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1459
-744
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -2315,9 +2315,9 @@ dependencies = [
23152315

23162316
[[package]]
23172317
name = "odht"
2318-
version = "0.3.0"
2318+
version = "0.3.1"
23192319
source = "registry+https://github.com/rust-lang/crates.io-index"
2320-
checksum = "d2504d29fda40b3f2f9ef525392435ab660e407c188196cb664b116ebcca0142"
2320+
checksum = "5a518809ac14b25b569624d0268eba1e88498f71615893dca57982bed7621abb"
23212321
dependencies = [
23222322
"cfg-if 1.0.0",
23232323
]

compiler/rustc_feature/src/active.rs

+3
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,9 @@ declare_features! (
684684
/// Allows using the `non_exhaustive_omitted_patterns` lint.
685685
(active, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554), None),
686686

687+
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
688+
(active, doc_auto_cfg, "1.57.0", Some(43781), None),
689+
687690
// -------------------------------------------------------------------------
688691
// feature-group-end: actual feature gates
689692
// -------------------------------------------------------------------------

compiler/rustc_hir/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ rustc_serialize = { path = "../rustc_serialize" }
1717
rustc_ast = { path = "../rustc_ast" }
1818
tracing = "0.1"
1919
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
20-
odht = { version = "0.3.0", features = ["nightly"] }
20+
odht = { version = "0.3.1", features = ["nightly"] }

compiler/rustc_lint/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
303303
UNUSED_LABELS,
304304
UNUSED_PARENS,
305305
UNUSED_BRACES,
306-
MUST_NOT_SUSPEND,
307306
REDUNDANT_SEMICOLONS
308307
);
309308

compiler/rustc_lint_defs/src/builtin.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ declare_lint! {
323323
///
324324
/// ```rust
325325
/// #![feature(must_not_suspend)]
326+
/// #![warn(must_not_suspend)]
326327
///
327328
/// #[must_not_suspend]
328329
/// struct SyncThing {}
@@ -349,8 +350,9 @@ declare_lint! {
349350
/// `MutexGuard`'s)
350351
///
351352
pub MUST_NOT_SUSPEND,
352-
Warn,
353+
Allow,
353354
"use of a `#[must_not_suspend]` value across a yield point",
355+
@feature_gate = rustc_span::symbol::sym::must_not_suspend;
354356
}
355357

356358
declare_lint! {
@@ -3052,6 +3054,7 @@ declare_lint_pass! {
30523054
BREAK_WITH_LABEL_AND_LOOP,
30533055
UNUSED_ATTRIBUTES,
30543056
NON_EXHAUSTIVE_OMITTED_PATTERNS,
3057+
TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
30553058
DEREF_INTO_DYN_SUPERTRAIT,
30563059
]
30573060
}

compiler/rustc_metadata/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ doctest = false
88

99
[dependencies]
1010
libc = "0.2"
11-
odht = { version = "0.3.0", features = ["nightly"] }
11+
odht = { version = "0.3.1", features = ["nightly"] }
1212
snap = "1"
1313
tracing = "0.1"
1414
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ symbols! {
549549
div_assign,
550550
doc,
551551
doc_alias,
552+
doc_auto_cfg,
552553
doc_cfg,
553554
doc_cfg_hide,
554555
doc_keyword,

compiler/rustc_target/src/spec/android_base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::spec::{LinkerFlavor, TargetOptions};
22

33
pub fn opts() -> TargetOptions {
4-
let mut base = super::linux_gnu_base::opts();
4+
let mut base = super::linux_base::opts();
55
base.os = "android".to_string();
66
// Many of the symbols defined in compiler-rt are also defined in libgcc.
77
// Android's linker doesn't like that by default.

compiler/rustc_ty_utils/src/needs_drop.rs

+56-45
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ use rustc_span::{sym, DUMMY_SP};
1212
type NeedsDropResult<T> = Result<T, AlwaysRequiresDrop>;
1313

1414
fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
15-
let adt_components =
16-
move |adt_def: &ty::AdtDef, _| tcx.adt_drop_tys(adt_def.did).map(|tys| tys.iter());
17-
1815
// If we don't know a type doesn't need drop, for example if it's a type
1916
// parameter without a `Copy` bound, then we conservatively return that it
2017
// needs drop.
21-
let res =
22-
NeedsDropTypes::new(tcx, query.param_env, query.value, adt_components).next().is_some();
18+
let adt_has_dtor =
19+
|adt_def: &ty::AdtDef| adt_def.destructor(tcx).map(|_| DtorType::Significant);
20+
let res = drop_tys_helper(tcx, query.value, query.param_env, adt_has_dtor).next().is_some();
2321

2422
debug!("needs_drop_raw({:?}) = {:?}", query, res);
2523
res
@@ -29,12 +27,10 @@ fn has_significant_drop_raw<'tcx>(
2927
tcx: TyCtxt<'tcx>,
3028
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
3129
) -> bool {
32-
let significant_drop_fields = move |adt_def: &ty::AdtDef, _| {
33-
tcx.adt_significant_drop_tys(adt_def.did).map(|tys| tys.iter())
34-
};
35-
let res = NeedsDropTypes::new(tcx, query.param_env, query.value, significant_drop_fields)
36-
.next()
37-
.is_some();
30+
let res =
31+
drop_tys_helper(tcx, query.value, query.param_env, adt_consider_insignificant_dtor(tcx))
32+
.next()
33+
.is_some();
3834
debug!("has_significant_drop_raw({:?}) = {:?}", query, res);
3935
res
4036
}
@@ -145,10 +141,8 @@ where
145141
Ok(tys) => tys,
146142
};
147143
for required_ty in tys {
148-
let subst_ty = tcx.normalize_erasing_regions(
149-
self.param_env,
150-
required_ty.subst(tcx, substs),
151-
);
144+
let subst_ty =
145+
tcx.normalize_erasing_regions(self.param_env, required_ty);
152146
queue_type(self, subst_ty);
153147
}
154148
}
@@ -187,23 +181,24 @@ enum DtorType {
187181
// Depending on the implentation of `adt_has_dtor`, it is used to check if the
188182
// ADT has a destructor or if the ADT only has a significant destructor. For
189183
// understanding significant destructor look at `adt_significant_drop_tys`.
190-
fn adt_drop_tys_helper<'tcx>(
184+
fn drop_tys_helper<'tcx>(
191185
tcx: TyCtxt<'tcx>,
192-
def_id: DefId,
186+
ty: Ty<'tcx>,
187+
param_env: rustc_middle::ty::ParamEnv<'tcx>,
193188
adt_has_dtor: impl Fn(&ty::AdtDef) -> Option<DtorType>,
194-
) -> Result<&ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
189+
) -> impl Iterator<Item = NeedsDropResult<Ty<'tcx>>> {
195190
let adt_components = move |adt_def: &ty::AdtDef, substs: SubstsRef<'tcx>| {
196191
if adt_def.is_manually_drop() {
197-
debug!("adt_drop_tys: `{:?}` is manually drop", adt_def);
192+
debug!("drop_tys_helper: `{:?}` is manually drop", adt_def);
198193
return Ok(Vec::new().into_iter());
199194
} else if let Some(dtor_info) = adt_has_dtor(adt_def) {
200195
match dtor_info {
201196
DtorType::Significant => {
202-
debug!("adt_drop_tys: `{:?}` implements `Drop`", adt_def);
197+
debug!("drop_tys_helper: `{:?}` implements `Drop`", adt_def);
203198
return Err(AlwaysRequiresDrop);
204199
}
205200
DtorType::Insignificant => {
206-
debug!("adt_drop_tys: `{:?}` drop is insignificant", adt_def);
201+
debug!("drop_tys_helper: `{:?}` drop is insignificant", adt_def);
207202

208203
// Since the destructor is insignificant, we just want to make sure all of
209204
// the passed in type parameters are also insignificant.
@@ -212,34 +207,27 @@ fn adt_drop_tys_helper<'tcx>(
212207
}
213208
}
214209
} else if adt_def.is_union() {
215-
debug!("adt_drop_tys: `{:?}` is a union", adt_def);
210+
debug!("drop_tys_helper: `{:?}` is a union", adt_def);
216211
return Ok(Vec::new().into_iter());
217212
}
218-
Ok(adt_def.all_fields().map(|field| tcx.type_of(field.did)).collect::<Vec<_>>().into_iter())
213+
Ok(adt_def
214+
.all_fields()
215+
.map(|field| {
216+
let r = tcx.type_of(field.did).subst(tcx, substs);
217+
debug!("drop_tys_helper: Subst into {:?} with {:?} gettng {:?}", field, substs, r);
218+
r
219+
})
220+
.collect::<Vec<_>>()
221+
.into_iter())
219222
};
220223

221-
let adt_ty = tcx.type_of(def_id);
222-
let param_env = tcx.param_env(def_id);
223-
let res: Result<Vec<_>, _> =
224-
NeedsDropTypes::new(tcx, param_env, adt_ty, adt_components).collect();
225-
226-
debug!("adt_drop_tys(`{}`) = `{:?}`", tcx.def_path_str(def_id), res);
227-
res.map(|components| tcx.intern_type_list(&components))
224+
NeedsDropTypes::new(tcx, param_env, ty, adt_components)
228225
}
229226

230-
fn adt_drop_tys(tcx: TyCtxt<'_>, def_id: DefId) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> {
231-
// This is for the "needs_drop" query, that considers all `Drop` impls, therefore all dtors are
232-
// significant.
233-
let adt_has_dtor =
234-
|adt_def: &ty::AdtDef| adt_def.destructor(tcx).map(|_| DtorType::Significant);
235-
adt_drop_tys_helper(tcx, def_id, adt_has_dtor)
236-
}
237-
238-
fn adt_significant_drop_tys(
239-
tcx: TyCtxt<'_>,
240-
def_id: DefId,
241-
) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> {
242-
let adt_has_dtor = |adt_def: &ty::AdtDef| {
227+
fn adt_consider_insignificant_dtor<'tcx>(
228+
tcx: TyCtxt<'tcx>,
229+
) -> impl Fn(&ty::AdtDef) -> Option<DtorType> + 'tcx {
230+
move |adt_def: &ty::AdtDef| {
243231
let is_marked_insig = tcx.has_attr(adt_def.did, sym::rustc_insignificant_dtor);
244232
if is_marked_insig {
245233
// In some cases like `std::collections::HashMap` where the struct is a wrapper around
@@ -256,8 +244,31 @@ fn adt_significant_drop_tys(
256244
// treat this as the simple case of Drop impl for type.
257245
None
258246
}
259-
};
260-
adt_drop_tys_helper(tcx, def_id, adt_has_dtor)
247+
}
248+
}
249+
250+
fn adt_drop_tys(tcx: TyCtxt<'_>, def_id: DefId) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> {
251+
// This is for the "adt_drop_tys" query, that considers all `Drop` impls, therefore all dtors are
252+
// significant.
253+
let adt_has_dtor =
254+
|adt_def: &ty::AdtDef| adt_def.destructor(tcx).map(|_| DtorType::Significant);
255+
drop_tys_helper(tcx, tcx.type_of(def_id), tcx.param_env(def_id), adt_has_dtor)
256+
.collect::<Result<Vec<_>, _>>()
257+
.map(|components| tcx.intern_type_list(&components))
258+
}
259+
260+
fn adt_significant_drop_tys(
261+
tcx: TyCtxt<'_>,
262+
def_id: DefId,
263+
) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> {
264+
drop_tys_helper(
265+
tcx,
266+
tcx.type_of(def_id),
267+
tcx.param_env(def_id),
268+
adt_consider_insignificant_dtor(tcx),
269+
)
270+
.collect::<Result<Vec<_>, _>>()
271+
.map(|components| tcx.intern_type_list(&components))
261272
}
262273

263274
pub(crate) fn provide(providers: &mut ty::query::Providers) {

compiler/rustc_ty_utils/src/ty.rs

+12
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ fn trait_of_item(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
248248
}
249249

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

279+
// It's important that we include the default substs in unevaluated
280+
// constants, since `Unevaluated` instances in predicates whose substs are None
281+
// can lead to "duplicate" caller bounds candidates during trait selection,
282+
// duplicate in the sense that both have their default substs, but the
283+
// candidate that resulted from a superpredicate still uses `None` in its
284+
// `substs_` field of `Unevaluated` to indicate that it has its default substs,
285+
// whereas the other candidate has `substs_: Some(default_substs)`, see
286+
// issue #89334
287+
predicates = tcx.expose_default_const_substs(predicates);
288+
278289
let unnormalized_env =
279290
ty::ParamEnv::new(tcx.intern_predicates(&predicates), traits::Reveal::UserFacing);
280291

292+
debug!("unnormalized_env caller bounds: {:?}", unnormalized_env.caller_bounds());
281293
let body_id = def_id
282294
.as_local()
283295
.map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id))

compiler/rustc_typeck/src/check/expr.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1698,15 +1698,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16981698
// Save the index of all fields regardless of their visibility in case
16991699
// of error recovery.
17001700
self.write_field_index(expr.hir_id, index);
1701+
let adjustments = self.adjust_steps(&autoderef);
17011702
if field.vis.is_accessible_from(def_scope, self.tcx) {
1702-
let adjustments = self.adjust_steps(&autoderef);
17031703
self.apply_adjustments(base, adjustments);
17041704
self.register_predicates(autoderef.into_obligations());
17051705

17061706
self.tcx.check_stability(field.did, Some(expr.hir_id), expr.span, None);
17071707
return field_ty;
17081708
}
1709-
private_candidate = Some((base_def.did, field_ty));
1709+
private_candidate = Some((adjustments, base_def.did, field_ty));
17101710
}
17111711
}
17121712
ty::Tuple(tys) => {
@@ -1729,7 +1729,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17291729
}
17301730
self.structurally_resolved_type(autoderef.span(), autoderef.final_ty(false));
17311731

1732-
if let Some((did, field_ty)) = private_candidate {
1732+
if let Some((adjustments, did, field_ty)) = private_candidate {
1733+
// (#90483) apply adjustments to avoid ExprUseVisitor from
1734+
// creating erroneous projection.
1735+
self.apply_adjustments(base, adjustments);
17331736
self.ban_private_field_access(expr, expr_t, field, did);
17341737
return field_ty;
17351738
}

compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
420420
..
421421
},
422422
method,
423-
)) if Some(recv_ty.def_id()) == pin_did && method.ident.name == sym::new => {
423+
)) if recv_ty.opt_def_id() == pin_did && method.ident.name == sym::new => {
424424
err.span_suggestion(
425425
fn_name.span,
426426
"use `Box::pin` to pin and box this expression",

0 commit comments

Comments
 (0)