Skip to content

Commit 4f7ba51

Browse files
committed
rename hir::map::local_def_id to local_def_id_from_node_id
1 parent 7987719 commit 4f7ba51

File tree

13 files changed

+48
-45
lines changed

13 files changed

+48
-45
lines changed

src/librustc/dep_graph/dep_tracking_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<M: DepTrackingMapConfig> MemoizationMap for RefCell<DepTrackingMap<M>> {
5555
///
5656
/// ```
5757
/// fn type_of_item(..., item: &hir::Item) -> Ty<'tcx> {
58-
/// let item_def_id = ccx.tcx.hir().local_def_id(it.id);
58+
/// let item_def_id = ccx.tcx.hir().local_def_id_from_node_id(it.id);
5959
/// ccx.tcx.item_types.memoized(item_def_id, || {
6060
/// ccx.tcx.dep_graph.read(DepNode::Hir(item_def_id)); // (*)
6161
/// compute_type_of_item(ccx, item)

src/librustc/hir/map/hir_id_validator.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ pub fn check_crate(hir_map: &hir::map::Map<'_>) {
1010
let errors = Lock::new(Vec::new());
1111

1212
par_iter(&hir_map.krate().modules).for_each(|(module_id, _)| {
13-
hir_map.visit_item_likes_in_module(hir_map.local_def_id(*module_id), &mut OuterVisitor {
13+
let local_def_id = hir_map.local_def_id_from_node_id(*module_id);
14+
hir_map.visit_item_likes_in_module(local_def_id, &mut OuterVisitor {
1415
hir_map,
1516
errors: &errors,
1617
});

src/librustc/hir/map/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ impl<'hir> Map<'hir> {
231231
}
232232

233233
#[inline]
234-
pub fn local_def_id(&self, node: NodeId) -> DefId {
234+
pub fn local_def_id_from_node_id(&self, node: NodeId) -> DefId {
235235
self.opt_local_def_id(node).unwrap_or_else(|| {
236236
let hir_id = self.node_to_hir_id(node);
237-
bug!("local_def_id: no entry for `{}`, which has a map of `{:?}`",
237+
bug!("local_def_id_from_node_id: no entry for `{}`, which has a map of `{:?}`",
238238
node, self.find_entry(hir_id))
239239
})
240240
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
140140
// region at the right depth with the same index
141141
(Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => {
142142
debug!(
143-
"EarlyBound self.infcx.tcx.hir().local_def_id(id)={:?} \
143+
"EarlyBound self.infcx.tcx.hir().local_def_id_from_node_id(id)={:?} \
144144
def_id={:?}",
145145
id,
146146
def_id
@@ -162,7 +162,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
162162
"FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}",
163163
debruijn_index
164164
);
165-
debug!("self.infcx.tcx.hir().local_def_id(id)={:?}", id);
165+
debug!("self.infcx.tcx.hir().local_def_id_from_node_id(id)={:?}", id);
166166
debug!("def_id={:?}", def_id);
167167
if debruijn_index == self.current_index && id == def_id {
168168
self.found_type = Some(arg);
@@ -232,7 +232,7 @@ impl Visitor<'tcx> for TyPathVisitor<'tcx> {
232232

233233
(Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => {
234234
debug!(
235-
"EarlyBound self.infcx.tcx.hir().local_def_id(id)={:?} \
235+
"EarlyBound self.infcx.tcx.hir().local_def_id_from_node_id(id)={:?} \
236236
def_id={:?}",
237237
id,
238238
def_id

src/librustc/lint/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ pub fn check_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
15001500
time(tcx.sess, "module lints", || {
15011501
// Run per-module lints
15021502
par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| {
1503-
tcx.ensure().lint_mod(tcx.hir().local_def_id(module));
1503+
tcx.ensure().lint_mod(tcx.hir().local_def_id_from_node_id(module));
15041504
});
15051505
});
15061506
});

src/librustc/ty/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,15 +1304,15 @@ impl<'tcx> TyCtxt<'tcx> {
13041304
maybe_unused_trait_imports:
13051305
resolutions.maybe_unused_trait_imports
13061306
.into_iter()
1307-
.map(|id| hir.local_def_id(id))
1307+
.map(|id| hir.local_def_id_from_node_id(id))
13081308
.collect(),
13091309
maybe_unused_extern_crates:
13101310
resolutions.maybe_unused_extern_crates
13111311
.into_iter()
1312-
.map(|(id, sp)| (hir.local_def_id(id), sp))
1312+
.map(|(id, sp)| (hir.local_def_id_from_node_id(id), sp))
13131313
.collect(),
13141314
glob_map: resolutions.glob_map.into_iter().map(|(id, names)| {
1315-
(hir.local_def_id(id), names)
1315+
(hir.local_def_id_from_node_id(id), names)
13161316
}).collect(),
13171317
extern_prelude: resolutions.extern_prelude,
13181318
hir_map: hir,

src/librustc_driver/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ fn print_with_analysis(
887887
let mut print = || match ppm {
888888
PpmMir | PpmMirCFG => {
889889
if let Some(nodeid) = nodeid {
890-
let def_id = tcx.hir().local_def_id(nodeid);
890+
let def_id = tcx.hir().local_def_id_from_node_id(nodeid);
891891
match ppm {
892892
PpmMir => write_mir_pretty(tcx, Some(def_id), &mut out),
893893
PpmMirCFG => write_mir_graphviz(tcx, Some(def_id), &mut out),

src/librustc_interface/passes.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -899,9 +899,10 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
899899
});
900900
}, {
901901
par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| {
902-
tcx.ensure().check_mod_loops(tcx.hir().local_def_id(module));
903-
tcx.ensure().check_mod_attrs(tcx.hir().local_def_id(module));
904-
tcx.ensure().check_mod_unstable_api_usage(tcx.hir().local_def_id(module));
902+
tcx.ensure().check_mod_loops(tcx.hir().local_def_id_from_node_id(module));
903+
tcx.ensure().check_mod_attrs(tcx.hir().local_def_id_from_node_id(module));
904+
tcx.ensure().check_mod_unstable_api_usage(
905+
tcx.hir().local_def_id_from_node_id(module));
905906
});
906907
});
907908
});
@@ -924,9 +925,9 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
924925
// "not all control paths return a value" is reported here.
925926
//
926927
// maybe move the check to a MIR pass?
927-
tcx.ensure().check_mod_liveness(tcx.hir().local_def_id(module));
928+
tcx.ensure().check_mod_liveness(tcx.hir().local_def_id_from_node_id(module));
928929

929-
tcx.ensure().check_mod_intrinsics(tcx.hir().local_def_id(module));
930+
tcx.ensure().check_mod_intrinsics(tcx.hir().local_def_id_from_node_id(module));
930931
});
931932
});
932933
});
@@ -986,7 +987,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
986987
}, {
987988
time(sess, "privacy checking modules", || {
988989
par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| {
989-
tcx.ensure().check_mod_privacy(tcx.hir().local_def_id(module));
990+
tcx.ensure().check_mod_privacy(tcx.hir().local_def_id_from_node_id(module));
990991
});
991992
});
992993
});

src/librustc_save_analysis/dump_visitor.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
123123
where
124124
F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, O>),
125125
{
126-
let item_def_id = self.tcx.hir().local_def_id(item_id);
126+
let item_def_id = self.tcx.hir().local_def_id_from_node_id(item_id);
127127
if self.tcx.has_typeck_tables(item_def_id) {
128128
let tables = self.tcx.typeck_tables_of(item_def_id);
129129
let old_tables = self.save_ctxt.tables;
@@ -436,7 +436,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
436436
attrs: &'l [Attribute],
437437
) {
438438
let qualname = format!("::{}",
439-
self.tcx.def_path_str(self.tcx.hir().local_def_id(id)));
439+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(id)));
440440

441441
if !self.span.filter_generated(ident.span) {
442442
let sig = sig::assoc_const_signature(id, ident.name, typ, expr, &self.save_ctxt);
@@ -481,7 +481,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
481481
debug!("process_struct {:?} {:?}", item, item.span);
482482
let name = item.ident.to_string();
483483
let qualname = format!("::{}",
484-
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
484+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
485485

486486
let kind = match item.node {
487487
ast::ItemKind::Struct(_, _) => DefKind::Struct,
@@ -683,7 +683,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
683683
self.process_generic_params(generics, "", item.id);
684684
for impl_item in impl_items {
685685
let map = &self.tcx.hir();
686-
self.process_impl_item(impl_item, map.local_def_id(item.id));
686+
self.process_impl_item(impl_item, map.local_def_id_from_node_id(item.id));
687687
}
688688
}
689689

@@ -696,7 +696,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
696696
) {
697697
let name = item.ident.to_string();
698698
let qualname = format!("::{}",
699-
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
699+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
700700
let mut val = name.clone();
701701
if !generics.params.is_empty() {
702702
val.push_str(&generic_params_to_string(&generics.params));
@@ -764,7 +764,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
764764
self.process_generic_params(generics, &qualname, item.id);
765765
for method in methods {
766766
let map = &self.tcx.hir();
767-
self.process_trait_item(method, map.local_def_id(item.id))
767+
self.process_trait_item(method, map.local_def_id_from_node_id(item.id))
768768
}
769769
}
770770

@@ -1109,7 +1109,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
11091109
// FIXME do something with _bounds (for type refs)
11101110
let name = trait_item.ident.name.to_string();
11111111
let qualname = format!("::{}",
1112-
self.tcx.def_path_str(self.tcx.hir().local_def_id(trait_item.id)));
1112+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(trait_item.id)));
11131113

11141114
if !self.span.filter_generated(trait_item.ident.span) {
11151115
let span = self.span_from_span(trait_item.ident.span);
@@ -1261,7 +1261,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
12611261
};
12621262

12631263
// Make a comma-separated list of names of imported modules.
1264-
let def_id = self.tcx.hir().local_def_id(id);
1264+
let def_id = self.tcx.hir().local_def_id_from_node_id(id);
12651265
let names = self.tcx.names_imported_by_glob_use(def_id);
12661266
let names: Vec<_> = names.iter().map(|n| n.to_string()).collect();
12671267

@@ -1318,7 +1318,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
13181318
assert_eq!(id, ast::CRATE_NODE_ID);
13191319

13201320
let qualname = format!("::{}",
1321-
self.tcx.def_path_str(self.tcx.hir().local_def_id(id)));
1321+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(id)));
13221322

13231323
let cm = self.tcx.sess.source_map();
13241324
let filename = cm.span_to_filename(span);
@@ -1408,7 +1408,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
14081408
}
14091409
Ty(ref ty, ref ty_params) => {
14101410
let qualname = format!("::{}",
1411-
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
1411+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
14121412
let value = ty_to_string(&ty);
14131413
if !self.span.filter_generated(item.ident.span) {
14141414
let span = self.span_from_span(item.ident.span);
@@ -1439,7 +1439,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
14391439
}
14401440
Existential(ref _bounds, ref ty_params) => {
14411441
let qualname = format!("::{}",
1442-
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
1442+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
14431443
// FIXME do something with _bounds
14441444
let value = String::new();
14451445
if !self.span.filter_generated(item.ident.span) {

src/librustc_save_analysis/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
135135

136136
pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option<Data> {
137137
let qualname = format!("::{}",
138-
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
138+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
139139
match item.node {
140140
ast::ForeignItemKind::Fn(ref decl, ref generics) => {
141141
filter!(self.span_utils, item.ident.span);
@@ -186,7 +186,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
186186
match item.node {
187187
ast::ItemKind::Fn(ref decl, .., ref generics, _) => {
188188
let qualname = format!("::{}",
189-
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
189+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
190190
filter!(self.span_utils, item.ident.span);
191191
Some(Data::DefData(Def {
192192
kind: DefKind::Function,
@@ -205,7 +205,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
205205
}
206206
ast::ItemKind::Static(ref typ, ..) => {
207207
let qualname = format!("::{}",
208-
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
208+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
209209

210210
filter!(self.span_utils, item.ident.span);
211211

@@ -229,7 +229,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
229229
}
230230
ast::ItemKind::Const(ref typ, _) => {
231231
let qualname = format!("::{}",
232-
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
232+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
233233
filter!(self.span_utils, item.ident.span);
234234

235235
let id = id_from_node_id(item.id, self);
@@ -252,7 +252,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
252252
}
253253
ast::ItemKind::Mod(ref m) => {
254254
let qualname = format!("::{}",
255-
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
255+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
256256

257257
let cm = self.tcx.sess.source_map();
258258
let filename = cm.span_to_filename(m.inner);
@@ -280,7 +280,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
280280
ast::ItemKind::Enum(ref def, _) => {
281281
let name = item.ident.to_string();
282282
let qualname = format!("::{}",
283-
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
283+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
284284
filter!(self.span_utils, item.ident.span);
285285
let variants_str = def.variants
286286
.iter()
@@ -365,10 +365,10 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
365365
if let Some(ident) = field.ident {
366366
let name = ident.to_string();
367367
let qualname = format!("::{}::{}",
368-
self.tcx.def_path_str(self.tcx.hir().local_def_id(scope)),
368+
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(scope)),
369369
ident);
370370
filter!(self.span_utils, ident.span);
371-
let def_id = self.tcx.hir().local_def_id(field.id);
371+
let def_id = self.tcx.hir().local_def_id_from_node_id(field.id);
372372
let typ = self.tcx.type_of(def_id).to_string();
373373

374374

@@ -400,7 +400,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
400400
// The qualname for a method is the trait name or name of the struct in an impl in
401401
// which the method is declared in, followed by the method's name.
402402
let (qualname, parent_scope, decl_id, docs, attributes) =
403-
match self.tcx.impl_of_method(self.tcx.hir().local_def_id(id)) {
403+
match self.tcx.impl_of_method(self.tcx.hir().local_def_id_from_node_id(id)) {
404404
Some(impl_id) => match self.tcx.hir().get_if_local(impl_id) {
405405
Some(Node::Item(item)) => match item.node {
406406
hir::ItemKind::Impl(.., ref ty, _) => {
@@ -451,7 +451,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
451451
);
452452
}
453453
},
454-
None => match self.tcx.trait_of_item(self.tcx.hir().local_def_id(id)) {
454+
None => match self.tcx.trait_of_item(self.tcx.hir().local_def_id_from_node_id(id)) {
455455
Some(def_id) => {
456456
let mut docs = String::new();
457457
let mut attrs = vec![];

src/librustc_typeck/impl_wf_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn impl_wf_check(tcx: TyCtxt<'_>) {
5454
// but it's one that we must perform earlier than the rest of
5555
// WfCheck.
5656
for &module in tcx.hir().krate().modules.keys() {
57-
tcx.ensure().check_mod_impl_wf(tcx.hir().local_def_id(module));
57+
tcx.ensure().check_mod_impl_wf(tcx.hir().local_def_id_from_node_id(module));
5858
}
5959
}
6060

src/librustc_typeck/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorReported> {
310310
tcx.sess.track_errors(|| {
311311
time(tcx.sess, "type collecting", || {
312312
for &module in tcx.hir().krate().modules.keys() {
313-
tcx.ensure().collect_mod_item_types(tcx.hir().local_def_id(module));
313+
tcx.ensure().collect_mod_item_types(tcx.hir().local_def_id_from_node_id(module));
314314
}
315315
});
316316
})?;
@@ -345,7 +345,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorReported> {
345345

346346
time(tcx.sess, "item-types checking", || {
347347
for &module in tcx.hir().krate().modules.keys() {
348-
tcx.ensure().check_mod_item_types(tcx.hir().local_def_id(module));
348+
tcx.ensure().check_mod_item_types(tcx.hir().local_def_id_from_node_id(module));
349349
}
350350
});
351351

src/librustdoc/clean/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ impl Clean<Item> for doctree::Module<'_> {
654654
visibility: self.vis.clean(cx),
655655
stability: self.stab.clean(cx),
656656
deprecation: self.depr.clean(cx),
657-
def_id: cx.tcx.hir().local_def_id(self.id),
657+
def_id: cx.tcx.hir().local_def_id_from_node_id(self.id),
658658
inner: ModuleItem(Module {
659659
is_crate: self.is_crate,
660660
items,
@@ -2982,10 +2982,11 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
29822982
ty::FnPtr(_) => {
29832983
let ty = cx.tcx.lift(self).expect("FnPtr lift failed");
29842984
let sig = ty.fn_sig(cx.tcx);
2985+
let local_def_id = cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID);
29852986
BareFunction(box BareFunctionDecl {
29862987
unsafety: sig.unsafety(),
29872988
generic_params: Vec::new(),
2988-
decl: (cx.tcx.hir().local_def_id(ast::CRATE_NODE_ID), sig).clean(cx),
2989+
decl: (local_def_id, sig).clean(cx),
29892990
abi: sig.abi(),
29902991
})
29912992
}
@@ -3991,7 +3992,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
39913992
name: None,
39923993
attrs: self.attrs.clean(cx),
39933994
source: self.whence.clean(cx),
3994-
def_id: cx.tcx.hir().local_def_id(ast::CRATE_NODE_ID),
3995+
def_id: cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID),
39953996
visibility: self.vis.clean(cx),
39963997
stability: None,
39973998
deprecation: None,

0 commit comments

Comments
 (0)