X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_metadata%2Frmeta%2Fdecoder%2Fcstore_impl.rs;h=86f64dc45b7c429d3d6fe1ac7ca2c85260145d5b;hb=c0b60c428a051773dea79426cb4a6a03737ca902;hp=50ab3811f523604047c950dcc2d84c889b4c7c8b;hpb=1e258784e141d68737d5702c6f388bd340c1d889;p=rust.git diff --git a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs index 50ab3811f52..86f64dc45b7 100644 --- a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs +++ b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs @@ -7,34 +7,29 @@ use rustc::hir::exports::Export; use rustc::hir::map::definitions::DefPathTable; use rustc::hir::map::{DefKey, DefPath, DefPathHash}; -use rustc::middle::cstore::{CrateSource, CrateStore, DepKind, EncodedMetadata, NativeLibraryKind}; +use rustc::middle::cstore::{CrateSource, CrateStore, EncodedMetadata, NativeLibraryKind}; use rustc::middle::exported_symbols::ExportedSymbol; use rustc::middle::stability::DeprecationEntry; use rustc::session::{CrateDisambiguator, Session}; use rustc::ty::query::Providers; use rustc::ty::query::QueryConfig; use rustc::ty::{self, TyCtxt}; +use rustc_ast::ast; +use rustc_ast::attr; +use rustc_ast::expand::allocator::AllocatorKind; +use rustc_ast::ptr::P; +use rustc_ast::tokenstream::DelimSpan; use rustc_data_structures::svh::Svh; use rustc_hir as hir; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, CRATE_DEF_INDEX, LOCAL_CRATE}; -use rustc_parse::parser::emit_unclosed_delims; -use rustc_parse::source_file_to_stream; +use rustc_span::source_map::{self, Span, Spanned}; +use rustc_span::symbol::Symbol; use rustc_data_structures::sync::Lrc; use smallvec::SmallVec; use std::any::Any; use std::sync::Arc; -use rustc_ast::ast; -use rustc_ast::attr; -use rustc_ast::expand::allocator::AllocatorKind; -use rustc_ast::ptr::P; -use rustc_ast::tokenstream::DelimSpan; -use rustc_span::source_map; -use rustc_span::source_map::Spanned; -use rustc_span::symbol::Symbol; -use rustc_span::{FileName, Span}; - macro_rules! provide { (<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $($name:ident => $compute:block)*) => { @@ -147,7 +142,7 @@ fn into_args(self) -> (DefId, DefId) { cdata.get_deprecation(def_id.index).map(DeprecationEntry::external) } item_attrs => { cdata.get_item_attrs(def_id.index, tcx.sess) } - // FIXME(#38501) We've skipped a `read` on the `HirBody` of + // FIXME(#38501) We've skipped a `read` on the `hir_owner_items` of // a `fn` when encoding, so the dep-tracking wouldn't work. // This is only used by rustdoc anyway, which shouldn't have // incremental recompilation ever enabled. @@ -393,14 +388,6 @@ pub fn provide(providers: &mut Providers<'_>) { } impl CStore { - pub fn export_macros_untracked(&self, cnum: CrateNum) { - let data = self.get_crate_data(cnum); - let mut dep_kind = data.dep_kind.lock(); - if *dep_kind == DepKind::UnexportedMacrosOnly { - *dep_kind = DepKind::MacrosOnly; - } - } - pub fn struct_field_names_untracked(&self, def: DefId, sess: &Session) -> Vec> { self.get_crate_data(def.krate).get_struct_field_names(def.index, sess) } @@ -427,15 +414,9 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro { return LoadedMacro::ProcMacro(data.load_proc_macro(id.index, sess)); } - let def = data.get_macro(id.index); - let macro_full_name = data.def_path(id.index).to_string_friendly(|_| data.root.name); - let source_name = FileName::Macros(macro_full_name); - - let source_file = sess.parse_sess.source_map().new_source_file(source_name, def.body); - let local_span = Span::with_root_ctxt(source_file.start_pos, source_file.end_pos); - let dspan = DelimSpan::from_single(local_span); - let (body, mut errors) = source_file_to_stream(&sess.parse_sess, source_file, None); - emit_unclosed_delims(&mut errors, &sess.parse_sess); + let span = data.get_span(id.index, sess); + let dspan = DelimSpan::from_single(span); + let rmeta::MacroDef { body, legacy } = data.get_macro(id.index, sess); // Mark the attrs as used let attrs = data.get_item_attrs(id.index, sess); @@ -449,22 +430,20 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro { .data .get_opt_name() .expect("no name in load_macro"); - sess.imported_macro_spans - .borrow_mut() - .insert(local_span, (name.to_string(), data.get_span(id.index, sess))); + sess.imported_macro_spans.borrow_mut().insert(span, (name.to_string(), span)); LoadedMacro::MacroDef( ast::Item { // FIXME: cross-crate hygiene ident: ast::Ident::with_dummy_span(name), id: ast::DUMMY_NODE_ID, - span: local_span, + span, attrs: attrs.iter().cloned().collect(), kind: ast::ItemKind::MacroDef(ast::MacroDef { body: P(ast::MacArgs::Delimited(dspan, ast::MacDelimiter::Brace, body)), - legacy: def.legacy, + legacy, }), - vis: source_map::respan(local_span.shrink_to_lo(), ast::VisibilityKind::Inherited), + vis: source_map::respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited), tokens: None, }, data.root.edition, @@ -525,7 +504,7 @@ fn def_path_hash(&self, def: DefId) -> DefPathHash { } fn def_path_table(&self, cnum: CrateNum) -> &DefPathTable { - &self.get_crate_data(cnum).def_path_table + &self.get_crate_data(cnum).cdata.def_path_table } fn crates_untracked(&self) -> Vec {