Closed
Description
Given the following code:
struct SourceStruct;
struct TargetStruct;
impl From<SourceStruct> for TargetStruct {
fn from(unchecked: SourceStruct) -> Self {
TargetStruct
}
}
fn main() {
let a = &SourceStruct;
let b: TargetStruct = a.into();
}
The current output is:
error[E0277]: the trait bound `TargetStruct: From<&SourceStruct>` is not satisfied
--> src/main.rs:12:27
|
12 | let b: TargetStruct = a.into();
| ^ ---- required by a bound introduced by this call
| |
| the trait `From<&SourceStruct>` is not implemented for `TargetStruct`
|
= note: required for `&SourceStruct` to implement `Into<TargetStruct>`
help: consider dereferencing here
|
12 | let b: TargetStruct = *a.into();
| +
Ideally the output should look like:
help: consider dereferencing here
|
12 | let b: TargetStruct = (*a).into();
| ++ +
The current suggestion will apply the dereference after the method call to .into()
, which is not what is needed.
Really, that suggestion wouldn't even be suggested because the result also doesn't work, but that might be a bigger change.
Seen in 1.67.0-nightly (2022-12-06 b28d30e)