Skip to content

Commit d75742b

Browse files
committed
Fix missing note on type mismatch error diagnostics
1 parent f208f20 commit d75742b

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

compiler/rustc_middle/src/ty/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'tcx> TyS<'tcx> {
5454
/// ADTs with no type arguments.
5555
pub fn is_simple_text(&self) -> bool {
5656
match self.kind() {
57-
Adt(_, substs) => substs.types().next().is_none(),
57+
Adt(_, substs) => substs.types().next().is_none() && substs.consts().next().is_none(),
5858
Ref(_, ty, _) => ty.is_simple_text(),
5959
_ => self.is_simple_ty(),
6060
}

src/test/ui/const-generics/defaults/mismatch.full.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ LL | let e: Example::<13> = ();
55
| ------------- ^^ expected struct `Example`, found `()`
66
| |
77
| expected due to this
8+
|
9+
= note: expected struct `Example`
10+
found unit type `()`
811

912
error[E0308]: mismatched types
1013
--> $DIR/mismatch.rs:14:34
@@ -40,12 +43,15 @@ LL | let e: Example3::<7> = ();
4043
found unit type `()`
4144

4245
error[E0308]: mismatched types
43-
--> $DIR/mismatch.rs:22:28
46+
--> $DIR/mismatch.rs:20:28
4447
|
4548
LL | let e: Example4::<7> = ();
4649
| ------------- ^^ expected struct `Example4`, found `()`
4750
| |
4851
| expected due to this
52+
|
53+
= note: expected struct `Example4<7_usize>`
54+
found unit type `()`
4955

5056
error: aborting due to 5 previous errors
5157

src/test/ui/const-generics/defaults/mismatch.min.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ LL | let e: Example::<13> = ();
55
| ------------- ^^ expected struct `Example`, found `()`
66
| |
77
| expected due to this
8+
|
9+
= note: expected struct `Example`
10+
found unit type `()`
811

912
error[E0308]: mismatched types
1013
--> $DIR/mismatch.rs:14:34
@@ -40,12 +43,15 @@ LL | let e: Example3::<7> = ();
4043
found unit type `()`
4144

4245
error[E0308]: mismatched types
43-
--> $DIR/mismatch.rs:22:28
46+
--> $DIR/mismatch.rs:20:28
4447
|
4548
LL | let e: Example4::<7> = ();
4649
| ------------- ^^ expected struct `Example4`, found `()`
4750
| |
4851
| expected due to this
52+
|
53+
= note: expected struct `Example4<7_usize>`
54+
found unit type `()`
4955

5056
error: aborting due to 5 previous errors
5157

src/test/ui/const-generics/defaults/mismatch.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ fn main() {
1717
//~^ Error: mismatched types
1818
let e: Example3::<7> = ();
1919
//~^ Error: mismatched types
20-
// FIXME(const_generics_defaults): There should be a note for the error below, but it is
21-
// missing.
2220
let e: Example4::<7> = ();
2321
//~^ Error: mismatched types
2422
}

0 commit comments

Comments
 (0)