@@ -305,21 +305,15 @@ fn generic_param_def_as_bound_arg(param: &ty::GenericParamDef) -> ty::BoundVaria
305
305
}
306
306
307
307
/// Whether this opaque always captures lifetimes in scope.
308
- /// Right now, this is all RPITIT and TAITs, and when `lifetime_capture_rules_2024`
309
- /// is enabled. We don't check the span of the edition, since this is done
310
- /// on a per-opaque basis to account for nested opaques.
311
- fn opaque_captures_all_in_scope_lifetimes < ' tcx > (
312
- tcx : TyCtxt < ' tcx > ,
313
- opaque : & ' tcx hir:: OpaqueTy < ' tcx > ,
314
- ) -> bool {
308
+ /// Right now, this is all RPITIT and TAITs, and when the opaque
309
+ /// is coming from a span corresponding to edition 2024.
310
+ fn opaque_captures_all_in_scope_lifetimes < ' tcx > ( opaque : & ' tcx hir:: OpaqueTy < ' tcx > ) -> bool {
315
311
match opaque. origin {
316
312
// if the opaque has the `use<...>` syntax, the user is telling us that they only want
317
313
// to account for those lifetimes, so do not try to be clever.
318
314
_ if opaque. bounds . iter ( ) . any ( |bound| matches ! ( bound, hir:: GenericBound :: Use ( ..) ) ) => false ,
319
315
hir:: OpaqueTyOrigin :: AsyncFn { .. } | hir:: OpaqueTyOrigin :: TyAlias { .. } => true ,
320
- _ if tcx. features ( ) . lifetime_capture_rules_2024 ( ) || opaque. span . at_least_rust_2024 ( ) => {
321
- true
322
- }
316
+ _ if opaque. span . at_least_rust_2024 ( ) => true ,
323
317
hir:: OpaqueTyOrigin :: FnReturn { in_trait_or_impl, .. } => in_trait_or_impl. is_some ( ) ,
324
318
}
325
319
}
@@ -519,8 +513,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
519
513
fn visit_opaque_ty ( & mut self , opaque : & ' tcx rustc_hir:: OpaqueTy < ' tcx > ) {
520
514
let captures = RefCell :: new ( FxIndexMap :: default ( ) ) ;
521
515
522
- let capture_all_in_scope_lifetimes =
523
- opaque_captures_all_in_scope_lifetimes ( self . tcx , opaque) ;
516
+ let capture_all_in_scope_lifetimes = opaque_captures_all_in_scope_lifetimes ( opaque) ;
524
517
if capture_all_in_scope_lifetimes {
525
518
let lifetime_ident = |def_id : LocalDefId | {
526
519
let name = self . tcx . item_name ( def_id. to_def_id ( ) ) ;
@@ -2276,7 +2269,7 @@ fn is_late_bound_map(
2276
2269
}
2277
2270
2278
2271
let mut appears_in_output =
2279
- AllCollector { tcx , has_fully_capturing_opaque : false , regions : Default :: default ( ) } ;
2272
+ AllCollector { has_fully_capturing_opaque : false , regions : Default :: default ( ) } ;
2280
2273
intravisit:: walk_fn_ret_ty ( & mut appears_in_output, & sig. decl . output ) ;
2281
2274
if appears_in_output. has_fully_capturing_opaque {
2282
2275
appears_in_output. regions . extend ( generics. params . iter ( ) . map ( |param| param. def_id ) ) ;
@@ -2289,7 +2282,7 @@ fn is_late_bound_map(
2289
2282
// Subtle point: because we disallow nested bindings, we can just
2290
2283
// ignore binders here and scrape up all names we see.
2291
2284
let mut appears_in_where_clause =
2292
- AllCollector { tcx , has_fully_capturing_opaque : true , regions : Default :: default ( ) } ;
2285
+ AllCollector { has_fully_capturing_opaque : true , regions : Default :: default ( ) } ;
2293
2286
appears_in_where_clause. visit_generics ( generics) ;
2294
2287
debug ! ( ?appears_in_where_clause. regions) ;
2295
2288
@@ -2455,23 +2448,21 @@ fn is_late_bound_map(
2455
2448
}
2456
2449
}
2457
2450
2458
- struct AllCollector < ' tcx > {
2459
- tcx : TyCtxt < ' tcx > ,
2451
+ struct AllCollector {
2460
2452
has_fully_capturing_opaque : bool ,
2461
2453
regions : FxHashSet < LocalDefId > ,
2462
2454
}
2463
2455
2464
- impl < ' v > Visitor < ' v > for AllCollector < ' v > {
2465
- fn visit_lifetime ( & mut self , lifetime_ref : & ' v hir:: Lifetime ) {
2456
+ impl < ' tcx > Visitor < ' tcx > for AllCollector {
2457
+ fn visit_lifetime ( & mut self , lifetime_ref : & ' tcx hir:: Lifetime ) {
2466
2458
if let hir:: LifetimeName :: Param ( def_id) = lifetime_ref. res {
2467
2459
self . regions . insert ( def_id) ;
2468
2460
}
2469
2461
}
2470
2462
2471
- fn visit_opaque_ty ( & mut self , opaque : & ' v hir:: OpaqueTy < ' v > ) {
2463
+ fn visit_opaque_ty ( & mut self , opaque : & ' tcx hir:: OpaqueTy < ' tcx > ) {
2472
2464
if !self . has_fully_capturing_opaque {
2473
- self . has_fully_capturing_opaque =
2474
- opaque_captures_all_in_scope_lifetimes ( self . tcx , opaque) ;
2465
+ self . has_fully_capturing_opaque = opaque_captures_all_in_scope_lifetimes ( opaque) ;
2475
2466
}
2476
2467
intravisit:: walk_opaque_ty ( self , opaque) ;
2477
2468
}
0 commit comments