mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Rollup merge of #126673 - oli-obk:dont_rely_on_err_reporting, r=compiler-errors
Ensure we don't accidentally succeed when we want to report an error This also changes the `DefiningOpaqueTypes::No` to `Yes` without adding tests, as it is solely run on the error path to improve diagnostics. I was unable to provide a test that changes diagnostics, as all the tests I came up with ended up successfully constraining the opaque type and thus succeeding the coercion. r? ```@compiler-errors``` cc https://github.com/rust-lang/rust/issues/116652
This commit is contained in:
commit
49bdf460a2
@ -1245,11 +1245,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
expr,
|
||||
);
|
||||
|
||||
return self
|
||||
return Err(self
|
||||
.commit_if_ok(|_| {
|
||||
self.at(cause, self.param_env).lub(DefineOpaqueTypes::No, prev_ty, new_ty)
|
||||
self.at(cause, self.param_env).lub(DefineOpaqueTypes::Yes, prev_ty, new_ty)
|
||||
})
|
||||
.map(|ok| self.register_infer_ok_obligations(ok));
|
||||
.unwrap_err());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1259,10 +1259,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
if let Some(e) = first_error {
|
||||
Err(e)
|
||||
} else {
|
||||
self.commit_if_ok(|_| {
|
||||
self.at(cause, self.param_env).lub(DefineOpaqueTypes::No, prev_ty, new_ty)
|
||||
})
|
||||
.map(|ok| self.register_infer_ok_obligations(ok))
|
||||
Err(self
|
||||
.commit_if_ok(|_| {
|
||||
self.at(cause, self.param_env).lub(
|
||||
DefineOpaqueTypes::Yes,
|
||||
prev_ty,
|
||||
new_ty,
|
||||
)
|
||||
})
|
||||
.unwrap_err())
|
||||
}
|
||||
}
|
||||
Ok(ok) => {
|
||||
|
Loading…
Reference in New Issue
Block a user