Skip to content

Commit 6130b99

Browse files
committed
rustc: use LocalDefId instead of DefIndex in hir::lowering.
1 parent 42b2adf commit 6130b99

File tree

2 files changed

+72
-57
lines changed

2 files changed

+72
-57
lines changed

src/librustc_ast_lowering/item.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_ast::visit::{self, AssocCtxt, Visitor};
1111
use rustc_errors::struct_span_err;
1212
use rustc_hir as hir;
1313
use rustc_hir::def::{DefKind, Res};
14-
use rustc_hir::def_id::DefId;
14+
use rustc_hir::def_id::LocalDefId;
1515
use rustc_span::source_map::{respan, DesugaringKind};
1616
use rustc_span::symbol::{kw, sym};
1717
use rustc_span::Span;
@@ -269,7 +269,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
269269
hir::ItemKind::Const(ty, body_id)
270270
}
271271
ItemKind::Fn(_, FnSig { ref decl, header }, ref generics, ref body) => {
272-
let fn_def_id = self.resolver.definitions().local_def_id(id);
272+
let fn_def_id = self.resolver.definitions().local_def_id(id).expect_local();
273273
self.with_new_scopes(|this| {
274274
this.current_item = Some(ident.span);
275275

@@ -287,7 +287,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
287287
AnonymousLifetimeMode::PassThrough,
288288
|this, idty| {
289289
let ret_id = asyncness.opt_return_id();
290-
this.lower_fn_decl(&decl, Some((fn_def_id, idty)), true, ret_id)
290+
this.lower_fn_decl(
291+
&decl,
292+
Some((fn_def_id.to_def_id(), idty)),
293+
true,
294+
ret_id,
295+
)
291296
},
292297
);
293298
let sig = hir::FnSig { decl, header: this.lower_fn_header(header) };
@@ -351,7 +356,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
351356
self_ty: ref ty,
352357
items: ref impl_items,
353358
} => {
354-
let def_id = self.resolver.definitions().local_def_id(id);
359+
let def_id = self.resolver.definitions().local_def_id(id).expect_local();
355360

356361
// Lower the "impl header" first. This ordering is important
357362
// for in-band lifetimes! Consider `'a` here:
@@ -648,7 +653,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
648653
}
649654

650655
fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem<'hir> {
651-
let def_id = self.resolver.definitions().local_def_id(i.id);
656+
let def_id = self.resolver.definitions().local_def_id(i.id).expect_local();
652657
hir::ForeignItem {
653658
hir_id: self.lower_node_id(i.id),
654659
ident: i.ident,
@@ -749,7 +754,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
749754
}
750755

751756
fn lower_trait_item(&mut self, i: &AssocItem) -> hir::TraitItem<'hir> {
752-
let trait_item_def_id = self.resolver.definitions().local_def_id(i.id);
757+
let trait_item_def_id = self.resolver.definitions().local_def_id(i.id).expect_local();
753758

754759
let (generics, kind) = match i.kind {
755760
AssocItemKind::Const(_, ref ty, ref default) => {
@@ -814,7 +819,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
814819
}
815820

816821
fn lower_impl_item(&mut self, i: &AssocItem) -> hir::ImplItem<'hir> {
817-
let impl_item_def_id = self.resolver.definitions().local_def_id(i.id);
822+
let impl_item_def_id = self.resolver.definitions().local_def_id(i.id).expect_local();
818823

819824
let (generics, kind) = match &i.kind {
820825
AssocItemKind::Const(_, ty, expr) => {
@@ -1211,7 +1216,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12111216
&mut self,
12121217
generics: &Generics,
12131218
sig: &FnSig,
1214-
fn_def_id: DefId,
1219+
fn_def_id: LocalDefId,
12151220
impl_trait_return_allow: bool,
12161221
is_async: Option<NodeId>,
12171222
) -> (hir::Generics<'hir>, hir::FnSig<'hir>) {
@@ -1223,7 +1228,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12231228
|this, idty| {
12241229
this.lower_fn_decl(
12251230
&sig.decl,
1226-
Some((fn_def_id, idty)),
1231+
Some((fn_def_id.to_def_id(), idty)),
12271232
impl_trait_return_allow,
12281233
is_async,
12291234
)

0 commit comments

Comments
 (0)