Don't cancel stashed OpaqueHiddenTypeMismatch errors.

This gives one extra error message on one test, but is necessary to fix
bigger problems caused by the cancellation of stashed errors.

(Note: why not just avoid stashing altogether? Because that resulted in
additional output changes.)
This commit is contained in:
Nicholas Nethercote 2024-02-26 16:54:53 +11:00
parent c475e2303b
commit c4ec196c7e
3 changed files with 19 additions and 2 deletions

View File

@ -852,7 +852,11 @@ impl<'tcx> OpaqueHiddenType<'tcx> {
.dcx()
.steal_diagnostic(tcx.def_span(opaque_def_id), StashKey::OpaqueHiddenTypeMismatch)
{
diag.cancel();
// We used to cancel here for slightly better error messages, but
// cancelling stashed diagnostics is no longer allowed because it
// causes problems when tracking whether errors have actually
// occurred.
diag.emit();
}
(self.ty, other.ty).error_reported()?;
// Found different concrete types for the opaque type.

View File

@ -11,6 +11,7 @@ fn foo<'a, 'b>() -> Tait<'a> {
}
let x: Tait<'a> = ();
x
//~^ ERROR concrete type differs from previous defining opaque type use
}
fn main() {}

View File

@ -1,3 +1,15 @@
error: concrete type differs from previous defining opaque type use
--> $DIR/different_defining_uses_never_type-2.rs:13:5
|
LL | x
| ^ expected `i32`, got `()`
|
note: previous use here
--> $DIR/different_defining_uses_never_type-2.rs:8:31
|
LL | let y: Tait<'b> = 1i32;
| ^^^^
error: concrete type differs from previous defining opaque type use
--> $DIR/different_defining_uses_never_type-2.rs:8:31
|
@ -10,5 +22,5 @@ note: previous use here
LL | if { return } {
| ^^^^^^
error: aborting due to 1 previous error
error: aborting due to 2 previous errors