You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"consider dereferencing here" help doesn't account for operator precedence of the deref operator #105429
structSourceStruct;structTargetStruct;implFrom<SourceStruct>forTargetStruct{fnfrom(unchecked:SourceStruct) -> Self{TargetStruct}}fnmain(){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.
Activity
Rollup merge of rust-lang#105595 - TaKO8Ki:suggest-dereferencing-rece…