On type mismatch errors, use a suggestion when encountering minimal differences in type differences due to refs, instead of a note.
66 lines
2.0 KiB
Plaintext
66 lines
2.0 KiB
Plaintext
error[E0308]: mismatched types
|
|
--> $DIR/deref-suggestion.rs:18:9
|
|
|
|
|
18 | foo(s); //~ ERROR mismatched types
|
|
| ^ expected struct `std::string::String`, found reference
|
|
|
|
|
= note: expected type `std::string::String`
|
|
found type `&std::string::String`
|
|
= help: here are some functions which might fulfill your needs:
|
|
- .escape_debug()
|
|
- .escape_default()
|
|
- .escape_unicode()
|
|
- .to_ascii_lowercase()
|
|
- .to_ascii_uppercase()
|
|
|
|
error[E0308]: mismatched types
|
|
--> $DIR/deref-suggestion.rs:23:10
|
|
|
|
|
23 | foo3(u); //~ ERROR mismatched types
|
|
| ^
|
|
| |
|
|
| expected u32, found &u32
|
|
| help: consider dereferencing the borrow: `*u`
|
|
|
|
|
= note: expected type `u32`
|
|
found type `&u32`
|
|
|
|
error[E0308]: mismatched types
|
|
--> $DIR/deref-suggestion.rs:30:9
|
|
|
|
|
30 | foo(&"aaa".to_owned()); //~ ERROR mismatched types
|
|
| ^^^^^^^^^^^^^^^^^
|
|
| |
|
|
| expected struct `std::string::String`, found reference
|
|
| help: consider removing the borrow: `"aaa".to_owned()`
|
|
|
|
|
= note: expected type `std::string::String`
|
|
found type `&std::string::String`
|
|
|
|
error[E0308]: mismatched types
|
|
--> $DIR/deref-suggestion.rs:31:9
|
|
|
|
|
31 | foo(&mut "aaa".to_owned()); //~ ERROR mismatched types
|
|
| ^^^^^^^^^^^^^^^^^^^^^
|
|
| |
|
|
| expected struct `std::string::String`, found mutable reference
|
|
| help: consider removing the borrow: `"aaa".to_owned()`
|
|
|
|
|
= note: expected type `std::string::String`
|
|
found type `&mut std::string::String`
|
|
|
|
error[E0308]: mismatched types
|
|
--> $DIR/deref-suggestion.rs:12:20
|
|
|
|
|
12 | ($x:expr) => { &$x } //~ ERROR mismatched types
|
|
| ^^^ expected u32, found &{integer}
|
|
...
|
|
32 | foo3(borrow!(0));
|
|
| ---------- in this macro invocation
|
|
|
|
|
= note: expected type `u32`
|
|
found type `&{integer}`
|
|
|
|
error: aborting due to 5 previous errors
|
|
|