Skip to content

Commit 3e246bb

Browse files
committed
librustc_middle: return LocalDefId instead of DefId in local_def_id
1 parent 7fb5187 commit 3e246bb

File tree

62 files changed

+545
-492
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

+545
-492
lines changed

src/librustc_codegen_ssa/back/symbol_export.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn reachable_non_generics_provider(
9494
if !generics.requires_monomorphization(tcx) &&
9595
// Functions marked with #[inline] are only ever codegened
9696
// with "internal" linkage and are never exported.
97-
!Instance::mono(tcx, def_id).def.generates_cgu_internal_copy(tcx)
97+
!Instance::mono(tcx, def_id.to_def_id()).def.generates_cgu_internal_copy(tcx)
9898
{
9999
Some(def_id)
100100
} else {
@@ -107,7 +107,7 @@ fn reachable_non_generics_provider(
107107
})
108108
.map(|def_id| {
109109
let export_level = if special_runtime_crate {
110-
let name = tcx.symbol_name(Instance::mono(tcx, def_id)).name.as_str();
110+
let name = tcx.symbol_name(Instance::mono(tcx, def_id.to_def_id())).name.as_str();
111111
// We can probably do better here by just ensuring that
112112
// it has hidden visibility rather than public
113113
// visibility, as this is primarily here to ensure it's
@@ -124,14 +124,14 @@ fn reachable_non_generics_provider(
124124
SymbolExportLevel::Rust
125125
}
126126
} else {
127-
symbol_export_level(tcx, def_id)
127+
symbol_export_level(tcx, def_id.to_def_id())
128128
};
129129
debug!(
130130
"EXPORTED SYMBOL (local): {} ({:?})",
131-
tcx.symbol_name(Instance::mono(tcx, def_id)),
131+
tcx.symbol_name(Instance::mono(tcx, def_id.to_def_id())),
132132
export_level
133133
);
134-
(def_id, export_level)
134+
(def_id.to_def_id(), export_level)
135135
})
136136
.collect();
137137

src/librustc_driver/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> {
322322
}
323323

324324
fn node_path(&self, id: hir::HirId) -> Option<String> {
325-
Some(self.tcx.def_path_str(self.tcx.hir().local_def_id(id)))
325+
Some(self.tcx.def_path_str(self.tcx.hir().local_def_id(id).to_def_id()))
326326
}
327327
}
328328

src/librustc_incremental/assert_dep_graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl IfThisChanged<'tcx> {
115115

