diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2023-05-20 12:21:01 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-20 12:21:01 +0530 |
| commit | c453b48fd8d2ef0721b470ad72f261e3bca5a50d (patch) | |
| tree | a789f4f00ac29b1132d38d8e9f1333a8dce23a60 | |
| parent | 93c031f6e663c428ee6e09b6fae2710ad3c54756 (diff) | |
| parent | 3e4ed61c0987d73af4c291b68cf76adfeaa349c6 (diff) | |
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 :grin:
| -rw-r--r-- | compiler/rustc_infer/src/infer/opaque_types.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs index 545310ad351..b88ba04b273 100644 --- a/compiler/rustc_infer/src/infer/opaque_types.rs +++ b/compiler/rustc_infer/src/infer/opaque_types.rs @@ -530,19 +530,18 @@ impl<'tcx> InferCtxt<'tcx> { // these are the same span, but not in cases like `-> (impl // Foo, impl Bar)`. let span = cause.span; - - let mut obligations = vec![]; let prev = self.inner.borrow_mut().opaque_types().register( OpaqueTypeKey { def_id, substs }, OpaqueHiddenType { ty: hidden_ty, span }, origin, ); - if let Some(prev) = prev { - obligations = self - .at(&cause, param_env) + let mut obligations = if let Some(prev) = prev { + self.at(&cause, param_env) .eq_exp(DefineOpaqueTypes::Yes, a_is_expected, prev, hidden_ty)? - .obligations; - } + .obligations + } else { + Vec::new() + }; let item_bounds = tcx.explicit_item_bounds(def_id); |
