Skip to content

Use hir::ItemLocalId instead of ast::NodeId in rustc::middle::region::CodeExtent. #44171

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Sep 1, 2017

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Aug 30, 2017

This is an alternative to @michaelwoerister's #43887, changing CodeExtent instead of ReScope.

The benefit here is that the same Regions are used same-crate and cross-crate, while preserving the incremental recompilation properties of the stable hir::ItemLocalId.

Only places which needed to get back to the ast::NodeId from CodeExtent was its span method, used in error reporting - passing the &RegionMaps down allowed using hir_to_node_id.
rustc::cfg and dataflow also had to be converted to hir::ItemLocalId because of their interactions with CodeExtent, especially in borrowck, and from that we have 3 more hir_to_node_id calls: cfg::graphviz node labels, borrowck move reporting, and the unconditional_recursion lint.

Out of all of those, only the lint actually makes a decision (on whether code will compile) based on the result of the conversion, the others only use it to know how to print information to the user.
So I think we're safe to say that the bulk of the code working with a CodeExtent is fine with local IDs.

r? @nikomatsakis

@eddyb
Copy link
Member Author

eddyb commented Aug 30, 2017

Crater report shows no regressions, so I'm pretty confident this works.

@bors
Copy link
Collaborator

bors commented Aug 30, 2017

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

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

OK, I can't claim to have read these in depth, but everything looked straightforward to me. Basically what I would expect.


/// If there are any `yield` nested within a scope, this map
/// stores the `Span` of the first one.
yield_in_scope: FxHashMap<CodeExtent, Span>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you have to add this?

Copy link
Contributor

Choose a reason for hiding this comment

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

er, never mind, I found the answer later.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 30, 2017

📌 Commit 46ba34a has been approved by nikomatsakis

@eddyb
Copy link
Member Author

eddyb commented Aug 30, 2017

@bors r=nikomatsakis

@bors
Copy link
Collaborator

bors commented Aug 30, 2017

📌 Commit ae82c78 has been approved by nikomatsakis

@bors
Copy link
Collaborator

bors commented Aug 30, 2017

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

@eddyb
Copy link
Member Author

eddyb commented Aug 31, 2017

@bors r=nikomatsakis

@bors
Copy link
Collaborator

bors commented Aug 31, 2017

📌 Commit 7c18f29 has been approved by nikomatsakis

@bors
Copy link
Collaborator

bors commented Aug 31, 2017

⌛ Testing commit 7c18f29d1aece4414ada3c74e74f6ee5343e3f84 with merge a5d023839e716258e1e4e7caf193e7799f57420a...

@bors
Copy link
Collaborator

bors commented Aug 31, 2017

💔 Test failed - status-appveyor

@nikomatsakis
Copy link
Contributor

Hmm, the failure looks spurious to me:

testing https://github.com/Aaronepower/tokei
Initialized empty Git repository in /c/projects/rust/build/ct/tokei/.git/
fatal: Could not parse object '5e11c4852fe4aa086b0e4fe5885822fbe57ba928'.
From https://github.com/Aaronepower/tokei
 * branch            master     -> FETCH_HEAD
fatal: Could not parse object '5e11c4852fe4aa086b0e4fe5885822fbe57ba928'.
From https://github.com/Aaronepower/tokei
 * branch            master     -> FETCH_HEAD
fatal: Could not parse object '5e11c4852fe4aa086b0e4fe5885822fbe57ba928'.
From https://github.com/Aaronepower/tokei
 * branch            master     -> FETCH_HEAD
HEAD is now at 5e11c48 Add Agda Support (#91)
 Downloading lazy_static v0.2.2
error: unable to get packages from source

@nikomatsakis
Copy link
Contributor

@bors retry

  • failure to fetch Aaronepower/tokei repository (cc @rust-lang/infra -- not sure how to categorize these)

@bors
Copy link
Collaborator

bors commented Aug 31, 2017

⌛ Testing commit 7c18f29d1aece4414ada3c74e74f6ee5343e3f84 with merge 8547ab847c9d633d86b8bd1d647f42bb226e90ed...

@bors
Copy link
Collaborator

bors commented Aug 31, 2017

💔 Test failed - status-travis

@eddyb
Copy link
Member Author

eddyb commented Aug 31, 2017

@bors retry

  • macOS timeout

@bors
Copy link
Collaborator

bors commented Aug 31, 2017

⌛ Testing commit 7c18f29d1aece4414ada3c74e74f6ee5343e3f84 with merge 3a544be3fba295f7b27e64831430c44da770ead5...

@bors
Copy link
Collaborator

bors commented Aug 31, 2017

💔 Test failed - status-travis

@eddyb
Copy link
Member Author

eddyb commented Aug 31, 2017

Is nothing landing lately?

@kennytm
Copy link
Member

kennytm commented Aug 31, 2017

@bors retry #40474 (still check i686-apple-Darwin, but different error)

[00:28:20] [ 44%] Building CXX object lib/Analysis/CMakeFiles/LLVMAnalysis.dir/AliasAnalysis.cpp.o

[00:38:30] error: failed to execute compile

[00:38:30] caused by: error reading compile response from server

[00:38:30] caused by: Failed to read response header

[00:38:30] caused by: failed to fill whole buffer

[00:38:30] error: failed to execute compile

[00:38:30] caused by: error reading compile response from server

[00:38:30] caused by: Failed to read response header

[00:38:30] caused by: failed to fill whole buffer

[00:38:30] make[3]: *** [lib/LTO/CMakeFiles/LLVMLTO.dir/Caching.cpp.o] Error 2

[00:38:30] make[3]: *** [lib/Analysis/CMakeFiles/LLVMAnalysis.dir/AliasAnalysis.cpp.o] Error 2



No output has been received in the last 30m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received

The build has been terminated

@eddyb
Copy link
Member Author

eddyb commented Sep 1, 2017

@bors r=nikomatsakis

@bors
Copy link
Collaborator

bors commented Sep 1, 2017

📌 Commit e4996ec has been approved by nikomatsakis

bors added a commit that referenced this pull request Sep 1, 2017
Use hir::ItemLocalId instead of ast::NodeId in rustc::middle::region::CodeExtent.

This is an alternative to @michaelwoerister's #43887, changing `CodeExtent` instead of `ReScope`.

The benefit here is that the same `Region`s are used same-crate and cross-crate, while preserving the incremental recompilation properties of the stable `hir::ItemLocalId`.

Only places which needed to get back to the `ast::NodeId` from `CodeExtent` was its `span` method, used in error reporting - passing the `&RegionMaps` down allowed using `hir_to_node_id`.
`rustc::cfg` and `dataflow` also had to be converted to `hir::ItemLocalId` because of their interactions with `CodeExtent`, especially in `borrowck`, and from that we have 3 more `hir_to_node_id` calls: `cfg::graphviz` node labels, `borrowck` move reporting, and the `unconditional_recursion` lint.

Out of all of those, *only* the lint actually makes a decision (on whether code will compile) based on the result of the conversion, the others only use it to know how to print information to the user.
So I think we're safe to say that the bulk of the code working with a `CodeExtent` is fine with local IDs.

r? @nikomatsakis
@bors
Copy link
Collaborator

bors commented Sep 1, 2017

⌛ Testing commit e4996ec with merge a59a6d8...

@bors
Copy link
Collaborator

bors commented Sep 1, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing a59a6d8 to master...

@bors bors merged commit e4996ec into rust-lang:master Sep 1, 2017
@eddyb eddyb deleted the scope branch September 1, 2017 17:42
@michaelwoerister
Copy link
Member

Nice, thanks a lot @eddyb!

bors added a commit that referenced this pull request Sep 5, 2017
Store fewer NodeIds in crate metadata.

The first commit just replaces `NodeId` with `DefId` in `resolve_lifetime::Region`, so we don't run into problems when stable-hashing `TypeParameterDef` values from other crates.

~~The second commit is more interesting. It adds the `ReScopeAnon` variant to `ty::RegionKind`, which is semantically equivalent to `ReScope`. The only difference is that it does not contain a `CodeExtent` field. All `ReScope` occurrences are then replaced with `ReScopeAnon` upon metadata export. This way we don't end up with `NodeIds` from other crates in various things imported from metadata. `ReScopeAnon` can still be tested for equality.~~ This is fixed in a better way by @eddyb in #44171.

r? @eddyb
cc @rust-lang/compiler
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants