@@ -126,13 +126,14 @@ where
126
126
127
127
let infcx_compat = infcx. fork ( ) ;
128
128
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.
130
131
let outlives_env = OutlivesEnvironment :: new_with_implied_bounds_compat (
131
132
& infcx,
132
133
body_def_id,
133
134
param_env,
134
135
assumed_wf_types. iter ( ) . copied ( ) ,
135
- false ,
136
+ true ,
136
137
) ;
137
138
138
139
lint_redundant_lifetimes ( tcx, body_def_id, & outlives_env) ;
@@ -142,53 +143,22 @@ where
142
143
return Ok ( ( ) ) ;
143
144
}
144
145
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
+ // FIXME: Once we fix bevy, this would be the place to insert a warning
158
+ // to upgrade bevy.
159
+ Ok ( ( ) )
165
160
} 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 ( ( ) )
161
+ Err ( infcx_compat. err_ctxt ( ) . report_region_errors ( body_def_id, & errors_compat) )
192
162
}
193
163
}
194
164
0 commit comments