Skip to content

Commit c453b48

Browse files
authored
Rollup merge of #111723 - lcnr:overwrite-obligations, r=compiler-errors
style: do not overwrite obligations this looks sketchy and would break if the original obligations do not start out empty 😁
2 parents 93c031f + 3e4ed61 commit c453b48

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

compiler/rustc_infer/src/infer/opaque_types.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -530,19 +530,18 @@ impl<'tcx> InferCtxt<'tcx> {
530530
// these are the same span, but not in cases like `-> (impl
531531
// Foo, impl Bar)`.
532532
let span = cause.span;
533-
534-
let mut obligations = vec![];
535533
let prev = self.inner.borrow_mut().opaque_types().register(
536534
OpaqueTypeKey { def_id, substs },
537535
OpaqueHiddenType { ty: hidden_ty, span },
538536
origin,
539537
);
540-
if let Some(prev) = prev {
541-
obligations = self
542-
.at(&cause, param_env)
538+
let mut obligations = if let Some(prev) = prev {
539+
self.at(&cause, param_env)
543540
.eq_exp(DefineOpaqueTypes::Yes, a_is_expected, prev, hidden_ty)?
544-
.obligations;
545-
}
541+
.obligations
542+
} else {
543+
Vec::new()
544+
};
546545

547546
let item_bounds = tcx.explicit_item_bounds(def_id);
548547

0 commit comments

Comments
 (0)