Skip to content

Commit 37d7e1f

Browse files
committed
rename hir::map::local_def_id_from_hir_id to local_def_id
1 parent 4f7ba51 commit 37d7e1f

Some content is hidden

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

76 files changed

+252
-252
lines changed

src/librustc/hir/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl CheckAttrVisitor<'tcx> {
9595
/// Checks any attribute.
9696
fn check_attributes(&self, item: &hir::Item, target: Target) {
9797
if target == Target::Fn || target == Target::Const {
98-
self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id_from_hir_id(item.hir_id));
98+
self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id(item.hir_id));
9999
} else if let Some(a) = item.attrs.iter().find(|a| a.check_name(sym::target_feature)) {
100100
self.tcx.sess.struct_span_err(a.span, "attribute should be applied to a function")
101101
.span_label(item.span, "not a function")

src/librustc/hir/map/hir_id_validator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> {
8080
hir_id: HirId,
8181
walk: F) {
8282
assert!(self.owner_def_index.is_none());
83-
let owner_def_index = self.hir_map.local_def_id_from_hir_id(hir_id).index;
83+
let owner_def_index = self.hir_map.local_def_id(hir_id).index;
8484
self.owner_def_index = Some(owner_def_index);
8585
walk(self);
8686

src/librustc/hir/map/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ impl<'hir> Map<'hir> {
240240
}
241241

242242
#[inline]
243-
pub fn local_def_id_from_hir_id(&self, hir_id: HirId) -> DefId {
244-
self.opt_local_def_id_from_hir_id(hir_id).unwrap_or_else(|| {
245-
bug!("local_def_id_from_hir_id: no entry for `{:?}`, which has a map of `{:?}`",
243+
pub fn local_def_id(&self, hir_id: HirId) -> DefId {
244+
self.opt_local_def_id(hir_id).unwrap_or_else(|| {
245+
bug!("local_def_id: no entry for `{:?}`, which has a map of `{:?}`",
246246
hir_id, self.find_entry(hir_id))
247247
})
248248
}
@@ -427,7 +427,7 @@ impl<'hir> Map<'hir> {
427427
}
428428

429429
pub fn body_owner_def_id(&self, id: BodyId) -> DefId {
430-
self.local_def_id_from_hir_id(self.body_owner(id))
430+
self.local_def_id(self.body_owner(id))
431431
}
432432

433433
/// Given a `HirId`, returns the `BodyId` associated with it,
@@ -763,7 +763,7 @@ impl<'hir> Map<'hir> {
763763
/// Returns the `DefId` of `id`'s nearest module parent, or `id` itself if no
764764
/// module parent is in this map.
765765
pub fn get_module_parent(&self, id: HirId) -> DefId {
766-
self.local_def_id_from_hir_id(self.get_module_parent_node(id))
766+
self.local_def_id(self.get_module_parent_node(id))
767767
}
768768

769769
/// Returns the `HirId` of `id`'s nearest module parent, or `id` itself if no
@@ -839,7 +839,7 @@ impl<'hir> Map<'hir> {
839839
}
840840

841841
pub fn get_parent_did(&self, id: HirId) -> DefId {
842-
self.local_def_id_from_hir_id(self.get_parent_item(id))
842+
self.local_def_id(self.get_parent_item(id))
843843
}
844844

845845
pub fn get_foreign_abi(&self, hir_id: HirId) -> Abi {
@@ -1245,7 +1245,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
12451245
// the user-friendly path, otherwise fall back to stringifying DefPath.
12461246
crate::ty::tls::with_opt(|tcx| {
12471247
if let Some(tcx) = tcx {
1248-
let def_id = map.local_def_id_from_hir_id(id);
1248+
let def_id = map.local_def_id(id);
12491249
tcx.def_path_str(def_id)
12501250
} else if let Some(path) = map.def_path_from_hir_id(id) {
12511251
path.data.into_iter().map(|elem| {

src/librustc/hir/upvars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> {
8383

8484
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
8585
if let hir::ExprKind::Closure(..) = expr.node {
86-
let closure_def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
86+
let closure_def_id = self.tcx.hir().local_def_id(expr.hir_id);
8787
if let Some(upvars) = self.tcx.upvars(closure_def_id) {
8888
// Every capture of a closure expression is a local in scope,
8989
// that is moved/copied/borrowed into the closure value, and

src/librustc/infer/opaque_types/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,8 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
951951
let parent_def_id = self.parent_def_id;
952952
let def_scope_default = || {
953953
let opaque_parent_hir_id = tcx.hir().get_parent_item(opaque_hir_id);
954-
parent_def_id
955-
== tcx.hir().local_def_id_from_hir_id(opaque_parent_hir_id)
954+
parent_def_id == tcx.hir()
955+
.local_def_id(opaque_parent_hir_id)
956956
};
957957
let (in_definition_scope, origin) = match tcx.hir().find(opaque_hir_id) {
958958
Some(Node::Item(item)) => match item.node {

src/librustc/lint/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> LateContextAndPass<'a, 'tcx, T> {
926926
{
927927
let old_param_env = self.context.param_env;
928928
self.context.param_env = self.context.tcx.param_env(
929-
self.context.tcx.hir().local_def_id_from_hir_id(id)
929+
self.context.tcx.hir().local_def_id(id)
930930
);
931931
f(self);
932932
self.context.param_env = old_param_env;

src/librustc/middle/dead.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
161161
Node::Item(item) => {
162162
match item.node {
163163
hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => {
164-
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
164+
let def_id = self.tcx.hir().local_def_id(item.hir_id);
165165
let def = self.tcx.adt_def(def_id);
166166
self.repr_has_repr_c = def.repr.c();
167167

@@ -325,7 +325,7 @@ fn has_allow_dead_code_or_lang_attr(
325325
return true;
326326
}
327327

328-
let def_id = tcx.hir().local_def_id_from_hir_id(id);
328+
let def_id = tcx.hir().local_def_id(id);
329329
let cg_attrs = tcx.codegen_fn_attrs(def_id);
330330

331331
// #[used], #[no_mangle], #[export_name], etc also keeps the item alive
@@ -494,7 +494,7 @@ impl DeadVisitor<'tcx> {
494494
}
495495

496496
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
497-
let field_type = self.tcx.type_of(self.tcx.hir().local_def_id_from_hir_id(field.hir_id));
497+
let field_type = self.tcx.type_of(self.tcx.hir().local_def_id(field.hir_id));
498498
!field.is_positional()
499499
&& !self.symbol_is_live(field.hir_id)
500500
&& !field_type.is_phantom_data()
@@ -525,7 +525,7 @@ impl DeadVisitor<'tcx> {
525525
// This is done to handle the case where, for example, the static
526526
// method of a private type is used, but the type itself is never
527527
// called directly.
528-
let def_id = self.tcx.hir().local_def_id_from_hir_id(id);
528+
let def_id = self.tcx.hir().local_def_id(id);
529529
let inherent_impls = self.tcx.inherent_impls(def_id);
530530
for &impl_did in inherent_impls.iter() {
531531
for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] {

src/librustc/middle/entry.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct EntryContext<'a, 'tcx> {
3232

3333
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> {
3434
fn visit_item(&mut self, item: &'tcx Item) {
35-
let def_id = self.map.local_def_id_from_hir_id(item.hir_id);
35+
let def_id = self.map.local_def_id(item.hir_id);
3636
let def_key = self.map.def_key(def_id);
3737
let at_root = def_key.parent == Some(CRATE_DEF_INDEX);
3838
find_item(item, self, at_root);
@@ -142,11 +142,11 @@ fn find_item(item: &Item, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
142142

143143
fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) -> Option<(DefId, EntryFnType)> {
144144
if let Some((hir_id, _)) = visitor.start_fn {
145-
Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Start))
145+
Some((tcx.hir().local_def_id(hir_id), EntryFnType::Start))
146146
} else if let Some((hir_id, _)) = visitor.attr_main_fn {
147-
Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Main))
147+
Some((tcx.hir().local_def_id(hir_id), EntryFnType::Main))
148148
} else if let Some((hir_id, _)) = visitor.main_fn {
149-
Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Main))
149+
Some((tcx.hir().local_def_id(hir_id), EntryFnType::Main))
150150
} else {
151151
// No main function
152152
let mut err = struct_err!(tcx.sess, E0601,

src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
930930
fn walk_captures(&mut self, closure_expr: &hir::Expr, fn_decl_span: Span) {
931931
debug!("walk_captures({:?})", closure_expr);
932932

933-
let closure_def_id = self.tcx().hir().local_def_id_from_hir_id(closure_expr.hir_id);
933+
let closure_def_id = self.tcx().hir().local_def_id(closure_expr.hir_id);
934934
if let Some(upvars) = self.tcx().upvars(closure_def_id) {
935935
for (&var_id, upvar) in upvars.iter() {
936936
let upvar_id = ty::UpvarId {

src/librustc/middle/lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl ItemLikeVisitor<'v> for LanguageItemCollector<'tcx> {
118118
match self.item_refs.get(&*value.as_str()).cloned() {
119119
// Known lang item with attribute on correct target.
120120
Some((item_index, expected_target)) if actual_target == expected_target => {
121-
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
121+
let def_id = self.tcx.hir().local_def_id(item.hir_id);
122122
self.collect_item(item_index, def_id);
123123
},
124124
// Known lang item with attribute on incorrect target.

src/librustc/middle/liveness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ fn visit_fn<'tcx>(
363363
debug!("visit_fn");
364364

365365
// swap in a new set of IR maps for this function body:
366-
let def_id = ir.tcx.hir().local_def_id_from_hir_id(id);
366+
let def_id = ir.tcx.hir().local_def_id(id);
367367
let mut fn_maps = IrMaps::new(ir.tcx, def_id);
368368

369369
// Don't run unused pass for #[derive()]
@@ -494,7 +494,7 @@ fn visit_expr<'tcx>(ir: &mut IrMaps<'tcx>, expr: &'tcx Expr) {
494494
// in better error messages than just pointing at the closure
495495
// construction site.
496496
let mut call_caps = Vec::new();
497-
let closure_def_id = ir.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
497+
let closure_def_id = ir.tcx.hir().local_def_id(expr.hir_id);
498498
if let Some(upvars) = ir.tcx.upvars(closure_def_id) {
499499
let parent_upvars = ir.tcx.upvars(ir.body_owner);
500500
call_caps.extend(upvars.iter().filter_map(|(&var_id, upvar)| {

src/librustc/middle/reachable.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item, attrs: CodegenFnAt
3535
match item.node {
3636
hir::ItemKind::Impl(..) |
3737
hir::ItemKind::Fn(..) => {
38-
let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(item.hir_id));
38+
let generics = tcx.generics_of(tcx.hir().local_def_id(item.hir_id));
3939
generics.requires_monomorphization(tcx)
4040
}
4141
_ => false,
@@ -48,7 +48,7 @@ fn method_might_be_inlined(
4848
impl_src: DefId,
4949
) -> bool {
5050
let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id());
51-
let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(impl_item.hir_id));
51+
let generics = tcx.generics_of(tcx.hir().local_def_id(impl_item.hir_id));
5252
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
5353
return true
5454
}
@@ -222,7 +222,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
222222
} else {
223223
false
224224
};
225-
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
225+
let def_id = self.tcx.hir().local_def_id(item.hir_id);
226226
let codegen_attrs = self.tcx.codegen_fn_attrs(def_id);
227227
let is_extern = codegen_attrs.contains_extern_indicator();
228228
let std_internal = codegen_attrs.flags.contains(
@@ -243,7 +243,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
243243
Node::Item(item) => {
244244
match item.node {
245245
hir::ItemKind::Fn(.., body) => {
246-
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
246+
let def_id = self.tcx.hir().local_def_id(item.hir_id);
247247
if item_might_be_inlined(self.tcx,
248248
&item,
249249
self.tcx.codegen_fn_attrs(def_id)) {
@@ -345,7 +345,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx
345345
// Anything which has custom linkage gets thrown on the worklist no
346346
// matter where it is in the crate, along with "special std symbols"
347347
// which are currently akin to allocator symbols.
348-
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
348+
let def_id = self.tcx.hir().local_def_id(item.hir_id);
349349
let codegen_attrs = self.tcx.codegen_fn_attrs(def_id);
350350
if codegen_attrs.contains_extern_indicator() ||
351351
codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL) {

src/librustc/middle/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ impl<'tcx> ScopeTree {
675675
&format!("free_scope: {:?} not recognized by the \
676676
region scope tree for {:?} / {:?}",
677677
param_owner,
678-
self.root_parent.map(|id| tcx.hir().local_def_id_from_hir_id(id)),
678+
self.root_parent.map(|id| tcx.hir().local_def_id(id)),
679679
self.root_body.map(|hir_id| DefId::local(hir_id.owner))));
680680
}
681681

src/librustc/middle/resolve_lifetime.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ impl Region {
8383
fn early(hir_map: &Map<'_>, index: &mut u32, param: &GenericParam) -> (ParamName, Region) {
8484
let i = *index;
8585
*index += 1;
86-
let def_id = hir_map.local_def_id_from_hir_id(param.hir_id);
86+
let def_id = hir_map.local_def_id(param.hir_id);
8787
let origin = LifetimeDefOrigin::from_param(param);
8888
debug!("Region::early: index={} def_id={:?}", i, def_id);
8989
(param.name.modern(), Region::EarlyBound(i, def_id, origin))
9090
}
9191

9292
fn late(hir_map: &Map<'_>, param: &GenericParam) -> (ParamName, Region) {
9393
let depth = ty::INNERMOST;
94-
let def_id = hir_map.local_def_id_from_hir_id(param.hir_id);
94+
let def_id = hir_map.local_def_id(param.hir_id);
9595
let origin = LifetimeDefOrigin::from_param(param);
9696
debug!(
9797
"Region::late: param={:?} depth={:?} def_id={:?} origin={:?}",
@@ -1326,7 +1326,7 @@ fn object_lifetime_defaults_for_item(
13261326

13271327
add_bounds(&mut set, &param.bounds);
13281328

1329-
let param_def_id = tcx.hir().local_def_id_from_hir_id(param.hir_id);
1329+
let param_def_id = tcx.hir().local_def_id(param.hir_id);
13301330
for predicate in &generics.where_clause.predicates {
13311331
// Look for `type: ...` where clauses.
13321332
let data = match *predicate {
@@ -1370,7 +1370,7 @@ fn object_lifetime_defaults_for_item(
13701370
.enumerate()
13711371
.find(|&(_, (_, lt_name, _))| lt_name == name)
13721372
.map_or(Set1::Many, |(i, (id, _, origin))| {
1373-
let def_id = tcx.hir().local_def_id_from_hir_id(id);
1373+
let def_id = tcx.hir().local_def_id(id);
13741374
Set1::One(Region::EarlyBound(i as u32, def_id, origin))
13751375
})
13761376
}
@@ -1835,7 +1835,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
18351835
node: hir::ImplItemKind::Method(..),
18361836
..
18371837
}) => {
1838-
let scope = self.tcx.hir().local_def_id_from_hir_id(fn_id);
1838+
let scope = self.tcx.hir().local_def_id(fn_id);
18391839
def = Region::Free(scope, def.id().unwrap());
18401840
}
18411841
_ => {}

src/librustc/middle/stability.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
361361
}
362362

363363
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
364-
let impl_def_id = self.tcx.hir().local_def_id_from_hir_id(
364+
let impl_def_id = self.tcx.hir().local_def_id(
365365
self.tcx.hir().get_parent_item(ii.hir_id));
366366
if self.tcx.impl_trait_ref(impl_def_id).is_none() {
367367
self.check_missing_stability(ii.hir_id, ii.span, "item");
@@ -598,7 +598,7 @@ impl<'tcx> TyCtxt<'tcx> {
598598
// Deprecated attributes apply in-crate and cross-crate.
599599
if let Some(id) = id {
600600
if let Some(depr_entry) = self.lookup_deprecation_entry(def_id) {
601-
let parent_def_id = self.hir().local_def_id_from_hir_id(
601+
let parent_def_id = self.hir().local_def_id(
602602
self.hir().get_parent_item(id));
603603
let skip = self.lookup_deprecation_entry(parent_def_id)
604604
.map_or(false, |parent_depr| parent_depr.same_origin(&depr_entry));
@@ -766,7 +766,7 @@ impl Visitor<'tcx> for Checker<'tcx> {
766766
// compiler-generated `extern crate` items have a dummy span.
767767
if item.span.is_dummy() { return }
768768

769-
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
769+
let def_id = self.tcx.hir().local_def_id(item.hir_id);
770770
let cnum = match self.tcx.extern_mod_stmt_cnum(def_id) {
771771
Some(cnum) => cnum,
772772
None => return,
@@ -796,7 +796,7 @@ impl Visitor<'tcx> for Checker<'tcx> {
796796
// There's no good place to insert stability check for non-Copy unions,
797797
// so semi-randomly perform it here in stability.rs
798798
hir::ItemKind::Union(..) if !self.tcx.features().untagged_unions => {
799-
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
799+
let def_id = self.tcx.hir().local_def_id(item.hir_id);
800800
let adt_def = self.tcx.adt_def(def_id);
801801
let ty = self.tcx.type_of(def_id);
802802

src/librustc/mir/mono.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'tcx> MonoItem<'tcx> {
7979
tcx.symbol_name(Instance::mono(tcx, def_id))
8080
}
8181
MonoItem::GlobalAsm(hir_id) => {
82-
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
82+
let def_id = tcx.hir().local_def_id(hir_id);
8383
SymbolName {
8484
name: InternedString::intern(&format!("global_asm_{:?}", def_id))
8585
}

src/librustc/ty/inhabitedness/def_id_forest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl<'tcx> DefIdForest {
3333
/// crate.
3434
#[inline]
3535
pub fn full(tcx: TyCtxt<'tcx>) -> DefIdForest {
36-
let crate_id = tcx.hir().local_def_id_from_hir_id(CRATE_HIR_ID);
36+
let crate_id = tcx.hir().local_def_id(CRATE_HIR_ID);
3737
DefIdForest::from_id(crate_id)
3838
}
3939

0 commit comments

Comments
 (0)