Skip to content

Commit 44cfafe

Browse files
committed
Auto merge of #108707 - matthiaskrgr:rollup-9a2l6pc, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #107981 (new solver: implement canonicalization and region constraints) - #108553 (Deny capturing late-bound non-lifetime param in anon const) - #108599 (Remove legacy PM leftovers) - #108667 (Fix another ICE in `point_at_expr_source_of_inferred_type`) - #108674 (Clippy Fix array-size-threshold config deserialization error) - #108685 (Match unmatched backticks in compiler/) - #108694 (Match unmatched backticks in compiler/ comments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7a809ce + 01fc5a7 commit 44cfafe

File tree

88 files changed

+1086
-222
lines changed

Some content is hidden

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

88 files changed

+1086
-222
lines changed

compiler/rustc_ast/src/util/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl AssocOp {
225225
AssignOp(_) | // `{ 42 } +=`
226226
As | // `{ 42 } as usize`
227227
// Equal | // `{ 42 } == { 42 }` Accepting these here would regress incorrect
228-
// NotEqual | // `{ 42 } != { 42 } struct literals parser recovery.
228+
// NotEqual | // `{ 42 } != { 42 }` struct literals parser recovery.
229229
Colon, // `{ 42 }: usize`
230230
)
231231
}

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16071607
hir::OwnerNode::Item(self.arena.alloc(opaque_ty_item))
16081608
}
16091609

1610-
/// Given a `parent_def_id`, a list of `lifetimes_in_bounds and a `remapping` hash to be
1610+
/// Given a `parent_def_id`, a list of `lifetimes_in_bounds` and a `remapping` hash to be
16111611
/// filled, this function creates new definitions for `Param` and `Fresh` lifetimes, inserts the
16121612
/// new definition, adds it to the remapping with the definition of the given lifetime and
16131613
/// returns a list of lifetimes to be lowered afterwards.

compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'a> AstValidator<'a> {
192192
// We allow these:
193193
// - `Option<impl Trait>`
194194
// - `option::Option<impl Trait>`
195-
// - `option::Option<T>::Foo<impl Trait>
195+
// - `option::Option<T>::Foo<impl Trait>`
196196
//
197197
// But not these:
198198
// - `<impl Trait>::Foo`

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
415415
/// fn foo<'a, 'b>(x: &'a u32) -> &'b u32 { x }
416416
/// ```
417417
///
418-
/// Here we would be invoked with `fr = 'a` and `outlived_fr = `'b`.
418+
/// Here we would be invoked with `fr = 'a` and `outlived_fr = 'b`.
419419
pub(crate) fn report_region_error(
420420
&mut self,
421421
fr: RegionVid,
@@ -949,7 +949,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
949949
.push_span_label(*span, "this has an implicit `'static` lifetime requirement");
950950
multi_span.push_span_label(
951951
ident.span,
952-
"calling this method introduces the `impl`'s 'static` requirement",
952+
"calling this method introduces the `impl`'s `'static` requirement",
953953
);
954954
err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span });
955955
err.span_suggestion_verbose(

compiler/rustc_borrowck/src/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
889889
/// from a universe it can't name; at present, the only way for
890890
/// this to be true is if `scc` outlives `'static`. This is
891891
/// actually stricter than necessary: ideally, we'd support bounds
892-
/// like `for<'a: 'b`>` that might then allow us to approximate
892+
/// like `for<'a: 'b>` that might then allow us to approximate
893893
/// `'a` with `'b` and not `'static`. But it will have to do for
894894
/// now.
895895
fn add_incompatible_universe(&mut self, scc: ConstraintSccIndex) {

compiler/rustc_borrowck/src/region_infer/values.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ pub(crate) struct RegionValues<N: Idx> {
235235
free_regions: SparseBitMatrix<N, RegionVid>,
236236

237237
/// Placeholders represent bound regions -- so something like `'a`
238-
/// in for<'a> fn(&'a u32)`.
238+
/// in `for<'a> fn(&'a u32)`.
239239
placeholders: SparseBitMatrix<N, PlaceholderIndex>,
240240
}
241241

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1814,8 +1814,6 @@ extern "C" {
18141814
/// Creates a legacy pass manager -- only used for final codegen.
18151815
pub fn LLVMCreatePassManager<'a>() -> &'a mut PassManager<'a>;
18161816

1817-
pub fn LLVMInitializePasses();
1818-
18191817
pub fn LLVMTimeTraceProfilerInitialize();
18201818

18211819
pub fn LLVMTimeTraceProfilerFinishThread();

compiler/rustc_codegen_llvm/src/llvm_util.rs

-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ unsafe fn configure_llvm(sess: &Session) {
120120
llvm::LLVMTimeTraceProfilerInitialize();
121121
}
122122

123-
llvm::LLVMInitializePasses();
124-
125123
rustc_llvm::initialize_available_targets();
126124

127125
llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int, llvm_args.as_ptr());

compiler/rustc_const_eval/src/interpret/intrinsics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
457457
assert_eq!(input_len, dest_len, "Return vector length must match input length");
458458
assert!(
459459
index < dest_len,
460-
"Index `{}` must be in bounds of vector with length {}`",
460+
"Index `{}` must be in bounds of vector with length {}",
461461
index,
462462
dest_len
463463
);
@@ -477,7 +477,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
477477
let (input, input_len) = self.operand_to_simd(&args[0])?;
478478
assert!(
479479
index < input_len,
480-
"index `{}` must be in bounds of vector with length `{}`",
480+
"index `{}` must be in bounds of vector with length {}",
481481
index,
482482
input_len
483483
);

compiler/rustc_const_eval/src/transform/check_consts/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
332332

333333
fn check_static(&mut self, def_id: DefId, span: Span) {
334334
if self.tcx.is_thread_local_static(def_id) {
335-
self.tcx.sess.delay_span_bug(span, "tls access is checked in `Rvalue::ThreadLocalRef");
335+
self.tcx.sess.delay_span_bug(span, "tls access is checked in `Rvalue::ThreadLocalRef`");
336336
}
337337
self.check_op_spanned(ops::StaticAccess, span)
338338
}

compiler/rustc_data_structures/src/stable_hasher/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn test_isize_compression() {
150150
let hash_b = hash(&(b as isize, a as isize));
151151
assert_ne!(
152152
hash_a, hash_b,
153-
"The hash stayed the same when permuting values `{a}` and `{b}!",
153+
"The hash stayed the same when permuting values `{a}` and `{b}`!",
154154
);
155155
}
156156

compiler/rustc_expand/src/mbe/transcribe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ pub(super) fn transcribe<'a>(
282282
}
283283

284284
// There should be no meta-var declarations in the invocation of a macro.
285-
mbe::TokenTree::MetaVarDecl(..) => panic!("unexpected `TokenTree::MetaVarDecl"),
285+
mbe::TokenTree::MetaVarDecl(..) => panic!("unexpected `TokenTree::MetaVarDecl`"),
286286
}
287287
}
288288
}

