mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Auto merge of #13034 - lowr:fix/regression-from-12993, r=lowr
fix: escape keywords used as names in earlier editions Fixes #13030 There are keywords in Rust 2018+ that you can use as names without escaping when your crate is in Rust 2015 e.g. "try". We need to be consistent on how to keep track of the names regardless of how they are actually written in each crate. This patch attempts at it by taking such names into account and storing them uniformly in their escaped form.
This commit is contained in:
commit
d6412b5866
2 changed files with 11 additions and 3 deletions
|
@ -402,7 +402,9 @@ impl<'a> FindUsages<'a> {
|
|||
.or_else(|| ty.as_builtin().map(|builtin| builtin.name()))
|
||||
})
|
||||
};
|
||||
self.def.name(sema.db).or_else(self_kw_refs).map(|it| it.to_smol_str())
|
||||
// We need to unescape the name in case it is written without "r#" in earlier
|
||||
// editions of Rust where it isn't a keyword.
|
||||
self.def.name(sema.db).or_else(self_kw_refs).map(|it| it.unescaped().to_smol_str())
|
||||
}
|
||||
};
|
||||
let name = match &name {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue