-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: escape keywords used as names in earlier editions #13034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I wanted to add a test, but I couldn't figure out how (I manually tested and confirmed #13030 is resolved with the patch). I even doubt if it's possible for the time being. Ideally we want to test something like this in nameres tests: //- /main.rs crate:main deps:liba edition:2015
#[macro_use]
extern crate liba;
use liba::try;
//- /lib.rs crate:liba edition:2018
#[macro_export]
macro_rules! r#try { () => {} } but we cannot, because it seems we unconditionally parse |
8f740d7
to
6e341fe
Compare
@bors d+ |
@bors delegate+ |
✌️ @lowr can now approve this pull request |
6e341fe
to
a3409c3
Compare
@bors r+ |
☀️ Test successful - checks-actions |
fix: Search raw identifiers without prefix When we find references/usages of a raw identifier, we should disregard `r#` prefix because there are keywords one can use without the prefix in earlier editions (see #13034; this bug is actually fallout from the PR). `name`, the text we're searching for, has already been stripped of the prefix, but the text of nodes we compare it to hasn't been. The second commit is strictly refactoring, I can remove it if it's not much of value.
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.