diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2024-10-26 18:51:15 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2024-10-26 22:08:55 +0300 |
| commit | b93a2dd0efeb00238543fd199ebdb8bb0f96bad7 (patch) | |
| tree | 8c91bdd763e91395d89b311df1393cb8371d6d3f /compiler/rustc_metadata | |
| parent | 9260be36b2dbd896c6b233d60d1c429a75a0081a (diff) | |
| download | rust-b93a2dd0efeb00238543fd199ebdb8bb0f96bad7.tar.gz rust-b93a2dd0efeb00238543fd199ebdb8bb0f96bad7.zip | |
expand: Stop using artificial `ast::Item` for macros loaded from metadata
Diffstat (limited to 'compiler/rustc_metadata')
| -rw-r--r-- | compiler/rustc_metadata/src/creader.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 28 |
2 files changed, 10 insertions, 22 deletions
diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index 8adec7554a8..16623915c40 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -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), } diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 71c7231a788..926eb4f6210 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -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 { |
