]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #36847 - alexcrichton:rustc-macro-doc, r=nrc
authorbors <bors@rust-lang.org>
Mon, 3 Oct 2016 14:40:22 +0000 (07:40 -0700)
committerGitHub <noreply@github.com>
Mon, 3 Oct 2016 14:40:22 +0000 (07:40 -0700)
rustdoc: Fix documenting rustc-macro crates

This commit adds a "hack" to the session to track whether we're a rustdoc
session or not. If we're rustdoc then we skip the expansion to add the
rustc-macro infrastructure.

Closes #36820

1  2 
src/bootstrap/step.rs
src/librustc/session/config.rs

diff --combined src/bootstrap/step.rs
index 8a96cd1b4d23939f5e08e516beaa4a984e5c96fc,5b48bcb9ab3778aba90dc8c1f32c00adec302033..e3567107884365698d6072f04472fa1ab449e7cb
@@@ -418,6 -418,7 +418,6 @@@ impl<'a> Step<'a> 
                      self.check_crate_std(compiler),
                      self.check_crate_test(compiler),
                      self.check_debuginfo(compiler),
 -                    self.dist(stage),
                  ];
  
                  // If we're testing the build triple, then we know we can
                          // misc
                          self.check_linkcheck(stage),
                          self.check_tidy(stage),
 +
 +                        // can we make the distributables?
 +                        self.dist(stage),
                      ]);
                  }
                  return base
              Source::CheckCodegenUnits { compiler } |
              Source::CheckIncremental { compiler } |
              Source::CheckUi { compiler } |
-             Source::CheckRustdoc { compiler } |
              Source::CheckPretty { compiler } |
              Source::CheckCFail { compiler } |
              Source::CheckRPassValgrind { compiler } |
                      self.debugger_scripts(compiler.stage),
                  ]
              }
+             Source::CheckRustdoc { compiler } |
              Source::CheckRPassFull { compiler } |
              Source::CheckRFailFull { compiler } |
              Source::CheckCFailFull { compiler } |
index f8b06bf2e97626c6951323634c8037fe5e1af692,1d8fa6e07775ccedf5a0de8e47dbe93700107ec5..9987fbab38909e56c973ced60350d17f74751b31
@@@ -19,7 -19,6 +19,7 @@@ pub use self::DebugInfoLevel::*
  use session::{early_error, early_warn, Session};
  use session::search_paths::SearchPaths;
  
 +use rustc_back::PanicStrategy;
  use rustc_back::target::Target;
  use lint;
  use middle::cstore;
@@@ -288,6 -287,11 +288,11 @@@ top_level_options!
          alt_std_name: Option<String> [TRACKED],
          // Indicates how the compiler should treat unstable features
          unstable_features: UnstableFeatures [TRACKED],
+         // Indicates whether this run of the compiler is actually rustdoc. This
+         // is currently just a hack and will be removed eventually, so please
+         // try to not rely on this too much.
+         actually_rustdoc: bool [TRACKED],
      }
  );
  
@@@ -440,6 -444,7 +445,7 @@@ pub fn basic_options() -> Options 
          libs: Vec::new(),
          unstable_features: UnstableFeatures::Disallow,
          debug_assertions: true,
+         actually_rustdoc: false,
      }
  }
  
@@@ -493,6 -498,21 +499,6 @@@ impl Passes 
      }
  }
  
 -#[derive(Clone, PartialEq, Hash, RustcEncodable, RustcDecodable)]
 -pub enum PanicStrategy {
 -    Unwind,
 -    Abort,
 -}
 -
 -impl PanicStrategy {
 -    pub fn desc(&self) -> &str {
 -        match *self {
 -            PanicStrategy::Unwind => "unwind",
 -            PanicStrategy::Abort => "abort",
 -        }
 -    }
 -}
 -
  /// Declare a macro that will define all CodegenOptions/DebuggingOptions fields and parsers all
  /// at once. The goal of this macro is to define an interface that can be
  /// programmatically used by the option parser in order to initialize the struct
@@@ -606,8 -626,7 +612,8 @@@ macro_rules! options 
  
      #[allow(dead_code)]
      mod $mod_set {
 -        use super::{$struct_name, Passes, SomePasses, AllPasses, PanicStrategy};
 +        use super::{$struct_name, Passes, SomePasses, AllPasses};
 +        use rustc_back::PanicStrategy;
  
          $(
              pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
              }
          }
  
 -        fn parse_panic_strategy(slot: &mut PanicStrategy, v: Option<&str>) -> bool {
 +        fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
              match v {
 -                Some("unwind") => *slot = PanicStrategy::Unwind,
 -                Some("abort") => *slot = PanicStrategy::Abort,
 +                Some("unwind") => *slot = Some(PanicStrategy::Unwind),
 +                Some("abort") => *slot = Some(PanicStrategy::Abort),
                  _ => return false
              }
              true
@@@ -796,7 -815,7 +802,7 @@@ options! {CodegenOptions, CodegenSetter
          "explicitly enable the cfg(debug_assertions) directive"),
      inline_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
          "set the inlining threshold for"),
 -    panic: PanicStrategy = (PanicStrategy::Unwind, parse_panic_strategy,
 +    panic: Option<PanicStrategy> = (None, parse_panic_strategy,
          [TRACKED], "panic strategy to compile crate with"),
  }
  
@@@ -1523,6 -1542,7 +1529,7 @@@ pub fn build_session_options_and_crate_
          libs: libs,
          unstable_features: UnstableFeatures::from_environment(),
          debug_assertions: debug_assertions,
+         actually_rustdoc: false,
      },
      cfg)
  }
@@@ -1652,10 -1672,9 +1659,10 @@@ mod dep_tracking 
      use std::collections::BTreeMap;
      use std::hash::{Hash, SipHasher};
      use std::path::PathBuf;
 -    use super::{Passes, PanicStrategy, CrateType, OptLevel, DebugInfoLevel,
 +    use super::{Passes, CrateType, OptLevel, DebugInfoLevel,
                  OutputTypes, Externs, ErrorOutputType};
      use syntax::feature_gate::UnstableFeatures;
 +    use rustc_back::PanicStrategy;
  
      pub trait DepTrackingHash {
          fn hash(&self, &mut SipHasher, ErrorOutputType);
      impl_dep_tracking_hash_via_hash!(Option<bool>);
      impl_dep_tracking_hash_via_hash!(Option<usize>);
      impl_dep_tracking_hash_via_hash!(Option<String>);
 +    impl_dep_tracking_hash_via_hash!(Option<PanicStrategy>);
      impl_dep_tracking_hash_via_hash!(Option<lint::Level>);
      impl_dep_tracking_hash_via_hash!(Option<PathBuf>);
      impl_dep_tracking_hash_via_hash!(CrateType);
@@@ -1761,8 -1779,7 +1768,8 @@@ mod tests 
      use std::iter::FromIterator;
      use std::path::PathBuf;
      use std::rc::Rc;
 -    use super::{OutputType, OutputTypes, Externs, PanicStrategy};
 +    use super::{OutputType, OutputTypes, Externs};
 +    use rustc_back::PanicStrategy;
      use syntax::{ast, attr};
      use syntax::parse::token::InternedString;
      use syntax::codemap::dummy_spanned;
          assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
  
          opts = reference.clone();
 -        opts.cg.panic = PanicStrategy::Abort;
 +        opts.cg.panic = Some(PanicStrategy::Abort);
          assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
      }