Teach Diagnostics to highlight text
This commit is contained in:
parent
bd8e9b0c82
commit
fc774e629f
29 changed files with 242 additions and 67 deletions
|
|
@ -18,6 +18,5 @@ pub unsafe extern fn foo(a: i32, b: u32) -> u32 {
|
|||
//~^ ERROR: mismatched types
|
||||
//~| NOTE: expected normal fn, found unsafe fn
|
||||
//~| NOTE: expected type `fn(proc_macro::TokenStream) -> proc_macro::TokenStream`
|
||||
//~| NOTE: found type `unsafe extern "C" fn(i32, u32) -> u32 {foo}`
|
||||
loop {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,11 @@ pub trait Buffer<'a, R: Resources<'a>> {
|
|||
//~^ ERROR mismatched types
|
||||
//~| lifetime mismatch
|
||||
//~| NOTE expected type `Resources<'_>`
|
||||
//~| NOTE found type `Resources<'a>`
|
||||
//~| NOTE the lifetime 'a as defined on the method body at 14:4...
|
||||
//~| NOTE ...does not necessarily outlive the anonymous lifetime #1 defined on the method body
|
||||
//~| ERROR mismatched types
|
||||
//~| lifetime mismatch
|
||||
//~| NOTE expected type `Resources<'_>`
|
||||
//~| NOTE found type `Resources<'a>`
|
||||
//~| NOTE the anonymous lifetime #1 defined on the method body at 14:4...
|
||||
//~| NOTE ...does not necessarily outlive the lifetime 'a as defined on the method body
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ impl<'a, T: 'a> Iterator for RepeatMut<'a, T> {
|
|||
//~^ ERROR method not compatible with trait
|
||||
//~| lifetime mismatch
|
||||
//~| NOTE expected type `fn(&mut RepeatMut<'a, T>) -> std::option::Option<&mut T>`
|
||||
//~| NOTE found type `fn(&'a mut RepeatMut<'a, T>) -> std::option::Option<&mut T>`
|
||||
{
|
||||
//~^ NOTE the anonymous lifetime #1 defined on the body
|
||||
//~| NOTE ...does not necessarily outlive the lifetime 'a as defined on the body
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ error[E0053]: method `b` has an incompatible type for trait
|
|||
| ^ expected type parameter, found a different type parameter
|
||||
|
|
||||
= note: expected type `fn(&E, F) -> F`
|
||||
= note: found type `fn(&E, G) -> G`
|
||||
found type `fn(&E, G) -> G`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
23
src/test/ui/mismatched_types/E0053.stderr
Normal file
23
src/test/ui/mismatched_types/E0053.stderr
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
error[E0053]: method `foo` has an incompatible type for trait
|
||||
--> $DIR/E0053.rs:19:15
|
||||
|
|
||||
12 | fn foo(x: u16); //~ NOTE type in trait
|
||||
| --- type in trait
|
||||
...
|
||||
19 | fn foo(x: i16) { }
|
||||
| ^^^ expected u16, found i16
|
||||
|
||||
error[E0053]: method `bar` has an incompatible type for trait
|
||||
--> $DIR/E0053.rs:22:12
|
||||
|
|
||||
13 | fn bar(&self); //~ NOTE type in trait
|
||||
| ----- type in trait
|
||||
...
|
||||
22 | fn bar(&mut self) { }
|
||||
| ^^^^^^^^^ types differ in mutability
|
||||
|
|
||||
= note: expected type `fn(&Bar)`
|
||||
found type `fn(&mut Bar)`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
19
src/test/ui/mismatched_types/E0409.stderr
Normal file
19
src/test/ui/mismatched_types/E0409.stderr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
error[E0409]: variable `y` is bound with different mode in pattern #2 than in pattern #1
|
||||
--> $DIR/E0409.rs:15:23
|
||||
|
|
||||
15 | (0, ref y) | (y, 0) => {} //~ ERROR E0409
|
||||
| - ^ bound in different ways
|
||||
| |
|
||||
| first binding
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/E0409.rs:15:23
|
||||
|
|
||||
15 | (0, ref y) | (y, 0) => {} //~ ERROR E0409
|
||||
| ^ expected &{integer}, found integral variable
|
||||
|
|
||||
= note: expected type `&{integer}`
|
||||
found type `{integer}`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
11
src/test/ui/mismatched_types/issue-19109.stderr
Normal file
11
src/test/ui/mismatched_types/issue-19109.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-19109.rs:14:5
|
||||
|
|
||||
14 | t as *mut Trait
|
||||
| ^^^^^^^^^^^^^^^ expected (), found *-ptr
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `*mut Trait`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -5,7 +5,7 @@ error[E0308]: mismatched types
|
|||
| ^^^^ expected type parameter, found bool
|
||||
|
|
||||
= note: expected type `bool` (type parameter)
|
||||
= note: found type `bool` (bool)
|
||||
found type `bool` (bool)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ error[E0308]: mismatched types
|
|||
| ^^^^ expected struct `Foo`, found reference
|
||||
|
|
||||
= note: expected type `Foo`
|
||||
= note: found type `&_`
|
||||
found type `&_`
|
||||
= help: did you mean `foo: &Foo`?
|
||||
|
||||
error[E0308]: mismatched types
|
||||
|
|
@ -15,7 +15,7 @@ error[E0308]: mismatched types
|
|||
| ^^^^ expected u32, found reference
|
||||
|
|
||||
= note: expected type `u32`
|
||||
= note: found type `&_`
|
||||
found type `&_`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-38371.rs:31:8
|
||||
|
|
@ -24,7 +24,7 @@ error[E0308]: mismatched types
|
|||
| ^^^^^ expected u32, found reference
|
||||
|
|
||||
= note: expected type `u32`
|
||||
= note: found type `&_`
|
||||
found type `&_`
|
||||
|
||||
error[E0529]: expected an array or slice, found `u32`
|
||||
--> $DIR/issue-38371.rs:34:9
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ error[E0308]: mismatched types
|
|||
| |_____^ ...ending here: expected u32, found ()
|
||||
|
|
||||
= note: expected type `u32`
|
||||
= note: found type `()`
|
||||
found type `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
23
src/test/ui/mismatched_types/overloaded-calls-bad.stderr
Normal file
23
src/test/ui/mismatched_types/overloaded-calls-bad.stderr
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/overloaded-calls-bad.rs:38:17
|
||||
|
|
||||
38 | let ans = s("what"); //~ ERROR mismatched types
|
||||
| ^^^^^^ expected isize, found reference
|
||||
|
|
||||
= note: expected type `isize`
|
||||
found type `&'static str`
|
||||
|
||||
error[E0057]: this function takes 1 parameter but 0 parameters were supplied
|
||||
--> $DIR/overloaded-calls-bad.rs:42:15
|
||||
|
|
||||
42 | let ans = s();
|
||||
| ^^^ expected 1 parameter
|
||||
|
||||
error[E0057]: this function takes 1 parameter but 2 parameters were supplied
|
||||
--> $DIR/overloaded-calls-bad.rs:45:17
|
||||
|
|
||||
45 | let ans = s("burma", "shave");
|
||||
| ^^^^^^^^^^^^^^^^ expected 1 parameter
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
11
src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr
Normal file
11
src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/trait-bounds-cant-coerce.rs:24:7
|
||||
|
|
||||
24 | a(x); //~ ERROR mismatched types [E0308]
|
||||
| ^ expected trait `Foo + std::marker::Send`, found trait `Foo`
|
||||
|
|
||||
= note: expected type `Box<Foo + std::marker::Send + 'static>`
|
||||
found type `Box<Foo + 'static>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ error[E0053]: method `bar` has an incompatible type for trait
|
|||
| ^^^^ types differ in mutability
|
||||
|
|
||||
= note: expected type `fn(&mut Bar, &mut Bar)`
|
||||
= note: found type `fn(&mut Bar, &Bar)`
|
||||
found type `fn(&mut Bar, &Bar)`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ error[E0308]: mismatched types
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `std::result::Result`
|
||||
|
|
||||
= note: expected type `()`
|
||||
= note: found type `std::result::Result<bool, std::io::Error>`
|
||||
found type `std::result::Result<bool, std::io::Error>`
|
||||
= help: here are some functions which might fulfill your needs:
|
||||
- .unwrap()
|
||||
- .unwrap_err()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ error[E0308]: mismatched types
|
|||
| ^^^^^^^^^^^^^ expected usize, found struct `std::string::String`
|
||||
|
|
||||
= note: expected type `usize`
|
||||
= note: found type `std::string::String`
|
||||
found type `std::string::String`
|
||||
= help: here are some functions which might fulfill your needs:
|
||||
- .capacity()
|
||||
- .len()
|
||||
|
|
@ -17,7 +17,7 @@ error[E0308]: mismatched types
|
|||
| ^^^^^^^^^^^^^ expected &str, found struct `std::string::String`
|
||||
|
|
||||
= note: expected type `&str`
|
||||
= note: found type `std::string::String`
|
||||
found type `std::string::String`
|
||||
= help: here are some functions which might fulfill your needs:
|
||||
- .as_str()
|
||||
- .trim()
|
||||
|
|
@ -31,7 +31,7 @@ error[E0308]: mismatched types
|
|||
| ^^ types differ in mutability
|
||||
|
|
||||
= note: expected type `&mut std::string::String`
|
||||
= note: found type `&std::string::String`
|
||||
found type `&std::string::String`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-suggestions.rs:36:11
|
||||
|
|
@ -40,7 +40,7 @@ error[E0308]: mismatched types
|
|||
| ^^ types differ in mutability
|
||||
|
|
||||
= note: expected type `&mut i32`
|
||||
= note: found type `&std::string::String`
|
||||
found type `&std::string::String`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-suggestions.rs:42:9
|
||||
|
|
@ -49,7 +49,7 @@ error[E0308]: mismatched types
|
|||
| ^^^^^ cyclic type of infinite size
|
||||
|
|
||||
= note: expected type `_`
|
||||
= note: found type `Box<_>`
|
||||
found type `Box<_>`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ error[E0308]: mismatched method receiver
|
|||
| ^^^^^^^^^ expected Self, found struct `SomeType`
|
||||
|
|
||||
= note: expected type `&Self`
|
||||
= note: found type `&SomeType`
|
||||
found type `&SomeType`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ error[E0308]: mismatched types
|
|||
| ^^^^^^^^^^ expected (), found closure
|
||||
|
|
||||
= note: expected type `()`
|
||||
= note: found type `[closure@$DIR/move-closure.rs:15:17: 15:27]`
|
||||
found type `[closure@$DIR/move-closure.rs:15:17: 15:27]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue