-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
fix(resolve): prevent infinite loop when glob-import self #110264
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
use _::a; | ||
//~^ ERROR expected identifier, found reserved identifier `_` | ||
//~| ERROR unresolved import `_` | ||
use _::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does use _::*
trigger the "glob-import a module into itself" in the first place?
I'd expect _
to resolve into Res::Err
here.
Is it possible to reproduce the ICE without _::*
, just with regular well-formed imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to reproduce the ICE without _::*, just with regular well-formed imports?
Will not occur, other cases will hit map_err
I'd expect _ to resolve into Res::Err here.
When executing new_key, special processing is performed for _
to ensure that _
each time the key
is not the same, it is intended to solve the case of xxx as _
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, fascinating.
The underscore_disambiguator += 1
should only apply when we define names, not when we are retrieving already added definitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest adding BindingKey::new
method that will be used everywhere by default, and rename new_key
to new_disambiguated_key
and use it only when adding use foo as _
imports to a module (in fn add_import
I guess, but I'm not sure).
Note that if new_key
is called for a single import twice in different contexts, then the resulting disambiguators are not consistent with each other, and it's something that is suspicious at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is independent from glob imports and we should do it first.
The glob change also looks reasonable, maybe it fixes some other actual issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I will open a new PR to rewrite new_key
, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, new PR.
This comment has been minimized.
This comment has been minimized.
…etrochenkov fix(resolve): only disambiguate binding key during define - close rust-lang#110164 - discussion: rust-lang#110264 (comment) r? `@petrochenkov`
…rochenkov fix(resolve): only disambiguate binding key during define - close rust-lang#110164 - discussion: rust-lang#110264 (comment) r? `@petrochenkov`
@bvanjoi FYI: when a PR is ready for review, send a message containing |
this issue had been solved by another PR, so it can be closed. |
close #110164