@@ -16,7 +16,6 @@ use rustc_lint_defs::builtin::SUPERTRAIT_ITEM_SHADOWING_DEFINITION;
16
16
use rustc_macros:: LintDiagnostic ;
17
17
use rustc_middle:: mir:: interpret:: ErrorHandled ;
18
18
use rustc_middle:: query:: Providers ;
19
- use rustc_middle:: ty:: print:: with_no_trimmed_paths;
20
19
use rustc_middle:: ty:: trait_def:: TraitSpecializationKind ;
21
20
use rustc_middle:: ty:: {
22
21
self , AdtKind , GenericArgKind , GenericArgs , GenericParamDefKind , Ty , TyCtxt , TypeFoldable ,
@@ -143,33 +142,7 @@ where
143
142
return Ok ( ( ) ) ;
144
143
}
145
144
146
- let is_bevy = ' is_bevy: {
147
- // We don't want to emit this for dependents of Bevy, for now.
148
- // See #119956
149
- let is_bevy_paramset = |def : ty:: AdtDef < ' _ > | {
150
- let adt_did = with_no_trimmed_paths ! ( infcx. tcx. def_path_str( def. 0 . did) ) ;
151
- adt_did. contains ( "ParamSet" )
152
- } ;
153
- for ty in assumed_wf_types. iter ( ) {
154
- match ty. kind ( ) {
155
- ty:: Adt ( def, _) => {
156
- if is_bevy_paramset ( * def) {
157
- break ' is_bevy true ;
158
- }
159
- }
160
- ty:: Ref ( _, ty, _) => match ty. kind ( ) {
161
- ty:: Adt ( def, _) => {
162
- if is_bevy_paramset ( * def) {
163
- break ' is_bevy true ;
164
- }
165
- }
166
- _ => { }
167
- } ,
168
- _ => { }
169
- }
170
- }
171
- false
172
- } ;
145
+ let is_bevy = assumed_wf_types. visit_with ( & mut ContainsBevyParamSet { tcx } ) . is_break ( ) ;
173
146
174
147
// If we have set `no_implied_bounds_compat`, then do not attempt compatibility.
175
148
// We could also just always enter if `is_bevy`, and call `implied_bounds_tys`,
@@ -194,6 +167,31 @@ where
194
167
}
195
168
}
196
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 ( ( ) )
192
+ }
193
+ }
194
+
197
195
fn check_well_formed ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> Result < ( ) , ErrorGuaranteed > {
198
196
let node = tcx. hir_node_by_def_id ( def_id) ;
199
197
let mut res = match node {
0 commit comments