expand: Stop using artificial ast::Item
for macros loaded from metadata
This commit is contained in:
parent
9260be36b2
commit
b93a2dd0ef
8 changed files with 94 additions and 120 deletions
|
@ -28,7 +28,7 @@ use rustc_session::lint::{self, BuiltinLintDiag};
|
|||
use rustc_session::output::validate_crate_name;
|
||||
use rustc_session::search_paths::PathKind;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::symbol::{Symbol, sym};
|
||||
use rustc_span::symbol::{Ident, Symbol, sym};
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
use rustc_target::spec::{PanicStrategy, Target, TargetTriple};
|
||||
use tracing::{debug, info, trace};
|
||||
|
@ -97,7 +97,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub enum LoadedMacro {
|
||||
MacroDef(ast::Item, Edition),
|
||||
MacroDef { def: MacroDef, ident: Ident, attrs: AttrVec, span: Span, edition: Edition },
|
||||
ProcMacro(SyntaxExtension),
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use std::any::Any;
|
||||
use std::mem;
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_attr::Deprecation;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||
|
@ -592,27 +591,16 @@ impl CStore {
|
|||
|
||||
let data = self.get_crate_data(id.krate);
|
||||
if data.root.is_proc_macro_crate() {
|
||||
return LoadedMacro::ProcMacro(data.load_proc_macro(id.index, tcx));
|
||||
}
|
||||
|
||||
let span = data.get_span(id.index, sess);
|
||||
|
||||
LoadedMacro::MacroDef(
|
||||
ast::Item {
|
||||
LoadedMacro::ProcMacro(data.load_proc_macro(id.index, tcx))
|
||||
} else {
|
||||
LoadedMacro::MacroDef {
|
||||
def: data.get_macro(id.index, sess),
|
||||
ident: data.item_ident(id.index, sess),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span,
|
||||
attrs: data.get_item_attrs(id.index, sess).collect(),
|
||||
kind: ast::ItemKind::MacroDef(data.get_macro(id.index, sess)),
|
||||
vis: ast::Visibility {
|
||||
span: span.shrink_to_lo(),
|
||||
kind: ast::VisibilityKind::Inherited,
|
||||
tokens: None,
|
||||
},
|
||||
tokens: None,
|
||||
},
|
||||
data.root.edition,
|
||||
)
|
||||
span: data.get_span(id.index, sess),
|
||||
edition: data.root.edition,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn def_span_untracked(&self, def_id: DefId, sess: &Session) -> Span {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue