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

Rollup of 7 pull requests #62119

Merged
merged 20 commits into from
Jun 25, 2019
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
30b6c59
Prefer to use `has_errors` to `err_count`
matthewjasper Jun 22, 2019
95a3215
Count all errors for `track_errors`
matthewjasper Jun 22, 2019
e1d871e
Remove built-in derive macros `Send` and `Sync`
petrochenkov Jun 23, 2019
a257dff
Add test for issue-38591
JohnTitor Jun 23, 2019
c7e1f4d
HIR: remove the NodeId get_parent_node, HirIdify is_argument
ljedrz Jun 24, 2019
d08bd72
HIR: rename get_parent_node_by_hir_id to get_parent_node
ljedrz Jun 24, 2019
90de9ed
HIR: remove the NodeId find
ljedrz Jun 24, 2019
f05cbc9
HIR: rename find_by_hir_id to find
ljedrz Jun 24, 2019
d82a12f
HirIdify driver::pretty::HirPrinterSupport::node_path
ljedrz Jun 24, 2019
87438a1
HirIdification: miscellaneous bits
ljedrz Jun 24, 2019
b7a0e40
Fix an ICE with uninhabited consts
varkor Jun 25, 2019
e6ee8a0
rustc: produce AST instead of HIR from `hir::lowering::Resolver` meth…
eddyb Jun 20, 2019
099f9e4
Implement From<Local> for Place and PlaceBase
spastorino Jun 24, 2019
d0e926f
Rollup merge of #61814 - varkor:uninhabited-const-61744, r=oli-obk
Centril Jun 25, 2019
81be122
Rollup merge of #61987 - eddyb:hirless-resolver, r=petrochenkov
Centril Jun 25, 2019
c5e6069
Rollup merge of #62055 - matthewjasper:fix-error-counting, r=pnkfelix
Centril Jun 25, 2019
61fae23
Rollup merge of #62078 - petrochenkov:nosendync2, r=varkor
Centril Jun 25, 2019
6070e2e
Rollup merge of #62085 - JohnTitor:add-test-for-issue-38591, r=Centril
Centril Jun 25, 2019
abc7423
Rollup merge of #62091 - ljedrz:hiridification_almost_there, r=Zoxc
Centril Jun 25, 2019
d406d89
Rollup merge of #62096 - spastorino:impl-place-from, r=oli-obk,Centril
Centril Jun 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
HIR: remove the NodeId get_parent_node, HirIdify is_argument
  • Loading branch information
ljedrz committed Jun 24, 2019
commit c7e1f4dcb78739fae7127c9d1ede182420f08a70
23 changes: 8 additions & 15 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
@@ -615,23 +615,16 @@ impl<'hir> Map<'hir> {
result
}

/// Similar to `get_parent`; returns the parent node-ID, or just `hir_id` if there
/// is no parent. Note that the parent may be `CRATE_NODE_ID`, which is not itself
/// Similar to `get_parent`; returns the parent HIR Id, or just `hir_id` if there
/// is no parent. Note that the parent may be `CRATE_HIR_ID`, which is not itself
/// present in the map, so passing the return value of `get_parent_node` to
/// `get` may in fact panic.
/// This function returns the immediate parent in the AST, whereas `get_parent`
/// This function returns the immediate parent in the HIR, whereas `get_parent`
/// returns the enclosing item. Note that this might not be the actual parent
/// node in the AST -- some kinds of nodes are not in the map and these will
/// node in the HIR -- some kinds of nodes are not in the map and these will
/// never appear as the parent node. Thus, you can always walk the parent nodes
/// from a node to the root of the AST (unless you get back the same ID here,
/// from a node to the root of the HIR (unless you get back the same ID here,
/// which can happen if the ID is not in the map itself or is just weird).
pub fn get_parent_node(&self, id: NodeId) -> NodeId {
let hir_id = self.node_to_hir_id(id);
let parent_hir_id = self.get_parent_node_by_hir_id(hir_id);
self.hir_to_node_id(parent_hir_id)
}

// FIXME(@ljedrz): replace the `NodeId` variant.
pub fn get_parent_node_by_hir_id(&self, hir_id: HirId) -> HirId {
if self.dep_graph.is_fully_enabled() {
let hir_id_owner = hir_id.owner;
@@ -646,12 +639,12 @@ impl<'hir> Map<'hir> {

/// Check if the node is an argument. An argument is a local variable whose
/// immediate parent is an item or a closure.
pub fn is_argument(&self, id: NodeId) -> bool {
match self.find(id) {
pub fn is_argument(&self, id: HirId) -> bool {
match self.find_by_hir_id(id) {
Some(Node::Binding(_)) => (),
_ => return false,
}
match self.find(self.get_parent_node(id)) {
match self.find_by_hir_id(self.get_parent_node_by_hir_id(id)) {
Some(Node::Item(_)) |
Some(Node::TraitItem(_)) |
Some(Node::ImplItem(_)) => true,
2 changes: 1 addition & 1 deletion src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
@@ -1526,7 +1526,7 @@ impl<'tcx> cmt_<'tcx> {
"non-place".into()
}
Categorization::Local(vid) => {
if tcx.hir().is_argument(tcx.hir().hir_to_node_id(vid)) {
if tcx.hir().is_argument(vid) {
"argument"
} else {
"local variable"
5 changes: 4 additions & 1 deletion src/librustc_save_analysis/lib.rs
Original file line number Diff line number Diff line change
@@ -621,7 +621,10 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
Node::PathSegment(seg) => {
match seg.res {
Some(res) if res != Res::Err => res,
_ => self.get_path_res(self.tcx.hir().get_parent_node(id)),
_ => {
let parent_node = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
self.get_path_res(self.tcx.hir().hir_to_node_id(parent_node))
},
}
}