@@ -136,7 +136,6 @@ pub fn predicates_for_generics<'tcx>(
136
136
/// `bound` or is not known to meet bound (note that this is
137
137
/// conservative towards *no impl*, which is the opposite of the
138
138
/// `evaluate` methods).
139
- #[ instrument( level = "debug" , skip( infcx, param_env, span) , ret) ]
140
139
pub fn type_known_to_meet_bound_modulo_regions < ' tcx > (
141
140
infcx : & InferCtxt < ' tcx > ,
142
141
param_env : ty:: ParamEnv < ' tcx > ,
@@ -146,31 +145,40 @@ pub fn type_known_to_meet_bound_modulo_regions<'tcx>(
146
145
) -> bool {
147
146
let trait_ref =
148
147
ty:: Binder :: dummy ( ty:: TraitRef { def_id, substs : infcx. tcx . mk_substs_trait ( ty, & [ ] ) } ) ;
148
+ pred_known_to_hold_modulo_regions ( infcx, param_env, trait_ref. without_const ( ) , span)
149
+ }
150
+
151
+ #[ instrument( level = "debug" , skip( infcx, param_env, span, pred) , ret) ]
152
+ fn pred_known_to_hold_modulo_regions < ' tcx > (
153
+ infcx : & InferCtxt < ' tcx > ,
154
+ param_env : ty:: ParamEnv < ' tcx > ,
155
+ pred : impl ToPredicate < ' tcx , ty:: Predicate < ' tcx > > + TypeVisitable < ' tcx > ,
156
+ span : Span ,
157
+ ) -> bool {
158
+ let has_non_region_infer = pred. has_non_region_infer ( ) ;
149
159
let obligation = Obligation {
150
160
param_env,
161
+ // We can use a dummy node-id here because we won't pay any mind
162
+ // to region obligations that arise (there shouldn't really be any
163
+ // anyhow).
151
164
cause : ObligationCause :: misc ( span, hir:: CRATE_HIR_ID ) ,
152
165
recursion_depth : 0 ,
153
- predicate : trait_ref . without_const ( ) . to_predicate ( infcx. tcx ) ,
166
+ predicate : pred . to_predicate ( infcx. tcx ) ,
154
167
} ;
155
168
156
169
let result = infcx. predicate_must_hold_modulo_regions ( & obligation) ;
157
170
debug ! ( ?result) ;
158
171
159
- if result && ty . has_non_region_infer ( ) {
172
+ if result && has_non_region_infer {
160
173
// Because of inference "guessing", selection can sometimes claim
161
174
// to succeed while the success requires a guess. To ensure
162
175
// this function's result remains infallible, we must confirm
163
176
// that guess. While imperfect, I believe this is sound.
164
177
165
- // We can use a dummy node-id here because we won't pay any mind
166
- // to region obligations that arise (there shouldn't really be any
167
- // anyhow).
168
- let cause = ObligationCause :: misc ( span, hir:: CRATE_HIR_ID ) ;
169
-
170
178
// The handling of regions in this area of the code is terrible,
171
179
// see issue #29149. We should be able to improve on this with
172
180
// NLL.
173
- let errors = fully_solve_bound ( infcx, cause , param_env , ty , def_id ) ;
181
+ let errors = fully_solve_obligation ( infcx, obligation ) ;
174
182
175
183
// Note: we only assume something is `Copy` if we can
176
184
// *definitively* show that it implements `Copy`. Otherwise,
0 commit comments