]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #41847 - alexcrichton:less-unstable-annotations, r=eddyb
authorbors <bors@rust-lang.org>
Sat, 13 May 2017 05:22:08 +0000 (05:22 +0000)
committerbors <bors@rust-lang.org>
Sat, 13 May 2017 05:22:08 +0000 (05:22 +0000)
rustc: Add a new `-Z force-unstable-if-unmarked` flag

This commit adds a new `-Z` flag to the compiler for use when bootstrapping the
compiler itself. We want to be able to use crates.io crates, but we also want
the usage of such crates to be as ergonomic as possible! To that end compiler
crates are a little tricky in that the crates.io crates are not annotated as
unstable, nor do they expect to pull in unstable dependencies.

To cover all these situations it's intended that the compiler will forever now
bootstrap with `-Z force-unstable-if-unmarked`. This flags serves a dual purpose
of forcing crates.io crates to themselves be unstable while also allowing them
to use other "unstable" crates.io crates. This should mean that adding a
dependency to compiler no longer requires upstream modification with
unstable/staged_api attributes for inclusion!

1  2 
src/librustc/middle/cstore.rs
src/librustc_driver/lib.rs
src/librustc_metadata/cstore_impl.rs

index da899a9130c8bb1e1fee34dbbaa26e51b59c4e89,53e684e34bde1408e602531dbe464312f01107f2..569b1aeeb09d7ca1a2e2323746295a89b24708c7
@@@ -210,21 -210,27 +210,21 @@@ pub trait CrateStore 
      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;
@@@ -331,22 -336,28 +330,22 @@@ impl CrateStore for DummyCrateStore 
      }
      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") }
index eef3b38a8b5e9bdb32c8b12788c32f68a1308ea9,9cee5bc0319b7f2d723aaeff9459826ac44791c9..024fc546a158efe9d175f4ba7357be522cf1a739
@@@ -15,7 -15,6 +15,6 @@@
  //! 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;
@@@ -635,24 -636,11 +636,24 @@@ impl RustcDefaultCalls 
                              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)
index f3fb427fed66fdd2e52204786bfbf03bc3f89312,c7da535faa2946a3ab232ea82b7f59cbb087c615..dbf3e94832fc4fd724a010fe841d440243c406b0
@@@ -41,6 -41,8 +41,6 @@@ use rustc::hir::svh::Svh
  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>) {
@@@ -111,23 -113,21 +111,23 @@@ provide! { <'tcx> tcx, def_id, cdat
      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)