compiler/rustc_hir_analysis/locales/en-US.ftl

+8
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,11 @@ hir_analysis_main_function_generic_parameters = `main` function is not allowed t
147147
148148
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like {$conventions}
149149
.label = C-variadic function must have a compatible calling convention
150+
151+
hir_analysis_cannot_capture_late_bound_ty_in_anon_const =
152+
cannot capture late-bound type parameter in a constant
153+
.label = parameter defined here
154+
155+
hir_analysis_cannot_capture_late_bound_const_in_anon_const =
156+
cannot capture late-bound const parameter in a constant
157+
.label = parameter defined here

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1873,7 +1873,7 @@ pub(super) fn check_type_bounds<'tcx>(
18731873
// type Bar<C> =...
18741874
// }
18751875
//
1876-
// - `impl_trait_ref` would be `<(A, B) as Foo<u32>>
1876+
// - `impl_trait_ref` would be `<(A, B) as Foo<u32>>`
18771877
// - `impl_ty_substs` would be `[A, B, ^0.0]` (`^0.0` here is the bound var with db 0 and index 0)
18781878
// - `rebased_substs` would be `[(A, B), u32, ^0.0]`, combining the substs from
18791879
// the *trait* with the generic associated type parameters (as bound vars).

compiler/rustc_hir_analysis/src/coherence/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
437437
}
438438

439439
// Here we are considering a case of converting
440-
// `S<P0...Pn>` to S<Q0...Qn>`. As an example, let's imagine a struct `Foo<T, U>`,
440+
// `S<P0...Pn>` to `S<Q0...Qn>`. As an example, let's imagine a struct `Foo<T, U>`,
441441
// which acts like a pointer to `U`, but carries along some extra data of type `T`:
442442
//
443443
// struct Foo<T, U> {

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+57-5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use rustc_span::symbol::{sym, Ident};
2424
use rustc_span::Span;
2525
use std::fmt;
2626