116116
fn process_attrs(&mut self, hir_id: hir::HirId, attrs: &[ast::Attribute]) {
117117
let def_id = self.tcx.hir().local_def_id(hir_id);
118-
let def_path_hash = self.tcx.def_path_hash(def_id);
118+
let def_path_hash = self.tcx.def_path_hash(def_id.to_def_id());
119119
for attr in attrs {
120120
if attr.check_name(sym::rustc_if_this_changed) {
121121
let dep_node_interned = self.argument(attr);
@@ -131,7 +131,7 @@ impl IfThisChanged<'tcx> {
131131
}
132132
},
133133
};
134-
self.if_this_changed.push((attr.span, def_id, dep_node));
134+
self.if_this_changed.push((attr.span, def_id.to_def_id(), dep_node));
135135
} else if attr.check_name(sym::rustc_then_this_would_need) {
136136
let dep_node_interned = self.argument(attr);
137137
let dep_node = match dep_node_interned {

src/librustc_incremental/persist/dirty_clean.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,16 +434,16 @@ impl DirtyCleanVisitor<'tcx> {
434434

435435
fn check_item(&mut self, item_id: hir::HirId, item_span: Span) {
436436
let def_id = self.tcx.hir().local_def_id(item_id);
437-
for attr in self.tcx.get_attrs(def_id).iter() {
437+
for attr in self.tcx.get_attrs(def_id.to_def_id()).iter() {
438438
let assertion = match self.assertion_maybe(item_id, attr) {
439439
Some(a) => a,
440440
None => continue,
441441
};
442442
self.checked_attrs.insert(attr.id);
443-
for dep_node in self.dep_nodes(&assertion.clean, def_id) {
443+
for dep_node in self.dep_nodes(&assertion.clean, def_id.to_def_id()) {
444444
self.assert_clean(item_span, dep_node);
445445
}
446-
for dep_node in self.dep_nodes(&assertion.dirty, def_id) {
446+
for dep_node in self.dep_nodes(&assertion.dirty, def_id.to_def_id()) {
447447
self.assert_dirty(item_span, dep_node);
448448
}
449449
}

src/librustc_interface/proc_macro_decls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn proc_macro_decls_static(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<DefId> {
1616
let mut finder = Finder { decls: None };
1717
tcx.hir().krate().visit_all_item_likes(&mut finder);
1818

19-
finder.decls.map(|id| tcx.hir().local_def_id(id))
19+
finder.decls.map(|id| tcx.hir().local_def_id(id).to_def_id())
2020
}
2121

2222
struct Finder {

src/librustc_lint/builtin.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
461461
};
462462

463463
let def_id = cx.tcx.hir().local_def_id(it.hir_id);
464-
let (article, desc) = cx.tcx.article_and_description(def_id);
464+
let (article, desc) = cx.tcx.article_and_description(def_id.to_def_id());
465465

466466
self.check_missing_docs_attrs(cx, Some(it.hir_id), &it.attrs, it.span, article, desc);
467467
}
@@ -472,7 +472,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
472472
}
473473

474474
let def_id = cx.tcx.hir().local_def_id(trait_item.hir_id);
475-
let (article, desc) = cx.tcx.article_and_description(def_id);
475+
let (article, desc) = cx.tcx.article_and_description(def_id.to_def_id());
476476

477477
self.check_missing_docs_attrs(
478478
cx,
@@ -491,7 +491,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
491491
}
492492

493493
let def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
494-
let (article, desc) = cx.tcx.article_and_description(def_id);
494+
let (article, desc) = cx.tcx.article_and_description(def_id.to_def_id());
495495
self.check_missing_docs_attrs(
496496
cx,
497497
Some(impl_item.hir_id),
@@ -1531,7 +1531,8 @@ impl ExplicitOutlivesRequirements {
15311531
inferred_outlives: &'tcx [(ty::Predicate<'tcx>, Span)],
15321532
ty_generics: &'tcx ty::Generics,
15331533
) -> Vec<ty::Region<'tcx>> {
1534-
let index = ty_generics.param_def_id_to_index[&tcx.hir().local_def_id(param.hir_id)];
1534+
let index =
1535+
ty_generics.param_def_id_to_index[&tcx.hir().local_def_id(param.hir_id).to_def_id()];
15351536

15361537
match param.kind {
15371538
hir::GenericParamKind::Lifetime { .. } => {

src/librustc_metadata/foreign_modules.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
2222
};
2323

2424
let foreign_items =
25-
fm.items.iter().map(|it| self.tcx.hir().local_def_id(it.hir_id)).collect();
26-
self.modules
27-
.push(ForeignModule { foreign_items, def_id: self.tcx.hir().local_def_id(it.hir_id) });
25+
fm.items.iter().map(|it| self.tcx.hir().local_def_id(it.hir_id).to_def_id()).collect();
26+
self.modules.push(ForeignModule {
27+
foreign_items,
28+
def_id: self.tcx.hir().local_def_id(it.hir_id).to_def_id(),
29+
});
2830
}
2931

3032
fn visit_trait_item(&mut self, _it: &'tcx hir::TraitItem<'tcx>) {}

src/librustc_metadata/native_libs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
5151
name: None,
5252
kind: cstore::NativeUnknown,
5353
cfg: None,
54-
foreign_module: Some(self.tcx.hir().local_def_id(it.hir_id)),
54+
foreign_module: Some(self.tcx.hir().local_def_id(it.hir_id).to_def_id()),
5555
wasm_import_module: None,
5656
};
5757
let mut kind_specified = false;

0 commit comments

Comments
 (0)