forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#115595 - surechen:114896, r=davidtwco
Fix incorrect mutable suggestion information for binding in ref pattern like: `let &b = a;` fixes rust-lang#114896 I find we have to get pat_span but not local_decl.source_info.span for suggestion. In `let &b = a;` pat_span is &b. I think check `let &b = a` in hir to make sure it is hir::Node::Local(hir::Local {pat: hir::Pat{kind: hir::PatKind::Ref(....... can distinguish it from other situation, but I'm not sure. If my processing method is not accurate, please guide me to modify it, thank you. r? `@davidtwco`
- Loading branch information
Showing
3 changed files
with
96 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
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,7 @@ | ||
fn main() { | ||
fn x(a: &char) { | ||
let &b = a; | ||
b.make_ascii_uppercase(); | ||
//~^ cannot borrow `b` as mutable, as it is not declared as mutable | ||
} | ||
} |
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,11 @@ | ||
error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable | ||
--> $DIR/issue-114896.rs:4:9 | ||
| | ||
LL | let &b = a; | ||
| -- help: consider changing this to be mutable: `&(mut b)` | ||
LL | b.make_ascii_uppercase(); | ||
| ^ cannot borrow as mutable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0596`. |