27+
use crate::errors;
28+
2729
trait RegionExt {
2830
fn early(param: &GenericParam<'_>) -> (LocalDefId, ResolvedArg);
2931

@@ -161,6 +163,15 @@ enum Scope<'a> {
161163
s: ScopeRef<'a>,
162164
},
163165

166+
/// Disallows capturing non-lifetime binders from parent scopes.
167+
///
168+
/// This is necessary for something like `for<T> [(); { /* references T */ }]:`,
169+
/// since we don't do something more correct like replacing any captured
170+
/// late-bound vars with early-bound params in the const's own generics.
171+
AnonConstBoundary {
172+
s: ScopeRef<'a>,
173+
},
174+
164175
Root {
165176
opt_parent_item: Option<LocalDefId>,
166177
},
@@ -211,6 +222,7 @@ impl<'a> fmt::Debug for TruncatedScopeDebug<'a> {
211222
.field("s", &"..")
212223
.finish(),
213224
Scope::TraitRefBoundary { s: _ } => f.debug_struct("TraitRefBoundary").finish(),
225+
Scope::AnonConstBoundary { s: _ } => f.debug_struct("AnonConstBoundary").finish(),
214226
Scope::Root { opt_parent_item } => {
215227
f.debug_struct("Root").field("opt_parent_item", &opt_parent_item).finish()
216228
}
@@ -312,7 +324,9 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
312324
break (vec![], BinderScopeType::Normal);
313325
}
314326

315-
Scope::Elision { s, .. } | Scope::ObjectLifetimeDefault { s, .. } => {
327+
Scope::Elision { s, .. }
328+
| Scope::ObjectLifetimeDefault { s, .. }
329+
| Scope::AnonConstBoundary { s } => {
316330
scope = s;
317331
}
318332

@@ -1029,6 +1043,12 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
10291043
fn visit_poly_trait_ref(&mut self, trait_ref: &'tcx hir::PolyTraitRef<'tcx>) {
10301044
self.visit_poly_trait_ref_inner(trait_ref, NonLifetimeBinderAllowed::Allow);
10311045
}
1046+
1047+
fn visit_anon_const(&mut self, c: &'tcx hir::AnonConst) {
1048+
self.with(Scope::AnonConstBoundary { s: self.scope }, |this| {
1049+
intravisit::walk_anon_const(this, c);
1050+
});
1051+
}
10321052
}
10331053

10341054
fn object_lifetime_default(tcx: TyCtxt<'_>, param_def_id: DefId) -> ObjectLifetimeDefault {
@@ -1275,7 +1295,8 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
12751295
Scope::Elision { s, .. }
12761296
| Scope::ObjectLifetimeDefault { s, .. }
12771297
| Scope::Supertrait { s, .. }
1278-
| Scope::TraitRefBoundary { s, .. } => {
1298+
| Scope::TraitRefBoundary { s, .. }
1299+
| Scope::AnonConstBoundary { s } => {
12791300
scope = s;
12801301
}
12811302
}
@@ -1340,7 +1361,8 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
13401361
| Scope::Elision { s, .. }
13411362
| Scope::ObjectLifetimeDefault { s, .. }
13421363
| Scope::Supertrait { s, .. }
1343-
| Scope::TraitRefBoundary { s, .. } => {
1364+
| Scope::TraitRefBoundary { s, .. }
1365+
| Scope::AnonConstBoundary { s } => {
13441366
scope = s;
13451367
}
13461368
}
@@ -1359,6 +1381,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
13591381
// search.
13601382
let mut late_depth = 0;
13611383
let mut scope = self.scope;
1384+
let mut crossed_anon_const = false;
13621385
let result = loop {
13631386
match *scope {
13641387
Scope::Body { s, .. } => {
@@ -1392,10 +1415,36 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
13921415
| Scope::TraitRefBoundary { s, .. } => {
13931416
scope = s;
13941417
}
1418+
1419+
Scope::AnonConstBoundary { s } => {
1420+
crossed_anon_const = true;
1421+
scope = s;
1422+
}
13951423
}
13961424
};
13971425

13981426
if let Some(def) = result {
1427+
if let ResolvedArg::LateBound(..) = def && crossed_anon_const {
1428+
let use_span = self.tcx.hir().span(hir_id);
1429+
let def_span = self.tcx.def_span(param_def_id);
1430+
match self.tcx.def_kind(param_def_id) {
1431+
DefKind::ConstParam => {
1432+
self.tcx.sess.emit_err(errors::CannotCaptureLateBoundInAnonConst::Const {
1433+
use_span,
1434+
def_span,
1435+
});
1436+
}
1437+
DefKind::TyParam => {
1438+
self.tcx.sess.emit_err(errors::CannotCaptureLateBoundInAnonConst::Type {
1439+
use_span,
1440+
def_span,
1441+
});
1442+
}
1443+
_ => unreachable!(),
1444+
}
1445+
return;
1446+
}
1447+
13991448
self.map.defs.insert(hir_id, def);
14001449
return;
14011450
}
@@ -1474,7 +1523,8 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
14741523
| Scope::Elision { s, .. }
14751524
| Scope::ObjectLifetimeDefault { s, .. }
14761525
| Scope::Supertrait { s, .. }
1477-
| Scope::TraitRefBoundary { s, .. } => {
1526+
| Scope::TraitRefBoundary { s, .. }
1527+
| Scope::AnonConstBoundary { s } => {
14781528
scope = s;
14791529
}
14801530
}
@@ -1710,7 +1760,9 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
17101760

17111761
Scope::ObjectLifetimeDefault { lifetime: Some(l), .. } => break l,
17121762

1713-
Scope::Supertrait { s, .. } | Scope::TraitRefBoundary { s, .. } => {
1763+
Scope::Supertrait { s, .. }
1764+
| Scope::TraitRefBoundary { s, .. }
1765+
| Scope::AnonConstBoundary { s } => {
17141766
scope = s;
17151767
}
17161768
}

compiler/rustc_hir_analysis/src/errors.rs

+18
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,21 @@ pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
381381
pub span: Span,
382382
pub conventions: &'a str,
383383
}
384+
385+
#[derive(Diagnostic)]
386+
pub(crate) enum CannotCaptureLateBoundInAnonConst {
387+
#[diag(hir_analysis_cannot_capture_late_bound_ty_in_anon_const)]
388+
Type {
389+
#[primary_span]
390+
use_span: Span,
391+
#[label]
392+
def_span: Span,
393+
},
394+
#[diag(hir_analysis_cannot_capture_late_bound_const_in_anon_const)]
395+
Const {
396+
#[primary_span]
397+
use_span: Span,
398+
#[label]
399+
def_span: Span,
400+
},
401+
}

compiler/rustc_hir_typeck/src/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
315315
probe::ProbeScope::TraitsInScope,
316316
None,
317317
) {
318-
Ok(pick) => pick.self_ty,
318+
Ok(pick) => eraser.fold_ty(pick.self_ty),
319319
Err(_) => rcvr_ty,
320320
};
321321
// Remove one layer of references to account for `&mut self` and

compiler/rustc_hir_typeck/src/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
636636
// `&&Some(x,)` `place_foo`
637637
// `&Some(x,)` `deref { place_foo}`
638638
// `Some(x,)` `deref { deref { place_foo }}`
639-
// (x,)` `field0 { deref { deref { place_foo }}}` <- resulting place
639+
// `(x,)` `field0 { deref { deref { place_foo }}}` <- resulting place
640640
//
641641
// The above example has no adjustments. If the code were instead the (after adjustments,
642642
// equivalent) version

compiler/rustc_hir_typeck/src/upvar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,7 @@ fn determine_place_ancestry_relation<'tcx>(
22232223
/// || drop(&*m.a.field_of_a)
22242224
/// // Here we really do want to capture `*m.a` because that outlives `'static`
22252225
///
2226-
/// // If we capture `m`, then the closure no longer outlives `'static'
2226+
/// // If we capture `m`, then the closure no longer outlives `'static`
22272227
/// // it is constrained to `'a`
22282228
/// }
22292229
/// ```

compiler/rustc_incremental/src/assert_module_sources.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//! the HIR doesn't change as a result of the annotations, which might
1919
//! perturb the reuse results.
2020
//!
21-
//! `#![rustc_expected_cgu_reuse(module="spike", cfg="rpass2", kind="post-lto")]
21+
//! `#![rustc_expected_cgu_reuse(module="spike", cfg="rpass2", kind="post-lto")]`
2222
//! allows for doing a more fine-grained check to see if pre- or post-lto data
2323
//! was re-used.
2424

compiler/rustc_index/src/bit_set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,7 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
18701870
}
18711871
}
18721872

1873-
/// Subtracts `set from `row`. `set` can be either `BitSet` or
1873+
/// Subtracts `set` from `row`. `set` can be either `BitSet` or
18741874
/// `HybridBitSet`. Has no effect if `row` does not exist.
18751875
///
18761876
/// Returns true if the row was changed.

0 commit comments

Comments
 (0)