-
Notifications
You must be signed in to change notification settings - Fork 13k
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 #105595 - TaKO8Ki:suggest-dereferencing-receiver-argu…
…ment, r=compiler-errors Suggest dereferencing receiver arguments properly Fixes #105429
- Loading branch information
Showing
4 changed files
with
71 additions
and
6 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
14 changes: 14 additions & 0 deletions
14
src/test/ui/traits/suggest-deferences/suggest-dereferencing-receiver-argument.fixed
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,14 @@ | ||
// run-rustfix | ||
|
||
struct TargetStruct; | ||
|
||
impl From<usize> for TargetStruct { | ||
fn from(_unchecked: usize) -> Self { | ||
TargetStruct | ||
} | ||
} | ||
|
||
fn main() { | ||
let a = &3; | ||
let _b: TargetStruct = (*a).into(); //~ ERROR the trait bound `TargetStruct: From<&{integer}>` is not satisfied | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/traits/suggest-deferences/suggest-dereferencing-receiver-argument.rs
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,14 @@ | ||
// run-rustfix | ||
|
||
struct TargetStruct; | ||
|
||
impl From<usize> for TargetStruct { | ||
fn from(_unchecked: usize) -> Self { | ||
TargetStruct | ||
} | ||
} | ||
|
||
fn main() { | ||
let a = &3; | ||
let _b: TargetStruct = a.into(); //~ ERROR the trait bound `TargetStruct: From<&{integer}>` is not satisfied | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/traits/suggest-deferences/suggest-dereferencing-receiver-argument.stderr
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,15 @@ | ||
error[E0277]: the trait bound `TargetStruct: From<&{integer}>` is not satisfied | ||
--> $DIR/suggest-dereferencing-receiver-argument.rs:13:30 | ||
| | ||
LL | let _b: TargetStruct = a.into(); | ||
| ^^^^ the trait `From<&{integer}>` is not implemented for `TargetStruct` | ||
| | ||
= note: required for `&{integer}` to implement `Into<TargetStruct>` | ||
help: consider dereferencing here | ||
| | ||
LL | let _b: TargetStruct = (*a).into(); | ||
| ++ + | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |