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};
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) }
+ asyncness => { cdata.asyncness(def_id.index) }
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
static_mutability => { cdata.static_mutability(def_id.index) }
def_kind => { cdata.def_kind(def_id.index) }
}
defined_lib_features => { cdata.get_lib_features(tcx) }
defined_lang_items => { cdata.get_lang_items(tcx) }
+ diagnostic_items => { cdata.get_diagnostic_items(tcx) }
missing_lang_items => { cdata.get_missing_lang_items(tcx) }
missing_extern_crate_item => {
used_crate_source => { Lrc::new(cdata.source.clone()) }
- exported_symbols => { Arc::new(cdata.exported_symbols(tcx)) }
+ 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,
+ }
+ });
+ }
+
+ Arc::new(syms)
+ }
}
pub fn provide(providers: &mut Providers<'_>) {
tcx.arena.alloc(visible_parent_map)
},
+ dependency_formats: |tcx, cnum| {
+ assert_eq!(cnum, LOCAL_CRATE);
+ Lrc::new(crate::dependency_format::calculate(tcx))
+ },
+
..*providers
};
}
.insert(local_span, (name.to_string(), data.get_span(id.index, sess)));
LoadedMacro::MacroDef(ast::Item {
- ident: ast::Ident::from_str(&name.as_str()),
+ // FIXME: cross-crate hygiene
+ ident: ast::Ident::with_dummy_span(name.as_symbol()),
id: ast::DUMMY_NODE_ID,
span: local_span,
attrs: attrs.iter().cloned().collect(),