@@ -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 ( ) ) ;
@@ -2273,7 +2266,7 @@ fn is_late_bound_map(
2273
2266
}
2274
2267
2275
2268
let mut appears_in_output =
2276
- AllCollector { tcx , has_fully_capturing_opaque : false , regions : Default :: default ( ) } ;
2269
+ AllCollector { has_fully_capturing_opaque : false , regions : Default :: default ( ) } ;
2277
2270
intravisit:: walk_fn_ret_ty ( & mut appears_in_output, & sig. decl . output ) ;
2278
2271
if appears_in_output. has_fully_capturing_opaque {
2279
2272
appears_in_output. regions . extend ( generics. params . iter ( ) . map ( |param| param. def_id ) ) ;
@@ -2286,7 +2279,7 @@ fn is_late_bound_map(
2286
2279
// Subtle point: because we disallow nested bindings, we can just
2287
2280
// ignore binders here and scrape up all names we see.
2288
2281
let mut appears_in_where_clause =
2289
- AllCollector { tcx , has_fully_capturing_opaque : true , regions : Default :: default ( ) } ;
2282
+ AllCollector { has_fully_capturing_opaque : true , regions : Default :: default ( ) } ;
2290
2283
appears_in_where_clause. visit_generics ( generics) ;
2291
2284
debug ! ( ?appears_in_where_clause. regions) ;
2292
2285
@@ -2452,23 +2445,21 @@ fn is_late_bound_map(
2452
2445
}
2453
2446
}
2454
2447
2455
- struct AllCollector < ' tcx > {
2456
- tcx : TyCtxt < ' tcx > ,
2448
+ struct AllCollector {
2457
2449
has_fully_capturing_opaque : bool ,
2458
2450
regions : FxHashSet < LocalDefId > ,
2459
2451
}
2460
2452
2461
- impl < ' v > Visitor < ' v > for AllCollector < ' v > {
2462
- fn visit_lifetime ( & mut self , lifetime_ref : & ' v hir:: Lifetime ) {
2453
+ impl < ' tcx > Visitor < ' tcx > for AllCollector {
2454
+ fn visit_lifetime ( & mut self , lifetime_ref : & ' tcx hir:: Lifetime ) {
2463
2455
if let hir:: LifetimeName :: Param ( def_id) = lifetime_ref. res {
2464
2456
self . regions . insert ( def_id) ;
2465
2457
}
2466
2458
}
2467
2459
2468
- fn visit_opaque_ty ( & mut self , opaque : & ' v hir:: OpaqueTy < ' v > ) {
2460
+ fn visit_opaque_ty ( & mut self , opaque : & ' tcx hir:: OpaqueTy < ' tcx > ) {
2469
2461
if !self . has_fully_capturing_opaque {
2470
- self . has_fully_capturing_opaque =
2471
- opaque_captures_all_in_scope_lifetimes ( self . tcx , opaque) ;
2462
+ self . has_fully_capturing_opaque = opaque_captures_all_in_scope_lifetimes ( opaque) ;
2472
2463
}
2473
2464
intravisit:: walk_opaque_ty ( self , opaque) ;
2474
2465
}
0 commit comments