1
Fork 0

Fix missing note on type mismatch error diagnostics

This commit is contained in:
Ellen 2021-05-29 05:37:45 +01:00
parent f208f207d6
commit d75742b1eb
4 changed files with 15 additions and 5 deletions

View file

@ -54,7 +54,7 @@ impl<'tcx> TyS<'tcx> {
/// ADTs with no type arguments.
pub fn is_simple_text(&self) -> bool {
match self.kind() {
Adt(_, substs) => substs.types().next().is_none(),
Adt(_, substs) => substs.types().next().is_none() && substs.consts().next().is_none(),
Ref(_, ty, _) => ty.is_simple_text(),
_ => self.is_simple_ty(),
}

View file

@ -5,6 +5,9 @@ LL | let e: Example::<13> = ();
| ------------- ^^ expected struct `Example`, found `()`
| |
| expected due to this
|
= note: expected struct `Example`
found unit type `()`
error[E0308]: mismatched types
--> $DIR/mismatch.rs:14:34
@ -40,12 +43,15 @@ LL | let e: Example3::<7> = ();
found unit type `()`
error[E0308]: mismatched types
--> $DIR/mismatch.rs:22:28
--> $DIR/mismatch.rs:20:28
|
LL | let e: Example4::<7> = ();
| ------------- ^^ expected struct `Example4`, found `()`
| |
| expected due to this
|
= note: expected struct `Example4<7_usize>`
found unit type `()`
error: aborting due to 5 previous errors

View file

@ -5,6 +5,9 @@ LL | let e: Example::<13> = ();
| ------------- ^^ expected struct `Example`, found `()`
| |
| expected due to this
|
= note: expected struct `Example`
found unit type `()`
error[E0308]: mismatched types
--> $DIR/mismatch.rs:14:34
@ -40,12 +43,15 @@ LL | let e: Example3::<7> = ();
found unit type `()`
error[E0308]: mismatched types
--> $DIR/mismatch.rs:22:28
--> $DIR/mismatch.rs:20:28
|
LL | let e: Example4::<7> = ();
| ------------- ^^ expected struct `Example4`, found `()`
| |
| expected due to this
|
= note: expected struct `Example4<7_usize>`
found unit type `()`
error: aborting due to 5 previous errors

View file

@ -17,8 +17,6 @@ fn main() {
//~^ Error: mismatched types
let e: Example3::<7> = ();
//~^ Error: mismatched types
// FIXME(const_generics_defaults): There should be a note for the error below, but it is
// missing.
let e: Example4::<7> = ();
//~^ Error: mismatched types
}