@@ -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 ( ) ) ;
@@ -2276,7 +2269,7 @@ fn is_late_bound_map(
22762269 }
22772270
22782271 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 ( ) } ;
22802273 intravisit:: walk_fn_ret_ty ( & mut appears_in_output, & sig. decl . output ) ;
22812274 if appears_in_output. has_fully_capturing_opaque {
22822275 appears_in_output. regions . extend ( generics. params . iter ( ) . map ( |param| param. def_id ) ) ;
@@ -2289,7 +2282,7 @@ fn is_late_bound_map(
22892282 // Subtle point: because we disallow nested bindings, we can just
22902283 // ignore binders here and scrape up all names we see.
22912284 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 ( ) } ;
22932286 appears_in_where_clause. visit_generics ( generics) ;
22942287 debug ! ( ?appears_in_where_clause. regions) ;
22952288
@@ -2455,23 +2448,21 @@ fn is_late_bound_map(
24552448 }
24562449 }
24572450
2458- struct AllCollector < ' tcx > {
2459- tcx : TyCtxt < ' tcx > ,
2451+ struct AllCollector {
24602452 has_fully_capturing_opaque : bool ,
24612453 regions : FxHashSet < LocalDefId > ,
24622454 }
24632455
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 ) {
24662458 if let hir:: LifetimeName :: Param ( def_id) = lifetime_ref. res {
24672459 self . regions . insert ( def_id) ;
24682460 }
24692461 }
24702462
2471- fn visit_opaque_ty ( & mut self , opaque : & ' v hir:: OpaqueTy < ' v > ) {
2463+ fn visit_opaque_ty ( & mut self , opaque : & ' tcx hir:: OpaqueTy < ' tcx > ) {
24722464 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) ;
24752466 }
24762467 intravisit:: walk_opaque_ty ( self , opaque) ;
24772468 }
0 commit comments