Skip to content

Commit c4ec196

Browse files
committed
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.)
1 parent c475e23 commit c4ec196

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

compiler/rustc_middle/src/ty/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,11 @@ impl<'tcx> OpaqueHiddenType<'tcx> {
852852
.dcx()
853853
.steal_diagnostic(tcx.def_span(opaque_def_id), StashKey::OpaqueHiddenTypeMismatch)
854854
{
855-
diag.cancel();
855+
// We used to cancel here for slightly better error messages, but
856+
// cancelling stashed diagnostics is no longer allowed because it
857+
// causes problems when tracking whether errors have actually
858+
// occurred.
859+
diag.emit();
856860
}
857861
(self.ty, other.ty).error_reported()?;
858862
// Found different concrete types for the opaque type.

tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fn foo<'a, 'b>() -> Tait<'a> {
1111
}
1212
let x: Tait<'a> = ();
1313
x
14+
//~^ ERROR concrete type differs from previous defining opaque type use
1415
}
1516

1617
fn main() {}

tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
error: concrete type differs from previous defining opaque type use
2+
--> $DIR/different_defining_uses_never_type-2.rs:13:5
3+
|
4+
LL | x
5+
| ^ expected `i32`, got `()`
6+
|
7+
note: previous use here
8+
--> $DIR/different_defining_uses_never_type-2.rs:8:31
9+
|
10+
LL | let y: Tait<'b> = 1i32;
11+
| ^^^^
12+
113
error: concrete type differs from previous defining opaque type use
214
--> $DIR/different_defining_uses_never_type-2.rs:8:31
315
|
@@ -10,5 +22,5 @@ note: previous use here
1022
LL | if { return } {
1123
| ^^^^^^
1224

13-
error: aborting due to 1 previous error
25+
error: aborting due to 2 previous errors
1426

0 commit comments

Comments
 (0)