Skip to content
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

Remove hir::Ident #33654

Merged
merged 3 commits into from
May 18, 2016
Merged

Remove hir::Ident #33654

merged 3 commits into from
May 18, 2016

Conversation

petrochenkov
Copy link
Contributor

Now when name resolution is done on AST, hir::Ident is no longer necessary.
See #30145 for more details.

r? @nrc

@@ -862,9 +865,14 @@ impl<'a> LoweringContext<'a> {
PatKind::Wild => hir::PatKind::Wild,
PatKind::Ident(ref binding_mode, pth1, ref sub) => {
self.with_parent_def(p.id, |this| {
let name = match this.resolver.get_resolution(p.id).map(|d| d.full_def()) {
// Only pattern bindings are renamed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we only sometimes rename here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to rename constants or unit variants/structs, that can also be represented with PatKind::Ident due to parsing ambiguities, only fresh bindings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this stage we are post-parsing and post-name resolution, so where do the remaining ambiguities get resolved? Put another way, in some sense this renaming must happen somewhere, where does it happen (and how)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the question.

At this stage we are post-parsing and post-name resolution, so where do the remaining ambiguities get resolved?

All ambiguities are resolved during name resolution, there's nothing ambiguous at this stage.

Put another way, in some sense this renaming must happen somewhere, where does it happen (and how)?

Renaming is done twice, once during name resolution, its results aren't saved anywhere, and once more during lowering to HIR, its results are persistent and kept in HIR.
Names in HIR need to be properly renamed to correctly treat cases like this, which in principle can be interpreted as requiring some rudimentary form of name resolution during type checking.

Copy link
Contributor Author

@petrochenkov petrochenkov May 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If tables of "canonical bindings" were filled during the main name resolution pass and saved for later, then HIR could keep plain non-renamed Names for everything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the explanation!

@bors
Copy link
Contributor

bors commented May 16, 2016

☔ The latest upstream changes (presumably #33505) made this pull request unmergeable. Please resolve the merge conflicts.

Do not rename invalid identifiers, they stop being invalid after renaming
@petrochenkov
Copy link
Contributor Author

Rebased.

@nrc
Copy link
Member

nrc commented May 18, 2016

@bors: r+

@bors
Copy link
Contributor

bors commented May 18, 2016

📌 Commit 02a1eef has been approved by nrc

@bors
Copy link
Contributor

bors commented May 18, 2016

⌛ Testing commit 02a1eef with merge 310d899...

bors added a commit that referenced this pull request May 18, 2016
Remove hir::Ident

Now when name resolution is done on AST, `hir::Ident` is no longer necessary.
See #30145 for more details.

r? @nrc
@bors bors merged commit 02a1eef into rust-lang:master May 18, 2016
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 16, 2016
Remove last traces of identifier hygiene from HIR

rust-lang@e783a0a removed the [last](rust-lang#33654 (comment)) [use](rust-lang#33654 (comment)) of hygiene at post-resolve compilation stages, so we can avoid renaming during lowering to HIR and just keep original names.

r? @nrc
@petrochenkov petrochenkov deleted the hirident branch September 21, 2016 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants