parent
c1d2d83ca3
commit
edbbfad88f
5 changed files with 54 additions and 3 deletions
|
|
@ -4,7 +4,10 @@ error[E0308]: mismatched types
|
|||
LL | fn main() {
|
||||
| - expected `()` because of default return type
|
||||
LL | &panic!()
|
||||
| ^^^^^^^^^ expected (), found reference
|
||||
| ^^^^^^^^^
|
||||
| |
|
||||
| expected (), found reference
|
||||
| help: consider removing the borrow: `panic!()`
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `&_`
|
||||
|
|
|
|||
|
|
@ -1,13 +1,19 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/diverging-tuple-parts-39485.rs:8:5
|
||||
|
|
||||
LL | fn g() {
|
||||
| - help: try adding a return type: `-> &_`
|
||||
LL | &panic!() //~ ERROR mismatched types
|
||||
| ^^^^^^^^^ expected (), found reference
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `&_`
|
||||
help: try adding a return type
|
||||
|
|
||||
LL | fn g() -> &_ {
|
||||
| ^^^^^
|
||||
help: consider removing the borrow
|
||||
|
|
||||
LL | panic!() //~ ERROR mismatched types
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/diverging-tuple-parts-39485.rs:12:5
|
||||
|
|
|
|||
6
src/test/ui/suggestions/format-borrow.rs
Normal file
6
src/test/ui/suggestions/format-borrow.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
fn main() {
|
||||
let a: String = &String::from("a");
|
||||
//~^ ERROR mismatched types
|
||||
let b: String = &format!("b");
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
27
src/test/ui/suggestions/format-borrow.stderr
Normal file
27
src/test/ui/suggestions/format-borrow.stderr
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/format-borrow.rs:2:21
|
||||
|
|
||||
LL | let a: String = &String::from("a");
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| expected struct `std::string::String`, found reference
|
||||
| help: consider removing the borrow: `String::from("a")`
|
||||
|
|
||||
= note: expected type `std::string::String`
|
||||
found type `&std::string::String`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/format-borrow.rs:4:21
|
||||
|
|
||||
LL | let b: String = &format!("b");
|
||||
| ^^^^^^^^^^^^^
|
||||
| |
|
||||
| expected struct `std::string::String`, found reference
|
||||
| help: consider removing the borrow: `format!("b")`
|
||||
|
|
||||
= note: expected type `std::string::String`
|
||||
found type `&std::string::String`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue