Improve handling of tmp
variable name conflicts
This commit is contained in:
parent
62b8ea67b7
commit
073010d425
5 changed files with 86 additions and 7 deletions
|
@ -1325,13 +1325,17 @@ impl<'a> Parser<'a> {
|
|||
kind: IncDecRecovery,
|
||||
(pre_span, post_span): (Span, Span),
|
||||
) {
|
||||
let mut msg = format!("use `{}= 1` instead", kind.op.chr());
|
||||
if base_src.trim() == "tmp" {
|
||||
msg.push_str(" (rename `tmp` so it doesn't conflict with your variable)");
|
||||
}
|
||||
err.multipart_suggestion(
|
||||
&format!("use `{}= 1` instead", kind.op.chr()),
|
||||
&msg,
|
||||
vec![
|
||||
(pre_span, "{ let tmp = ".to_string()),
|
||||
(post_span, format!("; {} {}= 1; tmp }}", base_src, kind.op.chr())),
|
||||
],
|
||||
Applicability::MachineApplicable,
|
||||
Applicability::HasPlaceholders,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue