@@ -305,21 +305,15 @@ fn generic_param_def_as_bound_arg(param: &ty::GenericParamDef) -> ty::BoundVaria
305305}
306306
307307/// 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 {
315311 match opaque. origin {
316312 // if the opaque has the `use<...>` syntax, the user is telling us that they only want
317313 // to account for those lifetimes, so do not try to be clever.
318314 _ if opaque. bounds . iter ( ) . any ( |bound| matches ! ( bound, hir:: GenericBound :: Use ( ..) ) ) => false ,
319315 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 ,
323317 hir:: OpaqueTyOrigin :: FnReturn { in_trait_or_impl, .. } => in_trait_or_impl. is_some ( ) ,
324318 }
325319}
@@ -519,8 +513,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
519513 fn visit_opaque_ty ( & mut self , opaque : & ' tcx rustc_hir:: OpaqueTy < ' tcx > ) {
520514 let captures = RefCell :: new ( FxIndexMap :: default ( ) ) ;
521515
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) ;
524517 if capture_all_in_scope_lifetimes {
525518 let lifetime_ident = |def_id : LocalDefId | {
526519 let name = self . tcx . item_name ( def_id. to_def_id ( ) ) ;
@@ -2273,7 +2266,7 @@ fn is_late_bound_map(
22732266 }
22742267
22752268 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 ( ) } ;
22772270 intravisit:: walk_fn_ret_ty ( & mut appears_in_output, & sig. decl . output ) ;
22782271 if appears_in_output. has_fully_capturing_opaque {
22792272 appears_in_output. regions . extend ( generics. params . iter ( ) . map ( |param| param. def_id ) ) ;
@@ -2286,7 +2279,7 @@ fn is_late_bound_map(
22862279 // Subtle point: because we disallow nested bindings, we can just
22872280 // ignore binders here and scrape up all names we see.
22882281 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 ( ) } ;
22902283 appears_in_where_clause. visit_generics ( generics) ;
22912284 debug ! ( ?appears_in_where_clause. regions) ;
22922285
@@ -2452,23 +2445,21 @@ fn is_late_bound_map(
24522445 }
24532446 }
24542447
2455- struct AllCollector < ' tcx > {
2456- tcx : TyCtxt < ' tcx > ,
2448+ struct AllCollector {
24572449 has_fully_capturing_opaque : bool ,
24582450 regions : FxHashSet < LocalDefId > ,
24592451 }
24602452
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 ) {
24632455 if let hir:: LifetimeName :: Param ( def_id) = lifetime_ref. res {
24642456 self . regions . insert ( def_id) ;
24652457 }
24662458 }
24672459
2468- fn visit_opaque_ty ( & mut self , opaque : & ' v hir:: OpaqueTy < ' v > ) {
2460+ fn visit_opaque_ty ( & mut self , opaque : & ' tcx hir:: OpaqueTy < ' tcx > ) {
24692461 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) ;
24722463 }
24732464 intravisit:: walk_opaque_ty ( self , opaque) ;
24742465 }
0 commit comments