X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_metadata%2Fcstore_impl.rs;h=c5f830c0d042054d04a4d8769bf9f429d2bb887a;hb=f49f38871389041671cc710a044e8360091840a3;hp=4cd1ff7b4a4ff8ed47ae02a8b3742a8df27f02a5;hpb=6bb7449fdb0c1abb597b6a3d3ab77efab466c937;p=rust.git diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 4cd1ff7b4a4..c5f830c0d04 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -9,7 +9,6 @@ use rustc::middle::cstore::{CrateSource, CrateStore, DepKind, EncodedMetadata, NativeLibraryKind}; use rustc::middle::exported_symbols::ExportedSymbol; use rustc::middle::stability::DeprecationEntry; -use rustc::middle::dependency_format::Linkage; use rustc::hir::def; use rustc::hir; use rustc::session::{CrateDisambiguator, Session}; @@ -29,7 +28,6 @@ use syntax::ast; use syntax::attr; use syntax::source_map; -use syntax::edition::Edition; use syntax::parse::source_file_to_stream; use syntax::parse::parser::emit_unclosed_delims; use syntax::source_map::Spanned; @@ -54,7 +52,7 @@ pub fn provide_extern<$lt>(providers: &mut Providers<$lt>) { let ($def_id, $other) = def_id_arg.into_args(); assert!(!$def_id.is_local()); - let $cdata = $tcx.crate_data_as_rc_any($def_id.krate); + let $cdata = $tcx.crate_data_as_any($def_id.krate); let $cdata = $cdata.downcast_ref::() .expect("CrateStore created data is not a CrateMetadata"); @@ -236,26 +234,11 @@ fn into_args(self) -> (DefId, DefId) { (self.0.as_def_id(), self.1) } used_crate_source => { Lrc::new(cdata.source.clone()) } exported_symbols => { - let mut syms = cdata.exported_symbols(tcx); - - // When linked into a dylib crates don't export their generic symbols, - // so if that's happening then we can't load upstream monomorphizations - // from this crate. - let formats = tcx.dependency_formats(LOCAL_CRATE); - let remove_generics = formats.iter().any(|(_ty, list)| { - match list.get(def_id.krate.as_usize() - 1) { - Some(Linkage::IncludedFromDylib) | Some(Linkage::Dynamic) => true, - _ => false, - } - }); - if remove_generics { - syms.retain(|(sym, _threshold)| { - match sym { - ExportedSymbol::Generic(..) => false, - _ => return true, - } - }); - } + let syms = cdata.exported_symbols(tcx); + + // FIXME rust-lang/rust#64319, rust-lang/rust#64872: We want + // to block export of generics from dylibs, but we must fix + // rust-lang/rust#65890 before we can do that robustly. Arc::new(syms) } @@ -411,10 +394,6 @@ pub fn export_macros_untracked(&self, cnum: CrateNum) { } } - pub fn crate_edition_untracked(&self, cnum: CrateNum) -> Edition { - self.get_crate_data(cnum).root.edition - } - 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) } @@ -445,7 +424,7 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro { 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 (body, mut errors) = source_file_to_stream(&sess.parse_sess, source_file, None); - emit_unclosed_delims(&mut errors, &sess.diagnostic()); + emit_unclosed_delims(&mut errors, &sess.parse_sess); // Mark the attrs as used let attrs = data.get_item_attrs(id.index, sess); @@ -460,7 +439,7 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro { LoadedMacro::MacroDef(ast::Item { // FIXME: cross-crate hygiene - ident: ast::Ident::with_dummy_span(name.as_symbol()), + ident: ast::Ident::with_dummy_span(name), id: ast::DUMMY_NODE_ID, span: local_span, attrs: attrs.iter().cloned().collect(), @@ -470,7 +449,7 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro { }), vis: source_map::respan(local_span.shrink_to_lo(), ast::VisibilityKind::Inherited), tokens: None, - }) + }, data.root.edition) } pub fn associated_item_cloned_untracked(&self, def: DefId) -> ty::AssocItem { @@ -483,8 +462,8 @@ pub fn crate_source_untracked(&self, cnum: CrateNum) -> CrateSource { } impl CrateStore for cstore::CStore { - fn crate_data_as_rc_any(&self, krate: CrateNum) -> Lrc { - self.get_crate_data(krate) + fn crate_data_as_any(&self, cnum: CrateNum) -> &dyn Any { + self.get_crate_data(cnum) } fn item_generics_cloned_untracked(&self, def: DefId, sess: &Session) -> ty::Generics { @@ -510,6 +489,10 @@ fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh self.get_crate_data(cnum).root.hash } + fn crate_host_hash_untracked(&self, cnum: CrateNum) -> Option { + self.get_crate_data(cnum).host_hash + } + /// Returns the `DefKey` for a given `DefId`. This indicates the /// parent `DefId` as well as some idea of what kind of data the /// `DefId` refers to. @@ -525,8 +508,8 @@ fn def_path_hash(&self, def: DefId) -> DefPathHash { self.get_crate_data(def.krate).def_path_hash(def.index) } - fn def_path_table(&self, cnum: CrateNum) -> Lrc { - self.get_crate_data(cnum).def_path_table.clone() + fn def_path_table(&self, cnum: CrateNum) -> &DefPathTable { + &self.get_crate_data(cnum).def_path_table } fn crates_untracked(&self) -> Vec