@@ -126,13 +126,14 @@ where
126126
127127 let infcx_compat = infcx. fork ( ) ;
128128
129- // We specifically want to call the non-compat version of `implied_bounds_tys`; we do this always.
129+ // We specifically want to *disable* the implied bounds hack, first,
130+ // so we can detect when failures are due to bevy's implied bounds.
130131 let outlives_env = OutlivesEnvironment :: new_with_implied_bounds_compat (
131132 & infcx,
132133 body_def_id,
133134 param_env,
134135 assumed_wf_types. iter ( ) . copied ( ) ,
135- false ,
136+ true ,
136137 ) ;
137138
138139 lint_redundant_lifetimes ( tcx, body_def_id, & outlives_env) ;
@@ -142,53 +143,20 @@ where
142143 return Ok ( ( ) ) ;
143144 }
144145
145- let is_bevy = assumed_wf_types. visit_with ( & mut ContainsBevyParamSet { tcx } ) . is_break ( ) ;
146-
147- // If we have set `no_implied_bounds_compat`, then do not attempt compatibility.
148- // We could also just always enter if `is_bevy`, and call `implied_bounds_tys`,
149- // but that does result in slightly more work when this option is set and
150- // just obscures what we mean here anyways. Let's just be explicit.
151- if is_bevy && !infcx. tcx . sess . opts . unstable_opts . no_implied_bounds_compat {
152- let outlives_env = OutlivesEnvironment :: new_with_implied_bounds_compat (
153- & infcx,
154- body_def_id,
155- param_env,
156- assumed_wf_types,
157- true ,
158- ) ;
159- let errors_compat = infcx_compat. resolve_regions_with_outlives_env ( & outlives_env) ;
160- if errors_compat. is_empty ( ) {
161- Ok ( ( ) )
162- } else {
163- Err ( infcx_compat. err_ctxt ( ) . report_region_errors ( body_def_id, & errors_compat) )
164- }
146+ let outlives_env = OutlivesEnvironment :: new_with_implied_bounds_compat (
147+ & infcx_compat,
148+ body_def_id,
149+ param_env,
150+ assumed_wf_types,
151+ // Don't *disable* the implied bounds hack; though this will only apply
152+ // the implied bounds hack if this contains `bevy_ecs`'s `ParamSet` type.
153+ false ,
154+ ) ;
155+ let errors_compat = infcx_compat. resolve_regions_with_outlives_env ( & outlives_env) ;
156+ if errors_compat. is_empty ( ) {
157+ Ok ( ( ) )
165158 } else {
166- Err ( infcx. err_ctxt ( ) . report_region_errors ( body_def_id, & errors) )
167- }
168- }
169-
170- struct ContainsBevyParamSet < ' tcx > {
171- tcx : TyCtxt < ' tcx > ,
172- }
173-
174- impl < ' tcx > TypeVisitor < TyCtxt < ' tcx > > for ContainsBevyParamSet < ' tcx > {
175- type Result = ControlFlow < ( ) > ;
176-
177- fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> Self :: Result {
178- // We only care to match `ParamSet<T>` or `&ParamSet<T>`.
179- match t. kind ( ) {
180- ty:: Adt ( def, _) => {
181- if self . tcx . item_name ( def. did ( ) ) == sym:: ParamSet
182- && self . tcx . crate_name ( def. did ( ) . krate ) == sym:: bevy_ecs
183- {
184- return ControlFlow :: Break ( ( ) ) ;
185- }
186- }
187- ty:: Ref ( _, ty, _) => ty. visit_with ( self ) ?,
188- _ => { }
189- }
190-
191- ControlFlow :: Continue ( ( ) )
159+ Err ( infcx_compat. err_ctxt ( ) . report_region_errors ( body_def_id, & errors_compat) )
192160 }
193161}
194162
0 commit comments