Fix missing note on type mismatch error diagnostics
This commit is contained in:
parent
f208f207d6
commit
d75742b1eb
4 changed files with 15 additions and 5 deletions
|
@ -54,7 +54,7 @@ impl<'tcx> TyS<'tcx> {
|
||||||
/// ADTs with no type arguments.
|
/// ADTs with no type arguments.
|
||||||
pub fn is_simple_text(&self) -> bool {
|
pub fn is_simple_text(&self) -> bool {
|
||||||
match self.kind() {
|
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(),
|
Ref(_, ty, _) => ty.is_simple_text(),
|
||||||
_ => self.is_simple_ty(),
|
_ => self.is_simple_ty(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,9 @@ LL | let e: Example::<13> = ();
|
||||||
| ------------- ^^ expected struct `Example`, found `()`
|
| ------------- ^^ expected struct `Example`, found `()`
|
||||||
| |
|
| |
|
||||||
| expected due to this
|
| expected due to this
|
||||||
|
|
|
||||||
|
= note: expected struct `Example`
|
||||||
|
found unit type `()`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/mismatch.rs:14:34
|
--> $DIR/mismatch.rs:14:34
|
||||||
|
@ -40,12 +43,15 @@ LL | let e: Example3::<7> = ();
|
||||||
found unit type `()`
|
found unit type `()`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/mismatch.rs:22:28
|
--> $DIR/mismatch.rs:20:28
|
||||||
|
|
|
|
||||||
LL | let e: Example4::<7> = ();
|
LL | let e: Example4::<7> = ();
|
||||||
| ------------- ^^ expected struct `Example4`, found `()`
|
| ------------- ^^ expected struct `Example4`, found `()`
|
||||||
| |
|
| |
|
||||||
| expected due to this
|
| expected due to this
|
||||||
|
|
|
||||||
|
= note: expected struct `Example4<7_usize>`
|
||||||
|
found unit type `()`
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,9 @@ LL | let e: Example::<13> = ();
|
||||||
| ------------- ^^ expected struct `Example`, found `()`
|
| ------------- ^^ expected struct `Example`, found `()`
|
||||||
| |
|
| |
|
||||||
| expected due to this
|
| expected due to this
|
||||||
|
|
|
||||||
|
= note: expected struct `Example`
|
||||||
|
found unit type `()`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/mismatch.rs:14:34
|
--> $DIR/mismatch.rs:14:34
|
||||||
|
@ -40,12 +43,15 @@ LL | let e: Example3::<7> = ();
|
||||||
found unit type `()`
|
found unit type `()`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/mismatch.rs:22:28
|
--> $DIR/mismatch.rs:20:28
|
||||||
|
|
|
|
||||||
LL | let e: Example4::<7> = ();
|
LL | let e: Example4::<7> = ();
|
||||||
| ------------- ^^ expected struct `Example4`, found `()`
|
| ------------- ^^ expected struct `Example4`, found `()`
|
||||||
| |
|
| |
|
||||||
| expected due to this
|
| expected due to this
|
||||||
|
|
|
||||||
|
= note: expected struct `Example4<7_usize>`
|
||||||
|
found unit type `()`
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,6 @@ fn main() {
|
||||||
//~^ Error: mismatched types
|
//~^ Error: mismatched types
|
||||||
let e: Example3::<7> = ();
|
let e: Example3::<7> = ();
|
||||||
//~^ Error: mismatched types
|
//~^ Error: mismatched types
|
||||||
// FIXME(const_generics_defaults): There should be a note for the error below, but it is
|
|
||||||
// missing.
|
|
||||||
let e: Example4::<7> = ();
|
let e: Example4::<7> = ();
|
||||||
//~^ Error: mismatched types
|
//~^ Error: mismatched types
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue