Uh oh!
There was an error while loading. Please reload this page.
operate on HirId instead of NodeId in hir::Pat::each_binding, and consequences of that - #50929
Conversation
There was a problem hiding this comment.
You can use self.mc.tcx.hir.hir_to_node_id() which is "just" a hash table lookup. find_node_for_hir_id() should actually be removed.
There was a problem hiding this comment.
You could change nid to HirId too, I think.
There was a problem hiding this comment.
This doesn't feel like an organic part of this somewhat-narrowly-focused cleanup PR to me (value called as nid is ultimately coming out of a Def::Local(NodeId) variant, in contrast to hir::Pat already having a hir_id field)?
There was a problem hiding this comment.
Same as above: self.hir.hir_to_node_id() will make it fast.
michaelwoerister
commented
May 21, 2018
Thanks for the PR, @zackmdavis!
Mostly yes, I think. I know that @eddyb wants to get rid of
There's a better alternative (which has been introduced later). See my comments in the code.
I think the names are fine. |
9ee1803 to
6dd885eComparezackmdavis
commented
May 27, 2018
@michaelwoerister (rebased, with a new commit using |
michaelwoerister
commented
May 28, 2018
Thanks, @zackmdavis! @bors r+ |
bors
commented
May 28, 2018
📌 Commit 6dd885e has been approved by |
bors
commented
May 28, 2018
☔ The latest upstream changes (presumably #50724) made this pull request unmergeable. Please resolve the merge conflicts. |
Changing the `each_binding` utility method to take the `HirId` of a binding pattern rather than its `NodeId` seems like a modest first step in support of the `HirId`ification initiative rust-lang#50928. (The inspiration for choosing this in particular came from the present author's previous work on diagnostics issued during liveness analysis, which is the most greatly affected module in this change.)
Michael Woerister pointed out that `hir_to_node_id` (introduced in August 2017's 28ddd7a) supersedes the functionality of `find_node_for_hir_id` (just a hash lookup compared to that linear search).
6dd885e to
1b7488dComparezackmdavis
commented
May 28, 2018
@michaelwoerister (rebased to fix conflict ↑) |
michaelwoerister
commented
May 28, 2018
Thanks! @bors r+ |
bors
commented
May 28, 2018
📌 Commit 1b7488d has been approved by |
bors
commented
May 28, 2018
…lwoerister operate on `HirId` instead of `NodeId` in `hir::Pat::each_binding`, and consequences of that See #50928 for motivation. Questions— * Is #50928 actually a good idea as a plan of record, or is there some reason to keep `NodeId`s? * Are the uses of `find_node_for_hir_id` in this initial submission OK (see the FIXME comments)? * Can we bikeshed a better method names `struct_span_lint_hir` _&c._? (Coined in analogy to the `struct_span_lint_node` and `NodeId`, but it feels kind of semantically clunky.) r? @michaelwoerister
bors
commented
May 28, 2018
☀️ Test successful - status-appveyor, status-travis |
HirId-ification, continued Another incremental step towards the vision of #50928 (previously: #50929). r? @michaelwoerister
See #50928 for motivation.
Questions—
HirId-ification initiative #50928 actually a good idea as a plan of record, or is there some reason to keepNodeIds?find_node_for_hir_idin this initial submission OK (see the FIXME comments)?struct_span_lint_hir&c.? (Coined in analogy to thestruct_span_lint_nodeandNodeId, but it feels kind of semantically clunky.)r? @michaelwoerister