forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#61217 - estebank:issue-52820, r=Centril
Account for short-hand init structs when suggesting conversion Fix rust-lang#52820.
- Loading branch information
Showing
4 changed files
with
58 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
struct Bravery { | ||
guts: String, | ||
brains: String, | ||
} | ||
|
||
fn main() { | ||
let guts = "mettle"; | ||
let _ = Bravery { | ||
guts, //~ ERROR mismatched types | ||
brains: guts.clone(), //~ ERROR mismatched types | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-52820.rs:9:9 | ||
| | ||
LL | guts, | ||
| ^^^^ | ||
| | | ||
| expected struct `std::string::String`, found &str | ||
| help: try using a conversion method: `guts: guts.to_string()` | ||
| | ||
= note: expected type `std::string::String` | ||
found type `&str` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-52820.rs:10:17 | ||
| | ||
LL | brains: guts.clone(), | ||
| ^^^^^^^^^^^^ | ||
| | | ||
| expected struct `std::string::String`, found &str | ||
| help: try using a conversion method: `guts.to_string()` | ||
| | ||
= note: expected type `std::string::String` | ||
found type `&str` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |