mirror of
https://github.com/rust-lang/rust.git
synced 2026-03-23 19:27:56 +00:00
Inline and remove lower_* methods.
They are all short and have a single call site.
This commit is contained in:
@@ -76,37 +76,27 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
|
||||
let node = self.ast_index[def_id];
|
||||
match node {
|
||||
AstOwner::NonOwner => {}
|
||||
AstOwner::Crate(c) => self.lower_crate(c),
|
||||
AstOwner::Item(item) => self.lower_item(item),
|
||||
AstOwner::AssocItem(item, ctxt) => self.lower_assoc_item(item, ctxt),
|
||||
AstOwner::ForeignItem(item) => self.lower_foreign_item(item),
|
||||
AstOwner::Crate(c) => {
|
||||
debug_assert_eq!(self.resolver.node_id_to_def_id[&CRATE_NODE_ID], CRATE_DEF_ID);
|
||||
self.with_lctx(CRATE_NODE_ID, |lctx| {
|
||||
let module = lctx.lower_mod(&c.items, &c.spans);
|
||||
// FIXME(jdonszelman): is dummy span ever a problem here?
|
||||
lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs, DUMMY_SP);
|
||||
hir::OwnerNode::Crate(module)
|
||||
})
|
||||
}
|
||||
AstOwner::Item(item) => {
|
||||
self.with_lctx(item.id, |lctx| hir::OwnerNode::Item(lctx.lower_item(item)))
|
||||
}
|
||||
AstOwner::AssocItem(item, ctxt) => {
|
||||
self.with_lctx(item.id, |lctx| lctx.lower_assoc_item(item, ctxt))
|
||||
}
|
||||
AstOwner::ForeignItem(item) => self.with_lctx(item.id, |lctx| {
|
||||
hir::OwnerNode::ForeignItem(lctx.lower_foreign_item(item))
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self, c))]
|
||||
fn lower_crate(&mut self, c: &Crate) {
|
||||
debug_assert_eq!(self.resolver.node_id_to_def_id[&CRATE_NODE_ID], CRATE_DEF_ID);
|
||||
self.with_lctx(CRATE_NODE_ID, |lctx| {
|
||||
let module = lctx.lower_mod(&c.items, &c.spans);
|
||||
// FIXME(jdonszelman): is dummy span ever a problem here?
|
||||
lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs, DUMMY_SP);
|
||||
hir::OwnerNode::Crate(module)
|
||||
})
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn lower_item(&mut self, item: &Item) {
|
||||
self.with_lctx(item.id, |lctx| hir::OwnerNode::Item(lctx.lower_item(item)))
|
||||
}
|
||||
|
||||
fn lower_assoc_item(&mut self, item: &AssocItem, ctxt: AssocCtxt) {
|
||||
self.with_lctx(item.id, |lctx| lctx.lower_assoc_item(item, ctxt))
|
||||
}
|
||||
|
||||
fn lower_foreign_item(&mut self, item: &ForeignItem) {
|
||||
self.with_lctx(item.id, |lctx| hir::OwnerNode::ForeignItem(lctx.lower_foreign_item(item)))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'hir> LoweringContext<'_, 'hir> {
|
||||
|
||||
Reference in New Issue
Block a user