@@ -15,6 +15,7 @@ use rustc_infer::infer::outlives::obligations::TypeOutlives;
15
15
use rustc_infer:: infer:: { self , InferCtxt , TyCtxtInferExt } ;
16
16
use rustc_middle:: mir:: ConstraintCategory ;
17
17
use rustc_middle:: query:: Providers ;
18
+ use rustc_middle:: ty:: print:: with_no_trimmed_paths;
18
19
use rustc_middle:: ty:: trait_def:: TraitSpecializationKind ;
19
20
use rustc_middle:: ty:: {
20
21
self , AdtKind , GenericParamDefKind , ToPredicate , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable ,
@@ -112,8 +113,6 @@ where
112
113
113
114
let assumed_wf_types = wfcx. ocx . assumed_wf_types_and_report_errors ( param_env, body_def_id) ?;
114
115
115
- let implied_bounds = infcx. implied_bounds_tys ( param_env, body_def_id, assumed_wf_types) ;
116
-
117
116
let errors = wfcx. select_all_or_error ( ) ;
118
117
if !errors. is_empty ( ) {
119
118
let err = infcx. err_ctxt ( ) . report_fulfillment_errors ( errors) ;
@@ -128,10 +127,58 @@ where
128
127
}
129
128
}
130
129
130
+ let infcx_compat = infcx. fork ( ) ;
131
+
132
+ debug ! ( ?assumed_wf_types) ;
133
+ let implied_bounds = infcx. implied_bounds_tys ( param_env, body_def_id, & assumed_wf_types) ;
131
134
let outlives_env = OutlivesEnvironment :: with_bounds ( param_env, implied_bounds) ;
132
135
133
- wfcx. ocx . resolve_regions_and_report_errors ( body_def_id, & outlives_env) ?;
134
- infcx. tainted_by_errors ( ) . error_reported ( )
136
+ let errors = infcx. resolve_regions ( & outlives_env) ;
137
+ if errors. is_empty ( ) {
138
+ return Ok ( ( ) ) ;
139
+ }
140
+
141
+ let is_bevy = ' is_bevy: {
142
+ // We don't want to emit this for dependents of Bevy, for now.
143
+ // See #119956
144
+ let is_bevy_paramset = |def : ty:: AdtDef < ' _ > | {
145
+ let adt_did = with_no_trimmed_paths ! ( infcx. tcx. def_path_str( def. 0 . did) ) ;
146
+ adt_did. contains ( "ParamSet" )
147
+ } ;
148
+ for ty in assumed_wf_types. iter ( ) {
149
+ match ty. kind ( ) {
150
+ ty:: Adt ( def, _) => {
151
+ if is_bevy_paramset ( * def) {
152
+ break ' is_bevy true ;
153
+ }
154
+ }
155
+ ty:: Ref ( _, ty, _) => match ty. kind ( ) {
156
+ ty:: Adt ( def, _) => {
157
+ if is_bevy_paramset ( * def) {
158
+ break ' is_bevy true ;
159
+ }
160
+ }
161
+ _ => { }
162
+ } ,
163
+ _ => { }
164
+ }
165
+ }
166
+ false
167
+ } ;
168
+
169
+ if is_bevy {
170
+ let implied_bounds =
171
+ infcx_compat. implied_bounds_tys_compat ( param_env, body_def_id, & assumed_wf_types) ;
172
+ let outlives_env = OutlivesEnvironment :: with_bounds ( param_env, implied_bounds) ;
173
+ let errors_compat = infcx_compat. resolve_regions ( & outlives_env) ;
174
+ if errors_compat. is_empty ( ) {
175
+ Ok ( ( ) )
176
+ } else {
177
+ Err ( infcx_compat. err_ctxt ( ) . report_region_errors ( body_def_id, & errors_compat) )
178
+ }
179
+ } else {
180
+ Err ( infcx. err_ctxt ( ) . report_region_errors ( body_def_id, & errors) )
181
+ }
135
182
}
136
183
137
184
fn check_well_formed ( tcx : TyCtxt < ' _ > , def_id : hir:: OwnerId ) -> Result < ( ) , ErrorGuaranteed > {
@@ -723,7 +770,7 @@ fn resolve_regions_with_wf_tys<'tcx>(
723
770
let infcx = tcx. infer_ctxt ( ) . build ( ) ;
724
771
let outlives_environment = OutlivesEnvironment :: with_bounds (
725
772
param_env,
726
- infcx. implied_bounds_tys ( param_env, id, wf_tys. clone ( ) ) ,
773
+ infcx. implied_bounds_tys_compat ( param_env, id, wf_tys) ,
727
774
) ;
728
775
let region_bound_pairs = outlives_environment. region_bound_pairs ( ) ;
729
776
0 commit comments