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.

0 commit comments

Comments
 (0)