Auto merge of #30953 - KalitaAlexey:17823-get-rid-of-duplicate-error, r=nrc
This commit is contained in:
commit
9d21acaf9b
14 changed files with 22 additions and 112 deletions
|
@ -486,13 +486,24 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let is_simple_error = if let &TypeError::Sorts(ref values) = terr {
|
||||||
|
values.expected.is_primitive() && values.found.is_primitive()
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
|
let expected_found_str = if is_simple_error {
|
||||||
|
expected_found_str
|
||||||
|
} else {
|
||||||
|
format!("{} ({})", expected_found_str, terr)
|
||||||
|
};
|
||||||
|
|
||||||
let mut err = struct_span_err!(self.tcx.sess,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
trace.origin.span(),
|
trace.origin.span(),
|
||||||
E0308,
|
E0308,
|
||||||
"{}: {} ({})",
|
"{}: {}",
|
||||||
trace.origin,
|
trace.origin,
|
||||||
expected_found_str,
|
expected_found_str);
|
||||||
terr);
|
|
||||||
|
|
||||||
self.check_and_note_conflicting_crates(&mut err, terr, trace.origin.span());
|
self.check_and_note_conflicting_crates(&mut err, terr, trace.origin.span());
|
||||||
|
|
||||||
|
|
|
@ -910,6 +910,13 @@ impl<'tcx> TyS<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_primitive(&self) -> bool {
|
||||||
|
match self.sty {
|
||||||
|
TyBool | TyChar | TyInt(_) | TyUint(_) | TyFloat(_) => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_ty_var(&self) -> bool {
|
pub fn is_ty_var(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyInfer(TyVar(_)) => true,
|
TyInfer(TyVar(_)) => true,
|
||||||
|
|
|
@ -13,6 +13,4 @@ fn main() {
|
||||||
//~^ ERROR if and else have incompatible types
|
//~^ ERROR if and else have incompatible types
|
||||||
//~| expected `i32`
|
//~| expected `i32`
|
||||||
//~| found `u32`
|
//~| found `u32`
|
||||||
//~| expected i32
|
|
||||||
//~| found u32
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,79 +43,55 @@ fn main() {
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i8`
|
//~| expected `i8`
|
||||||
//~| found `i16`
|
//~| found `i16`
|
||||||
//~| expected i8
|
|
||||||
//~| found i16
|
|
||||||
id_i8(a32);
|
id_i8(a32);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i8`
|
//~| expected `i8`
|
||||||
//~| found `i32`
|
//~| found `i32`
|
||||||
//~| expected i8
|
|
||||||
//~| found i32
|
|
||||||
id_i8(a64);
|
id_i8(a64);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i8`
|
//~| expected `i8`
|
||||||
//~| found `i64`
|
//~| found `i64`
|
||||||
//~| expected i8
|
|
||||||
//~| found i64
|
|
||||||
|
|
||||||
id_i16(a8);
|
id_i16(a8);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i16`
|
//~| expected `i16`
|
||||||
//~| found `i8`
|
//~| found `i8`
|
||||||
//~| expected i16
|
|
||||||
//~| found i8
|
|
||||||
id_i16(a16); // ok
|
id_i16(a16); // ok
|
||||||
id_i16(a32);
|
id_i16(a32);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i16`
|
//~| expected `i16`
|
||||||
//~| found `i32`
|
//~| found `i32`
|
||||||
//~| expected i16
|
|
||||||
//~| found i32
|
|
||||||
id_i16(a64);
|
id_i16(a64);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i16`
|
//~| expected `i16`
|
||||||
//~| found `i64`
|
//~| found `i64`
|
||||||
//~| expected i16
|
|
||||||
//~| found i64
|
|
||||||
|
|
||||||
id_i32(a8);
|
id_i32(a8);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i32`
|
//~| expected `i32`
|
||||||
//~| found `i8`
|
//~| found `i8`
|
||||||
//~| expected i32
|
|
||||||
//~| found i8
|
|
||||||
id_i32(a16);
|
id_i32(a16);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i32`
|
//~| expected `i32`
|
||||||
//~| found `i16`
|
//~| found `i16`
|
||||||
//~| expected i32
|
|
||||||
//~| found i16
|
|
||||||
id_i32(a32); // ok
|
id_i32(a32); // ok
|
||||||
id_i32(a64);
|
id_i32(a64);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i32`
|
//~| expected `i32`
|
||||||
//~| found `i64`
|
//~| found `i64`
|
||||||
//~| expected i32
|
|
||||||
//~| found i64
|
|
||||||
|
|
||||||
id_i64(a8);
|
id_i64(a8);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i64`
|
//~| expected `i64`
|
||||||
//~| found `i8`
|
//~| found `i8`
|
||||||
//~| expected i64
|
|
||||||
//~| found i8
|
|
||||||
id_i64(a16);
|
id_i64(a16);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i64`
|
//~| expected `i64`
|
||||||
//~| found `i16`
|
//~| found `i16`
|
||||||
//~| expected i64
|
|
||||||
//~| found i16
|
|
||||||
id_i64(a32);
|
id_i64(a32);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i64`
|
//~| expected `i64`
|
||||||
//~| found `i32`
|
//~| found `i32`
|
||||||
//~| expected i64
|
|
||||||
//~| found i32
|
|
||||||
id_i64(a64); // ok
|
id_i64(a64); // ok
|
||||||
|
|
||||||
id_i8(c8); // ok
|
id_i8(c8); // ok
|
||||||
|
@ -123,79 +99,55 @@ fn main() {
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i8`
|
//~| expected `i8`
|
||||||
//~| found `i16`
|
//~| found `i16`
|
||||||
//~| expected i8
|
|
||||||
//~| found i16
|
|
||||||
id_i8(c32);
|
id_i8(c32);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i8`
|
//~| expected `i8`
|
||||||
//~| found `i32`
|
//~| found `i32`
|
||||||
//~| expected i8
|
|
||||||
//~| found i32
|
|
||||||
id_i8(c64);
|
id_i8(c64);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i8`
|
//~| expected `i8`
|
||||||
//~| found `i64`
|
//~| found `i64`
|
||||||
//~| expected i8
|
|
||||||
//~| found i64
|
|
||||||
|
|
||||||
id_i16(c8);
|
id_i16(c8);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i16`
|
//~| expected `i16`
|
||||||
//~| found `i8`
|
//~| found `i8`
|
||||||
//~| expected i16
|
|
||||||
//~| found i8
|
|
||||||
id_i16(c16); // ok
|
id_i16(c16); // ok
|
||||||
id_i16(c32);
|
id_i16(c32);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i16`
|
//~| expected `i16`
|
||||||
//~| found `i32`
|
//~| found `i32`
|
||||||
//~| expected i16
|
|
||||||
//~| found i32
|
|
||||||
id_i16(c64);
|
id_i16(c64);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i16`
|
//~| expected `i16`
|
||||||
//~| found `i64`
|
//~| found `i64`
|
||||||
//~| expected i16
|
|
||||||
//~| found i64
|
|
||||||
|
|
||||||
id_i32(c8);
|
id_i32(c8);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i32`
|
//~| expected `i32`
|
||||||
//~| found `i8`
|
//~| found `i8`
|
||||||
//~| expected i32
|
|
||||||
//~| found i8
|
|
||||||
id_i32(c16);
|
id_i32(c16);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i32`
|
//~| expected `i32`
|
||||||
//~| found `i16`
|
//~| found `i16`
|
||||||
//~| expected i32
|
|
||||||
//~| found i16
|
|
||||||
id_i32(c32); // ok
|
id_i32(c32); // ok
|
||||||
id_i32(c64);
|
id_i32(c64);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i32`
|
//~| expected `i32`
|
||||||
//~| found `i64`
|
//~| found `i64`
|
||||||
//~| expected i32
|
|
||||||
//~| found i64
|
|
||||||
|
|
||||||
id_i64(a8);
|
id_i64(a8);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i64`
|
//~| expected `i64`
|
||||||
//~| found `i8`
|
//~| found `i8`
|
||||||
//~| expected i64
|
|
||||||
//~| found i8
|
|
||||||
id_i64(a16);
|
id_i64(a16);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i64`
|
//~| expected `i64`
|
||||||
//~| found `i16`
|
|
||||||
//~| expected i64
|
|
||||||
//~| found i16
|
//~| found i16
|
||||||
id_i64(a32);
|
id_i64(a32);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i64`
|
//~| expected `i64`
|
||||||
//~| found `i32`
|
//~| found `i32`
|
||||||
//~| expected i64
|
|
||||||
//~| found i32
|
|
||||||
id_i64(a64); // ok
|
id_i64(a64); // ok
|
||||||
|
|
||||||
id_u8(b8); // ok
|
id_u8(b8); // ok
|
||||||
|
@ -203,78 +155,54 @@ fn main() {
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u8`
|
//~| expected `u8`
|
||||||
//~| found `u16`
|
//~| found `u16`
|
||||||
//~| expected u8
|
|
||||||
//~| found u16
|
|
||||||
id_u8(b32);
|
id_u8(b32);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u8`
|
//~| expected `u8`
|
||||||
//~| found `u32`
|
//~| found `u32`
|
||||||
//~| expected u8
|
|
||||||
//~| found u32
|
|
||||||
id_u8(b64);
|
id_u8(b64);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u8`
|
//~| expected `u8`
|
||||||
//~| found `u64`
|
//~| found `u64`
|
||||||
//~| expected u8
|
|
||||||
//~| found u64
|
|
||||||
|
|
||||||
id_u16(b8);
|
id_u16(b8);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u16`
|
//~| expected `u16`
|
||||||
//~| found `u8`
|
//~| found `u8`
|
||||||
//~| expected u16
|
|
||||||
//~| found u8
|
|
||||||
id_u16(b16); // ok
|
id_u16(b16); // ok
|
||||||
id_u16(b32);
|
id_u16(b32);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u16`
|
//~| expected `u16`
|
||||||
//~| found `u32`
|
//~| found `u32`
|
||||||
//~| expected u16
|
|
||||||
//~| found u32
|
|
||||||
id_u16(b64);
|
id_u16(b64);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u16`
|
//~| expected `u16`
|
||||||
//~| found `u64`
|
//~| found `u64`
|
||||||
//~| expected u16
|
|
||||||
//~| found u64
|
|
||||||
|
|
||||||
id_u32(b8);
|
id_u32(b8);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u32`
|
//~| expected `u32`
|
||||||
//~| found `u8`
|
//~| found `u8`
|
||||||
//~| expected u32
|
|
||||||
//~| found u8
|
|
||||||
id_u32(b16);
|
id_u32(b16);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u32`
|
//~| expected `u32`
|
||||||
//~| found `u16`
|
//~| found `u16`
|
||||||
//~| expected u32
|
|
||||||
//~| found u16
|
|
||||||
id_u32(b32); // ok
|
id_u32(b32); // ok
|
||||||
id_u32(b64);
|
id_u32(b64);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u32`
|
//~| expected `u32`
|
||||||
//~| found `u64`
|
//~| found `u64`
|
||||||
//~| expected u32
|
|
||||||
//~| found u64
|
|
||||||
|
|
||||||
id_u64(b8);
|
id_u64(b8);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u64`
|
//~| expected `u64`
|
||||||
//~| found `u8`
|
//~| found `u8`
|
||||||
//~| expected u64
|
|
||||||
//~| found u8
|
|
||||||
id_u64(b16);
|
id_u64(b16);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u64`
|
//~| expected `u64`
|
||||||
//~| found `u16`
|
//~| found `u16`
|
||||||
//~| expected u64
|
|
||||||
//~| found u16
|
|
||||||
id_u64(b32);
|
id_u64(b32);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u64`
|
//~| expected `u64`
|
||||||
//~| found `u32`
|
//~| found `u32`
|
||||||
//~| expected u64
|
|
||||||
//~| found u32
|
|
||||||
id_u64(b64); // ok
|
id_u64(b64); // ok
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,9 @@ fn main() {
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i16`
|
//~| expected `i16`
|
||||||
//~| found `isize`
|
//~| found `isize`
|
||||||
//~| expected i16
|
|
||||||
//~| found isize
|
|
||||||
|
|
||||||
bar(1*(1 as usize));
|
bar(1*(1 as usize));
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u32`
|
//~| expected `u32`
|
||||||
//~| found `usize`
|
//~| found `usize`
|
||||||
//~| expected u32
|
|
||||||
//~| found usize
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,4 @@ fn main() {
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `char`
|
//~| expected `char`
|
||||||
//~| found `u8`
|
//~| found `u8`
|
||||||
//~| expected char
|
|
||||||
//~| found u8
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,4 @@ fn main() {
|
||||||
let x: char = true; //~ ERROR mismatched types
|
let x: char = true; //~ ERROR mismatched types
|
||||||
//~| expected `char`
|
//~| expected `char`
|
||||||
//~| found `bool`
|
//~| found `bool`
|
||||||
//~| expected char
|
|
||||||
//~| found bool
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,10 @@ enum Foo {
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `isize`
|
//~| expected `isize`
|
||||||
//~| found `i64`
|
//~| found `i64`
|
||||||
//~| expected isize
|
|
||||||
//~| found i64
|
|
||||||
B = 2u8
|
B = 2u8
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `isize`
|
//~| expected `isize`
|
||||||
//~| found `u8`
|
//~| found `u8`
|
||||||
//~| expected isize
|
|
||||||
//~| found u8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -42,6 +42,4 @@ fn main() {
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `char`
|
//~| expected `char`
|
||||||
//~| found `bool`
|
//~| found `bool`
|
||||||
//~| expected char
|
|
||||||
//~| found bool
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,9 @@ fn main() {
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u32`
|
//~| expected `u32`
|
||||||
//~| found `i32`
|
//~| found `i32`
|
||||||
//~| expected u32
|
|
||||||
//~| found i32
|
|
||||||
|
|
||||||
let_in(3i32, |i| { assert!(i == 3u32); });
|
let_in(3i32, |i| { assert!(i == 3u32); });
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i32`
|
//~| expected `i32`
|
||||||
//~| found `u32`
|
//~| found `u32`
|
||||||
//~| expected i32
|
|
||||||
//~| found u32
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,6 @@ fn main() {
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`
|
//~| expected `usize`
|
||||||
//~| found `bool`
|
//~| found `bool`
|
||||||
//~| expected usize
|
|
||||||
//~| found bool) [E0308]
|
|
||||||
//~| ERROR expected positive integer for repeat count, found boolean [E0306]
|
//~| ERROR expected positive integer for repeat count, found boolean [E0306]
|
||||||
let d = [0; 0.5];
|
let d = [0; 0.5];
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
|
@ -46,15 +44,11 @@ fn main() {
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`
|
//~| expected `usize`
|
||||||
//~| found `isize`
|
//~| found `isize`
|
||||||
//~| expected usize
|
|
||||||
//~| found isize) [E0308]
|
|
||||||
//~| ERROR expected positive integer for repeat count, found negative integer [E0306]
|
//~| ERROR expected positive integer for repeat count, found negative integer [E0306]
|
||||||
let f = [0_usize; -1_isize];
|
let f = [0_usize; -1_isize];
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`
|
//~| expected `usize`
|
||||||
//~| found `isize`
|
//~| found `isize`
|
||||||
//~| expected usize
|
|
||||||
//~| found isize) [E0308]
|
|
||||||
//~| ERROR expected positive integer for repeat count, found negative integer [E0306]
|
//~| ERROR expected positive integer for repeat count, found negative integer [E0306]
|
||||||
struct G {
|
struct G {
|
||||||
g: (),
|
g: (),
|
||||||
|
|
|
@ -36,8 +36,6 @@ fn foo(p: &Panolpy) {
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `i32`
|
//~| expected `i32`
|
||||||
//~| found `i64`
|
//~| found `i64`
|
||||||
//~| expected i32
|
|
||||||
//~| found i64)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -20,14 +20,10 @@ fn main() {
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u16`
|
//~| expected `u16`
|
||||||
//~| found `u8`
|
//~| found `u8`
|
||||||
//~| expected u16
|
|
||||||
//~| found u8
|
|
||||||
identity_u16(y);
|
identity_u16(y);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u16`
|
//~| expected `u16`
|
||||||
//~| found `i32`
|
//~| found `i32`
|
||||||
//~| expected u16
|
|
||||||
//~| found i32
|
|
||||||
|
|
||||||
let a = 3;
|
let a = 3;
|
||||||
|
|
||||||
|
@ -38,7 +34,4 @@ fn main() {
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `u16`
|
//~| expected `u16`
|
||||||
//~| found `isize`
|
//~| found `isize`
|
||||||
//~| expected u16
|
|
||||||
//~| found isize
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,5 +19,4 @@ fn main() { let a: bool = 1; let b: i32 = true; }
|
||||||
//~| ERROR mismatched types
|
//~| ERROR mismatched types
|
||||||
//~| expected `i32`
|
//~| expected `i32`
|
||||||
//~| found `bool`
|
//~| found `bool`
|
||||||
//~| expected i32
|
|
||||||
//~| found bool
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue