Skip to content

Commit 970b94d

Browse files
committed
Auto merge of #129078 - lcnr:scrape_region_constraints-use-ocx, r=<try>
`ParamEnvAnd::fully_perform`: we have an `ocx`, use it cc #123669 r? `@compiler-errors`
2 parents 9859bf2 + 3a02047 commit 970b94d

File tree

1 file changed

+3
-35
lines changed
  • compiler/rustc_trait_selection/src/traits/query/type_op

1 file changed

+3
-35
lines changed

compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs

+3-35
Original file line numberDiff line numberDiff line change
@@ -170,44 +170,12 @@ where
170170
// collecting region constraints via `region_constraints`.
171171
let (mut output, _) = scrape_region_constraints(
172172
infcx,
173-
|_ocx| {
174-
let (output, ei, mut obligations, _) =
173+
|ocx| {
174+
let (output, ei, obligations, _) =
175175
Q::fully_perform_into(self, infcx, &mut region_constraints, span)?;
176176
error_info = ei;
177177

178-
// Typically, instantiating NLL query results does not
179-
// create obligations. However, in some cases there
180-
// are unresolved type variables, and unify them *can*
181-
// create obligations. In that case, we have to go
182-
// fulfill them. We do this via a (recursive) query.
183-
while !obligations.is_empty() {
184-
trace!("{:#?}", obligations);
185-
let mut progress = false;
186-
for obligation in std::mem::take(&mut obligations) {
187-
let obligation = infcx.resolve_vars_if_possible(obligation);
188-
match ProvePredicate::fully_perform_into(
189-
obligation.param_env.and(ProvePredicate::new(obligation.predicate)),
190-
infcx,
191-
&mut region_constraints,
192-
span,
193-
) {
194-
Ok(((), _, new, certainty)) => {
195-
obligations.extend(new);
196-
progress = true;
197-
if let Certainty::Ambiguous = certainty {
198-
obligations.push(obligation);
199-
}
200-
}
201-
Err(_) => obligations.push(obligation),
202-
}
203-
}
204-
if !progress {
205-
infcx.dcx().span_bug(
206-
span,
207-
format!("ambiguity processing {obligations:?} from {self:?}"),
208-
);
209-
}
210-
}
178+
ocx.register_obligations(obligations);
211179
Ok(output)
212180
},
213181
"fully_perform",

0 commit comments

Comments
 (0)