-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
fn t(n: &mut i32) {
n = "42".parse().unwrap();
}I expected to see this happen: Suggestion of *n = ..., the correct code would be
fn t(n: &mut i32) {
*n = "42".parse().unwrap();
}Instead, this happened: It did not look at mutable deref value and directly show the suggestion
error[E0277]: the trait bound `&mut i32: std::str::FromStr` is not satisfied
--> src/lib.rs:2:14
|
2 | n = "42".parse().unwrap();
| ^^^^^ the trait `std::str::FromStr` is not implemented for `&mut i32`
|
= help: the following implementations were found:
<i32 as std::str::FromStr>
Not sure why but I miss * quite often. Link to playground https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=011e594936166764d011c581d7db107e
Meta
rustc --version --verbose:
1.42.0
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.