diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 23cc22c5cb3ae..385376333c1d7 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -338,7 +338,6 @@ pub fn docs(build: &Build, compiler: &Compiler) { continue } - println!("doc tests for: {}", p.display()); markdown_test(build, compiler, &p); } } @@ -375,6 +374,7 @@ fn markdown_test(build: &Build, compiler: &Compiler, markdown: &Path) { return; } + println!("doc tests for: {}", markdown.display()); let mut cmd = Command::new(build.rustdoc(compiler)); build.add_rustc_lib_path(compiler, &mut cmd); build.add_rust_test_threads(&mut cmd); diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 9946c93913fe7..9a07e8a8b1091 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -276,6 +276,10 @@ pub fn rustc(build: &Build, target: &str, compiler: &Compiler) { if build.is_rust_llvm(target) { cargo.env("LLVM_RUSTLLVM", "1"); } + if let Some(ref cfg_file) = build.flags.config { + let cfg_path = t!(PathBuf::from(cfg_file).canonicalize()); + cargo.env("CFG_LLVM_TOML", cfg_path.into_os_string()); + } cargo.env("LLVM_CONFIG", build.llvm_config(target)); let target_config = build.config.target_config.get(target); if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) { diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index bf4e414d41684..99000a031feab 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -35,6 +35,8 @@ macro_rules! panic { /// This will invoke the [`panic!`] macro if the provided expression cannot be /// evaluated to `true` at runtime. /// +/// # Uses +/// /// Assertions are always checked in both debug and release builds, and cannot /// be disabled. See [`debug_assert!`] for assertions that are not enabled in /// release builds by default. @@ -45,7 +47,9 @@ macro_rules! panic { /// Other use-cases of `assert!` include [testing] and enforcing run-time /// invariants in safe code (whose violation cannot result in unsafety). /// -/// This macro has a second version, where a custom panic message can +/// # Custom Messages +/// +/// This macro has a second form, where a custom panic message can /// be provided with or without arguments for formatting. /// /// [`panic!`]: macro.panic.html @@ -85,14 +89,15 @@ macro_rules! assert { ); } -/// Asserts that two expressions are equal to each other. +/// Asserts that two expressions are equal to each other (using [`PartialEq`]). /// /// On panic, this macro will print the values of the expressions with their /// debug representations. /// -/// Like [`assert!`], this macro has a second version, where a custom +/// Like [`assert!`], this macro has a second form, where a custom /// panic message can be provided. /// +/// [`PartialEq`]: cmp/trait.PartialEq.html /// [`assert!`]: macro.assert.html /// /// # Examples @@ -130,14 +135,15 @@ macro_rules! assert_eq { }); } -/// Asserts that two expressions are not equal to each other. +/// Asserts that two expressions are not equal to each other (using [`PartialEq`]). /// /// On panic, this macro will print the values of the expressions with their /// debug representations. /// -/// Like `assert!()`, this macro has a second version, where a custom +/// Like [`assert!`], this macro has a second form, where a custom /// panic message can be provided. /// +/// [`PartialEq`]: cmp/trait.PartialEq.html /// [`assert!`]: macro.assert.html /// /// # Examples @@ -183,6 +189,8 @@ macro_rules! assert_ne { /// Like [`assert!`], this macro also has a second version, where a custom panic /// message can be provided. /// +/// # Uses +/// /// Unlike [`assert!`], `debug_assert!` statements are only enabled in non /// optimized builds by default. An optimized build will omit all /// `debug_assert!` statements unless `-C debug-assertions` is passed to the diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 6602fccd58982..05df84708e05d 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -205,7 +205,7 @@ pub trait Unsize { /// but not `Copy`. /// /// [`Clone`] is a supertrait of `Copy`, so everything which is `Copy` must also implement -/// [`Clone`]. If a type is `Copy` then its [`Clone`] implementation need only return `*self` +/// [`Clone`]. If a type is `Copy` then its [`Clone`] implementation only needs to return `*self` /// (see the example above). /// /// ## When can my type be `Copy`? diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs index feded417ce17f..c500d770cef05 100644 --- a/src/librustc/hir/def.rs +++ b/src/librustc/hir/def.rs @@ -17,11 +17,11 @@ use hir; #[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum CtorKind { - // Constructor function automatically created by a tuple struct/variant. + /// Constructor function automatically created by a tuple struct/variant. Fn, - // Constructor constant automatically created by a unit struct/variant. + /// Constructor constant automatically created by a unit struct/variant. Const, - // Unusable name in value namespace created by a struct variant. + /// Unusable name in value namespace created by a struct variant. Fictive, } @@ -109,17 +109,21 @@ impl PathResolution { } } -// Definition mapping +/// Definition mapping pub type DefMap = NodeMap; -// This is the replacement export map. It maps a module to all of the exports -// within. + +/// This is the replacement export map. It maps a module to all of the exports +/// within. pub type ExportMap = NodeMap>; #[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)] pub struct Export { - pub ident: ast::Ident, // The name of the target. - pub def: Def, // The definition of the target. - pub span: Span, // The span of the target definition. + /// The name of the target. + pub ident: ast::Ident, + /// The definition of the target. + pub def: Def, + /// The span of the target definition. + pub span: Span, } impl CtorKind { @@ -160,6 +164,7 @@ impl Def { } } + /// A human readable kind name pub fn kind_name(&self) -> &'static str { match *self { Def::Fn(..) => "function", diff --git a/src/librustc/hir/def_id.rs b/src/librustc/hir/def_id.rs index 47604b961ae4a..ce2baa738975b 100644 --- a/src/librustc/hir/def_id.rs +++ b/src/librustc/hir/def_id.rs @@ -187,6 +187,7 @@ impl fmt::Debug for DefId { impl DefId { + /// Make a local `DefId` with the given index. pub fn local(index: DefIndex) -> DefId { DefId { krate: LOCAL_CRATE, index: index } } diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 4c436fb640f01..a6ab67e04693d 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -8,37 +8,37 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Lowers the AST to the HIR. -// -// Since the AST and HIR are fairly similar, this is mostly a simple procedure, -// much like a fold. Where lowering involves a bit more work things get more -// interesting and there are some invariants you should know about. These mostly -// concern spans and ids. -// -// Spans are assigned to AST nodes during parsing and then are modified during -// expansion to indicate the origin of a node and the process it went through -// being expanded. Ids are assigned to AST nodes just before lowering. -// -// For the simpler lowering steps, ids and spans should be preserved. Unlike -// expansion we do not preserve the process of lowering in the spans, so spans -// should not be modified here. When creating a new node (as opposed to -// 'folding' an existing one), then you create a new id using `next_id()`. -// -// You must ensure that ids are unique. That means that you should only use the -// id from an AST node in a single HIR node (you can assume that AST node ids -// are unique). Every new node must have a unique id. Avoid cloning HIR nodes. -// If you do, you must then set the new node's id to a fresh one. -// -// Spans are used for error messages and for tools to map semantics back to -// source code. It is therefore not as important with spans as ids to be strict -// about use (you can't break the compiler by screwing up a span). Obviously, a -// HIR node can only have a single span. But multiple nodes can have the same -// span and spans don't need to be kept in order, etc. Where code is preserved -// by lowering, it should have the same span as in the AST. Where HIR nodes are -// new it is probably best to give a span for the whole AST node being lowered. -// All nodes should have real spans, don't use dummy spans. Tools are likely to -// get confused if the spans from leaf AST nodes occur in multiple places -// in the HIR, especially for multiple identifiers. +//! Lowers the AST to the HIR. +//! +//! Since the AST and HIR are fairly similar, this is mostly a simple procedure, +//! much like a fold. Where lowering involves a bit more work things get more +//! interesting and there are some invariants you should know about. These mostly +//! concern spans and ids. +//! +//! Spans are assigned to AST nodes during parsing and then are modified during +//! expansion to indicate the origin of a node and the process it went through +//! being expanded. Ids are assigned to AST nodes just before lowering. +//! +//! For the simpler lowering steps, ids and spans should be preserved. Unlike +//! expansion we do not preserve the process of lowering in the spans, so spans +//! should not be modified here. When creating a new node (as opposed to +//! 'folding' an existing one), then you create a new id using `next_id()`. +//! +//! You must ensure that ids are unique. That means that you should only use the +//! id from an AST node in a single HIR node (you can assume that AST node ids +//! are unique). Every new node must have a unique id. Avoid cloning HIR nodes. +//! If you do, you must then set the new node's id to a fresh one. +//! +//! Spans are used for error messages and for tools to map semantics back to +//! source code. It is therefore not as important with spans as ids to be strict +//! about use (you can't break the compiler by screwing up a span). Obviously, a +//! HIR node can only have a single span. But multiple nodes can have the same +//! span and spans don't need to be kept in order, etc. Where code is preserved +//! by lowering, it should have the same span as in the AST. Where HIR nodes are +//! new it is probably best to give a span for the whole AST node being lowered. +//! All nodes should have real spans, don't use dummy spans. Tools are likely to +//! get confused if the spans from leaf AST nodes occur in multiple places +//! in the HIR, especially for multiple identifiers. use hir; use hir::map::{Definitions, DefKey, REGULAR_SPACE}; @@ -70,8 +70,10 @@ const HIR_ID_COUNTER_LOCKED: u32 = 0xFFFFFFFF; pub struct LoweringContext<'a> { crate_root: Option<&'static str>, + // Use to assign ids to hir nodes that do not directly correspond to an ast node sess: &'a Session, + // As we walk the AST we must keep track of the current 'parent' def id (in // the form of a DefIndex) so that if we create a new node which introduces // a definition, then we can properly create the def id. @@ -102,14 +104,14 @@ pub struct LoweringContext<'a> { } pub trait Resolver { - // Resolve a hir path generated by the lowerer when expanding `for`, `if let`, etc. + /// Resolve a hir path generated by the lowerer when expanding `for`, `if let`, etc. fn resolve_hir_path(&mut self, path: &mut hir::Path, is_value: bool); - // Obtain the resolution for a node id + /// Obtain the resolution for a node id fn get_resolution(&mut self, id: NodeId) -> Option; - // We must keep the set of definitions up to date as we add nodes that weren't in the AST. - // This should only return `None` during testing. + /// We must keep the set of definitions up to date as we add nodes that weren't in the AST. + /// This should only return `None` during testing. fn definitions(&mut self) -> &mut Definitions; } diff --git a/src/librustc/infer/region_inference/graphviz.rs b/src/librustc/infer/region_inference/graphviz.rs index cce253c1a1a43..81a8984e7530e 100644 --- a/src/librustc/infer/region_inference/graphviz.rs +++ b/src/librustc/infer/region_inference/graphviz.rs @@ -133,7 +133,6 @@ enum Node { Region(ty::RegionKind), } -// type Edge = Constraint; #[derive(Clone, PartialEq, Eq, Debug, Copy)] enum Edge<'tcx> { Constraint(Constraint<'tcx>), diff --git a/src/librustc/infer/region_inference/mod.rs b/src/librustc/infer/region_inference/mod.rs index acc1a397b4560..f62470fab723e 100644 --- a/src/librustc/infer/region_inference/mod.rs +++ b/src/librustc/infer/region_inference/mod.rs @@ -35,31 +35,31 @@ use std::u32; mod graphviz; -// A constraint that influences the inference process. +/// A constraint that influences the inference process. #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] pub enum Constraint<'tcx> { - // One region variable is subregion of another + /// One region variable is subregion of another ConstrainVarSubVar(RegionVid, RegionVid), - // Concrete region is subregion of region variable + /// Concrete region is subregion of region variable ConstrainRegSubVar(Region<'tcx>, RegionVid), - // Region variable is subregion of concrete region. This does not - // directly affect inference, but instead is checked after - // inference is complete. + /// Region variable is subregion of concrete region. This does not + /// directly affect inference, but instead is checked after + /// inference is complete. ConstrainVarSubReg(RegionVid, Region<'tcx>), - // A constraint where neither side is a variable. This does not - // directly affect inference, but instead is checked after - // inference is complete. + /// A constraint where neither side is a variable. This does not + /// directly affect inference, but instead is checked after + /// inference is complete. ConstrainRegSubReg(Region<'tcx>, Region<'tcx>), } -// VerifyGenericBound(T, _, R, RS): The parameter type `T` (or -// associated type) must outlive the region `R`. `T` is known to -// outlive `RS`. Therefore verify that `R <= RS[i]` for some -// `i`. Inference variables may be involved (but this verification -// step doesn't influence inference). +/// VerifyGenericBound(T, _, R, RS): The parameter type `T` (or +/// associated type) must outlive the region `R`. `T` is known to +/// outlive `RS`. Therefore verify that `R <= RS[i]` for some +/// `i`. Inference variables may be involved (but this verification +/// step doesn't influence inference). #[derive(Debug)] pub struct Verify<'tcx> { kind: GenericKind<'tcx>, @@ -74,29 +74,29 @@ pub enum GenericKind<'tcx> { Projection(ty::ProjectionTy<'tcx>), } -// When we introduce a verification step, we wish to test that a -// particular region (let's call it `'min`) meets some bound. -// The bound is described the by the following grammar: +/// When we introduce a verification step, we wish to test that a +/// particular region (let's call it `'min`) meets some bound. +/// The bound is described the by the following grammar: #[derive(Debug)] pub enum VerifyBound<'tcx> { - // B = exists {R} --> some 'r in {R} must outlive 'min - // - // Put another way, the subject value is known to outlive all - // regions in {R}, so if any of those outlives 'min, then the - // bound is met. + /// B = exists {R} --> some 'r in {R} must outlive 'min + /// + /// Put another way, the subject value is known to outlive all + /// regions in {R}, so if any of those outlives 'min, then the + /// bound is met. AnyRegion(Vec>), - // B = forall {R} --> all 'r in {R} must outlive 'min - // - // Put another way, the subject value is known to outlive some - // region in {R}, so if all of those outlives 'min, then the bound - // is met. + /// B = forall {R} --> all 'r in {R} must outlive 'min + /// + /// Put another way, the subject value is known to outlive some + /// region in {R}, so if all of those outlives 'min, then the bound + /// is met. AllRegions(Vec>), - // B = exists {B} --> 'min must meet some bound b in {B} + /// B = exists {B} --> 'min must meet some bound b in {B} AnyBound(Vec>), - // B = forall {B} --> 'min must meet all bounds b in {B} + /// B = forall {B} --> 'min must meet all bounds b in {B} AllBounds(Vec>), } @@ -183,35 +183,35 @@ pub struct RegionVarBindings<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { tcx: TyCtxt<'a, 'gcx, 'tcx>, var_origins: RefCell>, - // Constraints of the form `A <= B` introduced by the region - // checker. Here at least one of `A` and `B` must be a region - // variable. + /// Constraints of the form `A <= B` introduced by the region + /// checker. Here at least one of `A` and `B` must be a region + /// variable. constraints: RefCell, SubregionOrigin<'tcx>>>, - // A "verify" is something that we need to verify after inference is - // done, but which does not directly affect inference in any way. - // - // An example is a `A <= B` where neither `A` nor `B` are - // inference variables. + /// A "verify" is something that we need to verify after inference is + /// done, but which does not directly affect inference in any way. + /// + /// An example is a `A <= B` where neither `A` nor `B` are + /// inference variables. verifys: RefCell>>, - // A "given" is a relationship that is known to hold. In particular, - // we often know from closure fn signatures that a particular free - // region must be a subregion of a region variable: - // - // foo.iter().filter(<'a> |x: &'a &'b T| ...) - // - // In situations like this, `'b` is in fact a region variable - // introduced by the call to `iter()`, and `'a` is a bound region - // on the closure (as indicated by the `<'a>` prefix). If we are - // naive, we wind up inferring that `'b` must be `'static`, - // because we require that it be greater than `'a` and we do not - // know what `'a` is precisely. - // - // This hashmap is used to avoid that naive scenario. Basically we - // record the fact that `'a <= 'b` is implied by the fn signature, - // and then ignore the constraint when solving equations. This is - // a bit of a hack but seems to work. + /// A "given" is a relationship that is known to hold. In particular, + /// we often know from closure fn signatures that a particular free + /// region must be a subregion of a region variable: + /// + /// foo.iter().filter(<'a> |x: &'a &'b T| ...) + /// + /// In situations like this, `'b` is in fact a region variable + /// introduced by the call to `iter()`, and `'a` is a bound region + /// on the closure (as indicated by the `<'a>` prefix). If we are + /// naive, we wind up inferring that `'b` must be `'static`, + /// because we require that it be greater than `'a` and we do not + /// know what `'a` is precisely. + /// + /// This hashmap is used to avoid that naive scenario. Basically we + /// record the fact that `'a <= 'b` is implied by the fn signature, + /// and then ignore the constraint when solving equations. This is + /// a bit of a hack but seems to work. givens: RefCell, ty::RegionVid)>>, lubs: RefCell>, @@ -219,20 +219,21 @@ pub struct RegionVarBindings<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { skolemization_count: Cell, bound_count: Cell, - // The undo log records actions that might later be undone. - // - // Note: when the undo_log is empty, we are not actively - // snapshotting. When the `start_snapshot()` method is called, we - // push an OpenSnapshot entry onto the list to indicate that we - // are now actively snapshotting. The reason for this is that - // otherwise we end up adding entries for things like the lower - // bound on a variable and so forth, which can never be rolled - // back. + /// The undo log records actions that might later be undone. + /// + /// Note: when the undo_log is empty, we are not actively + /// snapshotting. When the `start_snapshot()` method is called, we + /// push an OpenSnapshot entry onto the list to indicate that we + /// are now actively snapshotting. The reason for this is that + /// otherwise we end up adding entries for things like the lower + /// bound on a variable and so forth, which can never be rolled + /// back. undo_log: RefCell>>, + unification_table: RefCell>, - // This contains the results of inference. It begins as an empty - // option and only acquires a value after inference is complete. + /// This contains the results of inference. It begins as an empty + /// option and only acquires a value after inference is complete. values: RefCell>>>, } diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 1a07423bcbc0f..ce5d58f5800c7 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -1363,7 +1363,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { m.push_str(&(if n == 1 { help_name } else { - format!("one of {}'s {} elided {}lifetimes", help_name, n, + format!("one of {}'s {} {}lifetimes", help_name, n, if have_bound_regions { "free " } else { "" } ) })[..]); diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index ba568857959f8..bdfc0a2fe855c 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -61,6 +61,11 @@ fn main() { println!("cargo:rerun-if-changed={}", llvm_config.display()); + if let Some(cfg_toml) = env::var_os("CFG_LLVM_TOML") { + let cfg_path = PathBuf::from(cfg_toml); + println!("cargo:rerun-if-changed={}", cfg_path.display()); + } + // Test whether we're cross-compiling LLVM. This is a pretty rare case // currently where we're producing an LLVM for a different platform than // what this build script is currently running on. diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 73c0256f2c1f5..6b5caff27e8f0 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -81,6 +81,7 @@ pub struct Symbol(u32); // The interner in thread-local, so `Symbol` shouldn't move between threads. impl !Send for Symbol { } +impl !Sync for Symbol { } impl Symbol { /// Maps a string to its interned representation. diff --git a/src/test/compile-fail/issue-26638.rs b/src/test/compile-fail/issue-26638.rs index f918f0aed7a10..9b8c7b250763e 100644 --- a/src/test/compile-fail/issue-26638.rs +++ b/src/test/compile-fail/issue-26638.rs @@ -10,7 +10,7 @@ fn parse_type(iter: Box+'static>) -> &str { iter.next() } //~^ ERROR missing lifetime specifier [E0106] -//~^^ HELP 2 elided lifetimes +//~^^ HELP 2 lifetimes fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } //~^ ERROR missing lifetime specifier [E0106] diff --git a/src/test/compile-fail/issue-30255.rs b/src/test/compile-fail/issue-30255.rs index 1daa6a61f777c..e3f55ae51e8b6 100644 --- a/src/test/compile-fail/issue-30255.rs +++ b/src/test/compile-fail/issue-30255.rs @@ -17,19 +17,19 @@ struct S<'a> { fn f(a: &S, b: i32) -> &i32 { //~^ ERROR missing lifetime specifier [E0106] -//~^^ HELP does not say which one of `a`'s 2 elided lifetimes it is borrowed from +//~^^ HELP does not say which one of `a`'s 2 lifetimes it is borrowed from panic!(); } fn g(a: &S, b: bool, c: &i32) -> &i32 { //~^ ERROR missing lifetime specifier [E0106] -//~^^ HELP does not say whether it is borrowed from one of `a`'s 2 elided lifetimes or `c` +//~^^ HELP does not say whether it is borrowed from one of `a`'s 2 lifetimes or `c` panic!(); } fn h(a: &bool, b: bool, c: &S, d: &i32) -> &i32 { //~^ ERROR missing lifetime specifier [E0106] -//~^^ HELP does not say whether it is borrowed from `a`, one of `c`'s 2 elided lifetimes, or `d` +//~^^ HELP does not say whether it is borrowed from `a`, one of `c`'s 2 lifetimes, or `d` panic!(); } diff --git a/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs b/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs index 43371eb6340f4..2d9de57a2659f 100644 --- a/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs +++ b/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs @@ -28,7 +28,7 @@ struct Foo<'a> { // Lifetime annotation needed because we have two lifetimes: one as a parameter // and one on the reference. fn h(_x: &Foo) -> &isize { //~ ERROR missing lifetime specifier -//~^ HELP the signature does not say which one of `_x`'s 2 elided lifetimes it is borrowed from +//~^ HELP the signature does not say which one of `_x`'s 2 lifetimes it is borrowed from panic!() }