Skip to content

Commit d996c4d

Browse files
committed
remove _by_hir_id if there is no NodeId counterpart
1 parent 61964d9 commit d996c4d

File tree

62 files changed

+164
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+164
-164
lines changed

src/librustc/cfg/construct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
358358
args: I) -> CFGIndex {
359359
let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
360360
let ret = self.straightline(call_expr, func_or_rcvr_exit, args);
361-
let m = self.tcx.hir().get_module_parent_by_hir_id(call_expr.hir_id);
361+
let m = self.tcx.hir().get_module_parent(call_expr.hir_id);
362362
if self.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(call_expr)) {
363363
self.add_unreachable_node()
364364
} else {

src/librustc/hir/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub trait Visitor<'v> : Sized {
171171
/// but cannot supply a `Map`; see `nested_visit_map` for advice.
172172
#[allow(unused_variables)]
173173
fn visit_nested_item(&mut self, id: ItemId) {
174-
let opt_item = self.nested_visit_map().inter().map(|map| map.expect_item_by_hir_id(id.id));
174+
let opt_item = self.nested_visit_map().inter().map(|map| map.expect_item(id.id));
175175
if let Some(item) = opt_item {
176176
self.visit_item(item);
177177
}

src/librustc/hir/map/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ impl<'hir> Map<'hir> {
435435

436436
/// Given a `HirId`, returns the `BodyId` associated with it,
437437
/// if the node is a body owner, otherwise returns `None`.
438-
pub fn maybe_body_owned_by_by_hir_id(&self, hir_id: HirId) -> Option<BodyId> {
438+
pub fn maybe_body_owned_by(&self, hir_id: HirId) -> Option<BodyId> {
439439
if let Some(entry) = self.find_entry(hir_id) {
440440
if self.dep_graph.is_fully_enabled() {
441441
let hir_id_owner = hir_id.owner;
@@ -451,13 +451,13 @@ impl<'hir> Map<'hir> {
451451

452452
/// Given a body owner's id, returns the `BodyId` associated with it.
453453
pub fn body_owned_by(&self, id: HirId) -> BodyId {
454-
self.maybe_body_owned_by_by_hir_id(id).unwrap_or_else(|| {
455-
span_bug!(self.span_by_hir_id(id), "body_owned_by: {} has no associated body",
454+
self.maybe_body_owned_by(id).unwrap_or_else(|| {
455+
span_bug!(self.span(id), "body_owned_by: {} has no associated body",
456456
self.hir_to_string(id));
457457
})
458458
}
459459

460-
pub fn body_owner_kind_by_hir_id(&self, id: HirId) -> BodyOwnerKind {
460+
pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind {
461461
match self.get_by_hir_id(id) {
462462
Node::Item(&Item { node: ItemKind::Const(..), .. }) |
463463
Node::TraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) |
@@ -548,7 +548,7 @@ impl<'hir> Map<'hir> {
548548
let module = &self.forest.krate.modules[&node_id];
549549

550550
for id in &module.items {
551-
visitor.visit_item(self.expect_item_by_hir_id(*id));
551+
visitor.visit_item(self.expect_item(*id));
552552
}
553553

554554
for id in &module.trait_items {
@@ -784,7 +784,7 @@ impl<'hir> Map<'hir> {
784784

785785
/// Returns the `DefId` of `id`'s nearest module parent, or `id` itself if no
786786
/// module parent is in this map.
787-
pub fn get_module_parent_by_hir_id(&self, id: HirId) -> DefId {
787+
pub fn get_module_parent(&self, id: HirId) -> DefId {
788788
self.local_def_id_from_hir_id(self.get_module_parent_node(id))
789789
}
790790

@@ -860,11 +860,11 @@ impl<'hir> Map<'hir> {
860860
Some(scope)
861861
}
862862

863-
pub fn get_parent_did_by_hir_id(&self, id: HirId) -> DefId {
863+
pub fn get_parent_did(&self, id: HirId) -> DefId {
864864
self.local_def_id_from_hir_id(self.get_parent_item(id))
865865
}
866866

867-
pub fn get_foreign_abi_by_hir_id(&self, hir_id: HirId) -> Abi {
867+
pub fn get_foreign_abi(&self, hir_id: HirId) -> Abi {
868868
let parent = self.get_parent_item(hir_id);
869869
if let Some(entry) = self.find_entry(parent) {
870870
if let Entry {
@@ -877,7 +877,7 @@ impl<'hir> Map<'hir> {
877877
bug!("expected foreign mod or inlined parent, found {}", self.hir_to_string(parent))
878878
}
879879

880-
pub fn expect_item_by_hir_id(&self, id: HirId) -> &'hir Item {
880+
pub fn expect_item(&self, id: HirId) -> &'hir Item {
881881
match self.find_by_hir_id(id) { // read recorded by `find`
882882
Some(Node::Item(item)) => item,
883883
_ => bug!("expected item, found {}", self.hir_to_string(id))
@@ -965,7 +965,7 @@ impl<'hir> Map<'hir> {
965965

966966
/// Given a node ID, gets a list of attributes associated with the AST
967967
/// corresponding to the node-ID.
968-
pub fn attrs_by_hir_id(&self, id: HirId) -> &'hir [ast::Attribute] {
968+
pub fn attrs(&self, id: HirId) -> &'hir [ast::Attribute] {
969969
self.read(id); // reveals attributes on the node
970970
let attrs = match self.find_entry(id).map(|entry| entry.node) {
971971
Some(Node::Local(l)) => Some(&l.attrs[..]),
@@ -981,7 +981,7 @@ impl<'hir> Map<'hir> {
981981
Some(Node::GenericParam(param)) => Some(&param.attrs[..]),
982982
// Unit/tuple structs/variants take the attributes straight from
983983
// the struct/variant definition.
984-
Some(Node::Ctor(..)) => return self.attrs_by_hir_id(self.get_parent_item(id)),
984+
Some(Node::Ctor(..)) => return self.attrs(self.get_parent_item(id)),
985985
Some(Node::Crate) => Some(&self.forest.krate.attrs[..]),
986986
_ => None
987987
};
@@ -1028,7 +1028,7 @@ impl<'hir> Map<'hir> {
10281028
})
10291029
}
10301030

1031-
pub fn span_by_hir_id(&self, hir_id: HirId) -> Span {
1031+
pub fn span(&self, hir_id: HirId) -> Span {
10321032
self.read(hir_id); // reveals span from node
10331033
match self.find_entry(hir_id).map(|entry| entry.node) {
10341034
Some(Node::Item(item)) => item.span,
@@ -1068,7 +1068,7 @@ impl<'hir> Map<'hir> {
10681068
}
10691069

10701070
pub fn span_if_local(&self, id: DefId) -> Option<Span> {
1071-
self.as_local_hir_id(id).map(|id| self.span_by_hir_id(id))
1071+
self.as_local_hir_id(id).map(|id| self.span(id))
10721072
}
10731073

10741074
pub fn hir_to_string(&self, id: HirId) -> String {
@@ -1221,7 +1221,7 @@ pub fn map_crate<'hir>(sess: &crate::session::Session,
12211221
impl<'hir> print::PpAnn for Map<'hir> {
12221222
fn nested(&self, state: &mut print::State<'_>, nested: print::Nested) -> io::Result<()> {
12231223
match nested {
1224-
Nested::Item(id) => state.print_item(self.expect_item_by_hir_id(id.id)),
1224+
Nested::Item(id) => state.print_item(self.expect_item(id.id)),
12251225
Nested::TraitItem(id) => state.print_trait_item(self.trait_item(id)),
12261226
Nested::ImplItem(id) => state.print_impl_item(self.impl_item(id)),
12271227
Nested::Body(id) => state.print_expr(&self.body(id).value),

src/librustc/hir/upvars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn provide(providers: &mut Providers<'_>) {
1515
}
1616

1717
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
18-
let body = tcx.hir().body(tcx.hir().maybe_body_owned_by_by_hir_id(hir_id)?);
18+
let body = tcx.hir().body(tcx.hir().maybe_body_owned_by(hir_id)?);
1919

2020
let mut local_collector = LocalCollector::default();
2121
local_collector.visit_body(body);

src/librustc/infer/error_reporting/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl<'tcx> TyCtxt<'tcx> {
191191
};
192192
let (prefix, span) = match *region {
193193
ty::ReEarlyBound(ref br) => {
194-
let mut sp = cm.def_span(self.hir().span_by_hir_id(node));
194+
let mut sp = cm.def_span(self.hir().span(node));
195195
if let Some(param) = self.hir()
196196
.get_generics(scope)
197197
.and_then(|generics| generics.get_named(br.name))
@@ -204,7 +204,7 @@ impl<'tcx> TyCtxt<'tcx> {
204204
bound_region: ty::BoundRegion::BrNamed(_, name),
205205
..
206206
}) => {
207-
let mut sp = cm.def_span(self.hir().span_by_hir_id(node));
207+
let mut sp = cm.def_span(self.hir().span(node));
208208
if let Some(param) = self.hir()
209209
.get_generics(scope)
210210
.and_then(|generics| generics.get_named(name))
@@ -216,11 +216,11 @@ impl<'tcx> TyCtxt<'tcx> {
216216
ty::ReFree(ref fr) => match fr.bound_region {
217217
ty::BrAnon(idx) => (
218218
format!("the anonymous lifetime #{} defined on", idx + 1),
219-
self.hir().span_by_hir_id(node),
219+
self.hir().span(node),
220220
),
221221
_ => (
222222
format!("the lifetime {} as defined on", region),
223-
cm.def_span(self.hir().span_by_hir_id(node)),
223+
cm.def_span(self.hir().span(node)),
224224
),
225225
},
226226
_ => bug!(),
@@ -1338,7 +1338,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13381338
if let Node::GenericParam(ref param) = hir.get_by_hir_id(id) {
13391339
has_bounds = !param.bounds.is_empty();
13401340
}
1341-
let sp = hir.span_by_hir_id(id);
1341+
let sp = hir.span(id);
13421342
// `sp` only covers `T`, change it so that it covers
13431343
// `T:` when appropriate
13441344
let is_impl_trait = bound_kind.to_string().starts_with("impl ");

src/librustc/infer/error_reporting/nice_region_error/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
5252

5353
let hir = &self.tcx().hir();
5454
if let Some(hir_id) = hir.as_local_hir_id(id) {
55-
if let Some(body_id) = hir.maybe_body_owned_by_by_hir_id(hir_id) {
55+
if let Some(body_id) = hir.maybe_body_owned_by(hir_id) {
5656
let body = hir.body(body_id);
5757
let owner_id = hir.body_owner(body_id);
5858
let fn_decl = hir.fn_decl_by_hir_id(owner_id).unwrap();
@@ -63,7 +63,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
6363
.filter_map(|(index, arg)| {
6464
// May return None; sometimes the tables are not yet populated.
6565
let ty_hir_id = fn_decl.inputs[index].hir_id;
66-
let arg_ty_span = hir.span_by_hir_id(ty_hir_id);
66+
let arg_ty_span = hir.span(ty_hir_id);
6767
let ty = tables.node_type_opt(arg.hir_id)?;
6868
let mut found_anon_region = false;
6969
let new_arg_ty = self.tcx().fold_regions(&ty, &mut false, |r, _| {

src/librustc/lint/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ fn late_lint_mod_pass<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
13991399

14001400
// Visit the crate attributes
14011401
if hir_id == hir::CRATE_HIR_ID {
1402-
walk_list!(cx, visit_attribute, tcx.hir().attrs_by_hir_id(hir::CRATE_HIR_ID));
1402+
walk_list!(cx, visit_attribute, tcx.hir().attrs(hir::CRATE_HIR_ID));
14031403
}
14041404
}
14051405

src/librustc/lint/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
762762
}
763763

764764
pub fn maybe_lint_level_root(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
765-
let attrs = tcx.hir().attrs_by_hir_id(id);
765+
let attrs = tcx.hir().attrs(id);
766766
attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some())
767767
}
768768

src/librustc/middle/dead.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
292292
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
293293
match ty.node {
294294
TyKind::Def(item_id, _) => {
295-
let item = self.tcx.hir().expect_item_by_hir_id(item_id.id);
295+
let item = self.tcx.hir().expect_item(item_id.id);
296296
intravisit::walk_item(self, item);
297297
}
298298
_ => ()

src/librustc/middle/liveness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11711171
}
11721172

11731173
hir::ExprKind::Call(ref f, ref args) => {
1174-
let m = self.ir.tcx.hir().get_module_parent_by_hir_id(expr.hir_id);
1174+
let m = self.ir.tcx.hir().get_module_parent(expr.hir_id);
11751175
let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
11761176
self.s.exit_ln
11771177
} else {
@@ -1182,7 +1182,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11821182
}
11831183

11841184
hir::ExprKind::MethodCall(.., ref args) => {
1185-
let m = self.ir.tcx.hir().get_module_parent_by_hir_id(expr.hir_id);
1185+
let m = self.ir.tcx.hir().get_module_parent(expr.hir_id);
11861186
let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
11871187
self.s.exit_ln
11881188
} else {

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl MutabilityCategory {
358358
}
359359
_ => span_bug!(p.span, "expected identifier pattern")
360360
},
361-
_ => span_bug!(tcx.hir().span_by_hir_id(id), "expected identifier pattern")
361+
_ => span_bug!(tcx.hir().span(id), "expected identifier pattern")
362362
};
363363
debug!("MutabilityCategory::{}(tcx, id={:?}) => {:?}",
364364
"from_local", id, ret);

src/librustc/middle/reachable.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
174174
} else {
175175
let impl_did = self.tcx
176176
.hir()
177-
.get_parent_did_by_hir_id(hir_id);
177+
.get_parent_did(hir_id);
178178
// Check the impl. If the generics on the self
179179
// type of the impl require inlining, this method
180180
// does too.
181181
let impl_hir_id = self.tcx.hir().as_local_hir_id(impl_did).unwrap();
182-
match self.tcx.hir().expect_item_by_hir_id(impl_hir_id).node {
182+
match self.tcx.hir().expect_item(impl_hir_id).node {
183183
hir::ItemKind::Impl(..) => {
184184
let generics = self.tcx.generics_of(impl_did);
185185
generics.requires_monomorphization(self.tcx)
@@ -296,7 +296,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
296296
self.visit_nested_body(body);
297297
}
298298
hir::ImplItemKind::Method(_, body) => {
299-
let did = self.tcx.hir().get_parent_did_by_hir_id(search_item);
299+
let did = self.tcx.hir().get_parent_did(search_item);
300300
if method_might_be_inlined(self.tcx, impl_item, did) {
301301
self.visit_nested_body(body)
302302
}

src/librustc/middle/region.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl Scope {
188188
if hir_id == hir::DUMMY_HIR_ID {
189189
return DUMMY_SP;
190190
}
191-
let span = tcx.hir().span_by_hir_id(hir_id);
191+
let span = tcx.hir().span(hir_id);
192192
if let ScopeData::Remainder(first_statement_index) = self.data {
193193
if let Node::Block(ref blk) = tcx.hir().get_by_hir_id(hir_id) {
194194
// Want span for scope starting after the
@@ -649,7 +649,7 @@ impl<'tcx> ScopeTree {
649649
let param_owner = tcx.parent(br.def_id).unwrap();
650650

651651
let param_owner_id = tcx.hir().as_local_hir_id(param_owner).unwrap();
652-
let scope = tcx.hir().maybe_body_owned_by_by_hir_id(param_owner_id).map(|body_id| {
652+
let scope = tcx.hir().maybe_body_owned_by(param_owner_id).map(|body_id| {
653653
tcx.hir().body(body_id).value.hir_id.local_id
654654
}).unwrap_or_else(|| {
655655
// The lifetime was defined on node that doesn't own a body,
@@ -1277,7 +1277,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
12771277

12781278
// The body of the every fn is a root scope.
12791279
self.cx.parent = self.cx.var_parent;
1280-
if self.tcx.hir().body_owner_kind_by_hir_id(owner_id).is_fn_or_closure() {
1280+
if self.tcx.hir().body_owner_kind(owner_id).is_fn_or_closure() {
12811281
self.visit_expr(&body.value)
12821282
} else {
12831283
// Only functions have an outer terminating (drop) scope, while
@@ -1336,7 +1336,7 @@ fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ScopeTree
13361336
}
13371337

13381338
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
1339-
let scope_tree = if let Some(body_id) = tcx.hir().maybe_body_owned_by_by_hir_id(id) {
1339+
let scope_tree = if let Some(body_id) = tcx.hir().maybe_body_owned_by(id) {
13401340
let mut visitor = RegionResolutionVisitor {
13411341
tcx,
13421342
scope_tree: ScopeTree::default(),

src/librustc/middle/resolve_lifetime.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
625625
// `abstract type MyAnonTy<'b>: MyTrait<'b>;`
626626
// ^ ^ this gets resolved in the scope of
627627
// the exist_ty generics
628-
let (generics, bounds) = match self.tcx.hir().expect_item_by_hir_id(item_id.id).node
628+
let (generics, bounds) = match self.tcx.hir().expect_item(item_id.id).node
629629
{
630630
// named existential types are reached via TyKind::Path
631631
// this arm is for `impl Trait` in the types of statics, constants and locals
@@ -1236,7 +1236,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
12361236
signal_shadowing_problem(
12371237
tcx,
12381238
label.name,
1239-
original_lifetime(tcx.hir().span_by_hir_id(hir_id)),
1239+
original_lifetime(tcx.hir().span(hir_id)),
12401240
shadower_label(label.span),
12411241
);
12421242
return;
@@ -1590,7 +1590,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
15901590
if let Some(parent_hir_id) = self.tcx.hir()
15911591
.as_local_hir_id(parent_def_id) {
15921592
// lifetimes in `derive` expansions don't count (Issue #53738)
1593-
if self.tcx.hir().attrs_by_hir_id(parent_hir_id).iter()
1593+
if self.tcx.hir().attrs(parent_hir_id).iter()
15941594
.any(|attr| attr.check_name(sym::automatically_derived)) {
15951595
continue;
15961596
}
@@ -1690,7 +1690,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
16901690
// Find the start of nested early scopes, e.g., in methods.
16911691
let mut index = 0;
16921692
if let Some(parent_id) = parent_id {
1693-
let parent = self.tcx.hir().expect_item_by_hir_id(parent_id);
1693+
let parent = self.tcx.hir().expect_item(parent_id);
16941694
if sub_items_have_self_param(&parent.node) {
16951695
index += 1; // Self comes before lifetimes
16961696
}
@@ -2065,7 +2065,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
20652065
}) => {
20662066
if let hir::ItemKind::Trait(.., ref trait_items) = self.tcx
20672067
.hir()
2068-
.expect_item_by_hir_id(self.tcx.hir().get_parent_item(parent))
2068+
.expect_item(self.tcx.hir().get_parent_item(parent))
20692069
.node
20702070
{
20712071
assoc_item_kind = trait_items
@@ -2085,7 +2085,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
20852085
}) => {
20862086
if let hir::ItemKind::Impl(.., ref self_ty, ref impl_items) = self.tcx
20872087
.hir()
2088-
.expect_item_by_hir_id(self.tcx.hir().get_parent_item(parent))
2088+
.expect_item(self.tcx.hir().get_parent_item(parent))
20892089
.node
20902090
{
20912091
impl_self = Some(self_ty);
@@ -2629,7 +2629,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
26292629
signal_shadowing_problem(
26302630
self.tcx,
26312631
param.name.ident().name,
2632-
original_lifetime(self.tcx.hir().span_by_hir_id(hir_id)),
2632+
original_lifetime(self.tcx.hir().span(hir_id)),
26332633
shadower_lifetime(&param),
26342634
);
26352635
return;

0 commit comments

Comments
 (0)