fn visibility(&self, def: DefId) -> ty::Visibility;
fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap<DefId>>;
fn item_generics_cloned(&self, def: DefId) -> ty::Generics;
- fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]>;
- fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>;
// trait info
fn implementations_of_trait(&self, filter: Option<DefId>) -> Vec<DefId>;
// impl info
fn impl_defaultness(&self, def: DefId) -> hir::Defaultness;
- fn impl_parent(&self, impl_def_id: DefId) -> Option<DefId>;
// trait/impl-item info
- fn trait_of_item(&self, def_id: DefId) -> Option<DefId>;
fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem;
// flags
fn is_const_fn(&self, did: DefId) -> bool;
fn is_default_impl(&self, impl_did: DefId) -> bool;
- fn is_foreign_item(&self, did: DefId) -> bool;
fn is_dllimport_foreign_item(&self, def: DefId) -> bool;
fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool;
- fn is_exported_symbol(&self, def_id: DefId) -> bool;
// crate metadata
fn dylib_dependency_formats(&self, cnum: CrateNum)
fn export_macros(&self, cnum: CrateNum);
fn lang_items(&self, cnum: CrateNum) -> Vec<(DefIndex, usize)>;
fn missing_lang_items(&self, cnum: CrateNum) -> Vec<lang_items::LangItem>;
- fn is_staged_api(&self, cnum: CrateNum) -> bool;
fn is_allocator(&self, cnum: CrateNum) -> bool;
fn is_panic_runtime(&self, cnum: CrateNum) -> bool;
fn is_compiler_builtins(&self, cnum: CrateNum) -> bool;
}
fn item_generics_cloned(&self, def: DefId) -> ty::Generics
{ bug!("item_generics_cloned") }
- fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]> { bug!("item_attrs") }
- fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name> { bug!("fn_arg_names") }
// trait info
fn implementations_of_trait(&self, filter: Option<DefId>) -> Vec<DefId> { vec![] }
// impl info
fn impl_defaultness(&self, def: DefId) -> hir::Defaultness { bug!("impl_defaultness") }
- fn impl_parent(&self, def: DefId) -> Option<DefId> { bug!("impl_parent") }
// trait/impl-item info
- fn trait_of_item(&self, def_id: DefId) -> Option<DefId> { bug!("trait_of_item") }
fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem
{ bug!("associated_item_cloned") }
// flags
fn is_const_fn(&self, did: DefId) -> bool { bug!("is_const_fn") }
fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") }
- fn is_foreign_item(&self, did: DefId) -> bool { bug!("is_foreign_item") }
fn is_dllimport_foreign_item(&self, id: DefId) -> bool { false }
fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { false }
- fn is_exported_symbol(&self, def_id: DefId) -> bool { false }
// crate metadata
fn dylib_dependency_formats(&self, cnum: CrateNum)
{ bug!("lang_items") }
fn missing_lang_items(&self, cnum: CrateNum) -> Vec<lang_items::LangItem>
{ bug!("missing_lang_items") }
- fn is_staged_api(&self, cnum: CrateNum) -> bool { bug!("is_staged_api") }
fn dep_kind(&self, cnum: CrateNum) -> DepKind { bug!("is_explicitly_linked") }
fn export_macros(&self, cnum: CrateNum) { bug!("export_macros") }
fn is_allocator(&self, cnum: CrateNum) -> bool { bug!("is_allocator") }
//! This API is completely unstable and subject to change.
#![crate_name = "rustc_driver"]
- #![unstable(feature = "rustc_private", issue = "27812")]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
#![feature(libc)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
- #![feature(rustc_private)]
#![feature(set_stdio)]
- #![feature(staged_api)]
+
+ #![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))]
+ #![cfg_attr(stage0, feature(rustc_private))]
+ #![cfg_attr(stage0, feature(staged_api))]
extern crate arena;
extern crate getopts;
node: ast::MetaItemKind::Word,
span: DUMMY_SP,
});
- if !allow_unstable_cfg && gated_cfg.is_some() {
- continue;
+
+ // Note that crt-static is a specially recognized cfg
+ // directive that's printed out here as part of
+ // rust-lang/rust#37406, but in general the
+ // `target_feature` cfg is gated under
+ // rust-lang/rust#29717. For now this is just
+ // specifically allowing the crt-static cfg and that's
+ // it, this is intended to get into Cargo and then go
+ // through to build scripts.
+ let value = value.as_ref().map(|s| s.as_str());
+ let value = value.as_ref().map(|s| s.as_ref());
+ if name != "target_feature" || value != Some("crt-static") {
+ if !allow_unstable_cfg && gated_cfg.is_some() {
+ continue;
+ }
}
- cfgs.push(if let &Some(ref value) = value {
+ cfgs.push(if let Some(value) = value {
format!("{}=\"{}\"", name, value)
} else {
format!("{}", name)
use rustc_back::target::Target;
use rustc::hir;
-use std::collections::BTreeMap;
-
macro_rules! provide {
(<$lt:tt> $tcx:ident, $def_id:ident, $cdata:ident $($name:ident => $compute:block)*) => {
pub fn provide<$lt>(providers: &mut Providers<$lt>) {
def_span => { cdata.get_span(def_id.index, &tcx.sess) }
stability => { cdata.get_stability(def_id.index) }
deprecation => { cdata.get_deprecation(def_id.index) }
- item_body_nested_bodies => {
- let map: BTreeMap<_, _> = cdata.entry(def_id.index).ast.into_iter().flat_map(|ast| {
- ast.decode(cdata).nested_bodies.decode(cdata).map(|body| (body.id(), body))
- }).collect();
-
- Rc::new(map)
- }
+ item_attrs => { cdata.get_item_attrs(def_id.index, &tcx.dep_graph) }
+ // FIXME(#38501) We've skipped a `read` on the `HirBody` 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.
+ fn_arg_names => { cdata.get_fn_arg_names(def_id.index) }
+ impl_parent => { cdata.get_parent_impl(def_id.index) }
+ trait_of_item => { cdata.get_trait_of_item(def_id.index) }
+ is_exported_symbol => {
+ let dep_node = cdata.metadata_dep_node(GlobalMetaDataKind::ExportedSymbols);
+ cdata.exported_symbols.get(&tcx.dep_graph, dep_node).contains(&def_id.index)
+ }
+ item_body_nested_bodies => { Rc::new(cdata.item_body_nested_bodies(def_id.index)) }
const_is_rvalue_promotable_to_static => {
- cdata.entry(def_id.index).ast.expect("const item missing `ast`")
- .decode(cdata).rvalue_promotable_to_static
- }
- is_mir_available => {
- !cdata.is_proc_macro(def_id.index) &&
- cdata.maybe_entry(def_id.index).and_then(|item| item.decode(cdata).mir).is_some()
+ cdata.const_is_rvalue_promotable_to_static(def_id.index)
}
+ is_mir_available => { cdata.is_item_mir_available(def_id.index) }
}
impl CrateStore for cstore::CStore {
self.get_crate_data(def.krate).get_generics(def.index)
}
- fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]>
- {
- self.get_crate_data(def_id.krate)
- .get_item_attrs(def_id.index, &self.dep_graph)
- }
-
- fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>
- {
- // FIXME(#38501) We've skipped a `read` on the `HirBody` 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.
- assert!(!self.dep_graph.is_fully_enabled());
- self.get_crate_data(did.krate).get_fn_arg_names(did.index)
- }
-
fn implementations_of_trait(&self, filter: Option<DefId>) -> Vec<DefId>
{
if let Some(def_id) = filter {
self.get_crate_data(def.krate).get_impl_defaultness(def.index)
}
- fn impl_parent(&self, impl_def: DefId) -> Option<DefId> {
- self.dep_graph.read(DepNode::MetaData(impl_def));
- self.get_crate_data(impl_def.krate).get_parent_impl(impl_def.index)
- }
-
- fn trait_of_item(&self, def_id: DefId) -> Option<DefId> {
- self.dep_graph.read(DepNode::MetaData(def_id));
- self.get_crate_data(def_id.krate).get_trait_of_item(def_id.index)
- }
-
fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem
{
self.dep_graph.read(DepNode::MetaData(def));
self.get_crate_data(impl_did.krate).is_default_impl(impl_did.index)
}
- fn is_foreign_item(&self, did: DefId) -> bool {
- self.get_crate_data(did.krate).is_foreign_item(did.index)
- }
-
fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool
{
self.do_is_statically_included_foreign_item(def_id)
}
- fn is_exported_symbol(&self, def_id: DefId) -> bool {
- let data = self.get_crate_data(def_id.krate);
- let dep_node = data.metadata_dep_node(GlobalMetaDataKind::ExportedSymbols);
- data.exported_symbols
- .get(&self.dep_graph, dep_node)
- .contains(&def_id.index)
- }
-
fn is_dllimport_foreign_item(&self, def_id: DefId) -> bool {
if def_id.krate == LOCAL_CRATE {
self.dllimport_foreign_items.borrow().contains(&def_id.index)
self.get_crate_data(cnum).get_missing_lang_items(&self.dep_graph)
}
- fn is_staged_api(&self, cnum: CrateNum) -> bool
- {
- self.get_crate_data(cnum).is_staged_api(&self.dep_graph)
- }
-
fn is_allocator(&self, cnum: CrateNum) -> bool
{
self.get_crate_data(cnum).is_allocator(&self.dep_graph)