Add raw identifier in a typo suggestion
This commit is contained in:
parent
aed2187d53
commit
589c2fe24d
@ -1617,7 +1617,7 @@ pub(crate) fn add_typo_suggestion(
|
|||||||
let post = format!(", consider renaming `{}` into `{snippet}`", suggestion.candidate);
|
let post = format!(", consider renaming `{}` into `{snippet}`", suggestion.candidate);
|
||||||
(span, snippet, post)
|
(span, snippet, post)
|
||||||
} else {
|
} else {
|
||||||
(span, suggestion.candidate.to_string(), String::new())
|
(span, suggestion.candidate.to_ident_string(), String::new())
|
||||||
};
|
};
|
||||||
let msg = match suggestion.target {
|
let msg = match suggestion.target {
|
||||||
SuggestionTarget::SimilarlyNamed => format!(
|
SuggestionTarget::SimilarlyNamed => format!(
|
||||||
|
11
tests/ui/span/suggestion-raw-68962.rs
Normal file
11
tests/ui/span/suggestion-raw-68962.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fn r#fn() {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let r#final = 1;
|
||||||
|
|
||||||
|
// Should correctly suggest variable defined using raw identifier.
|
||||||
|
fina; //~ ERROR cannot find value
|
||||||
|
|
||||||
|
// Should correctly suggest function defined using raw identifier.
|
||||||
|
f(); //~ ERROR cannot find function
|
||||||
|
}
|
18
tests/ui/span/suggestion-raw-68962.stderr
Normal file
18
tests/ui/span/suggestion-raw-68962.stderr
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
error[E0425]: cannot find value `fina` in this scope
|
||||||
|
--> $DIR/suggestion-raw-68962.rs:7:5
|
||||||
|
|
|
||||||
|
LL | fina;
|
||||||
|
| ^^^^ help: a local variable with a similar name exists: `r#final`
|
||||||
|
|
||||||
|
error[E0425]: cannot find function `f` in this scope
|
||||||
|
--> $DIR/suggestion-raw-68962.rs:10:5
|
||||||
|
|
|
||||||
|
LL | fn r#fn() {}
|
||||||
|
| --------- similarly named function `r#fn` defined here
|
||||||
|
...
|
||||||
|
LL | f();
|
||||||
|
| ^ help: a function with a similar name exists: `r#fn`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0425`.
|
Loading…
Reference in New Issue
Block a user