From ef275d1c10f9824845455744850f2a9784a86429 Mon Sep 17 00:00:00 2001 From: gaurikholkar Date: Tue, 14 Nov 2017 20:58:38 +0530 Subject: [PATCH 01/18] update let-expressions to use except --- .../incremental/hashes/let_expressions.rs | 246 +++--------------- 1 file changed, 36 insertions(+), 210 deletions(-) diff --git a/src/test/incremental/hashes/let_expressions.rs b/src/test/incremental/hashes/let_expressions.rs index d46fbd367607c..dd8bd8fcff24c 100644 --- a/src/test/incremental/hashes/let_expressions.rs +++ b/src/test/incremental/hashes/let_expressions.rs @@ -32,26 +32,9 @@ pub fn change_name() { } #[cfg(not(cfail1))] -#[rustc_clean(label="Hir", cfg="cfail2")] -#[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_dirty(label="HirBody", cfg="cfail2")] -#[rustc_clean(label="HirBody", cfg="cfail3")] -#[rustc_metadata_clean(cfg="cfail2")] -#[rustc_metadata_clean(cfg="cfail3")] -#[rustc_dirty(label="MirValidated", cfg="cfail2")] -#[rustc_clean(label="MirValidated", cfg="cfail3")] -#[rustc_dirty(label="MirOptimized", cfg="cfail2")] -#[rustc_clean(label="MirOptimized", cfg="cfail3")] -#[rustc_clean(label="TypeckTables", cfg="cfail2")] -#[rustc_clean(label="TypeckTables", cfg="cfail3")] -#[rustc_clean(label="TypeOfItem", cfg="cfail2")] -#[rustc_clean(label="TypeOfItem", cfg="cfail3")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail2")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail3")] -#[rustc_clean(label="FnSignature", cfg="cfail2")] -#[rustc_clean(label="FnSignature", cfg="cfail3")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail2")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail3")] +#[rustc_clean(cfg="cfail2", + except="HirBody,MirValidated,MirOptimized")] +#[rustc_clean(cfg="cfail3")] pub fn change_name() { let _y = 2u64; } @@ -65,26 +48,11 @@ pub fn add_type() { } #[cfg(not(cfail1))] -#[rustc_clean(label="Hir", cfg="cfail2")] -#[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_dirty(label="HirBody", cfg="cfail2")] -#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_clean(cfg="cfail2", + except="HirBody,TypeckTables")] +#[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[rustc_clean(label="MirValidated", cfg="cfail2")] -#[rustc_clean(label="MirValidated", cfg="cfail3")] -#[rustc_clean(label="MirOptimized", cfg="cfail2")] -#[rustc_clean(label="MirOptimized", cfg="cfail3")] -#[rustc_dirty(label="TypeckTables", cfg="cfail2")] -#[rustc_clean(label="TypeckTables", cfg="cfail3")] -#[rustc_clean(label="TypeOfItem", cfg="cfail2")] -#[rustc_clean(label="TypeOfItem", cfg="cfail3")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail2")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail3")] -#[rustc_clean(label="FnSignature", cfg="cfail2")] -#[rustc_clean(label="FnSignature", cfg="cfail3")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail2")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail3")] pub fn add_type() { let _x: u32 = 2u32; } @@ -98,26 +66,11 @@ pub fn change_type() { } #[cfg(not(cfail1))] -#[rustc_clean(label="Hir", cfg="cfail2")] -#[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_dirty(label="HirBody", cfg="cfail2")] -#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_clean(cfg="cfail2", + except="HirBody,TypeckTables,MirValidated,MirOptimized")] +#[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[rustc_dirty(label="MirValidated", cfg="cfail2")] -#[rustc_clean(label="MirValidated", cfg="cfail3")] -#[rustc_dirty(label="MirOptimized", cfg="cfail2")] -#[rustc_clean(label="MirOptimized", cfg="cfail3")] -#[rustc_dirty(label="TypeckTables", cfg="cfail2")] -#[rustc_clean(label="TypeckTables", cfg="cfail3")] -#[rustc_clean(label="TypeOfItem", cfg="cfail2")] -#[rustc_clean(label="TypeOfItem", cfg="cfail3")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail2")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail3")] -#[rustc_clean(label="FnSignature", cfg="cfail2")] -#[rustc_clean(label="FnSignature", cfg="cfail3")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail2")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail3")] pub fn change_type() { let _x: u8 = 2; } @@ -131,26 +84,11 @@ pub fn change_mutability_of_reference_type() { } #[cfg(not(cfail1))] -#[rustc_clean(label="Hir", cfg="cfail2")] -#[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_dirty(label="HirBody", cfg="cfail2")] -#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_clean(cfg="cfail2", + except="HirBody,TypeckTables,MirValidated")] +#[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[rustc_dirty(label="MirValidated", cfg="cfail2")] -#[rustc_clean(label="MirValidated", cfg="cfail3")] -#[rustc_clean(label="MirOptimized", cfg="cfail2")] -#[rustc_clean(label="MirOptimized", cfg="cfail3")] -#[rustc_dirty(label="TypeckTables", cfg="cfail2")] -#[rustc_clean(label="TypeckTables", cfg="cfail3")] -#[rustc_clean(label="TypeOfItem", cfg="cfail2")] -#[rustc_clean(label="TypeOfItem", cfg="cfail3")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail2")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail3")] -#[rustc_clean(label="FnSignature", cfg="cfail2")] -#[rustc_clean(label="FnSignature", cfg="cfail3")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail2")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail3")] pub fn change_mutability_of_reference_type() { let _x: &mut u64; } @@ -164,26 +102,11 @@ pub fn change_mutability_of_slot() { } #[cfg(not(cfail1))] -#[rustc_clean(label="Hir", cfg="cfail2")] -#[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_dirty(label="HirBody", cfg="cfail2")] -#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_clean(cfg="cfail2", + except="HirBody,TypeckTables,MirValidated,MirOptimized")] +#[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[rustc_dirty(label="MirValidated", cfg="cfail2")] -#[rustc_clean(label="MirValidated", cfg="cfail3")] -#[rustc_dirty(label="MirOptimized", cfg="cfail2")] -#[rustc_clean(label="MirOptimized", cfg="cfail3")] -#[rustc_dirty(label="TypeckTables", cfg="cfail2")] -#[rustc_clean(label="TypeckTables", cfg="cfail3")] -#[rustc_clean(label="TypeOfItem", cfg="cfail2")] -#[rustc_clean(label="TypeOfItem", cfg="cfail3")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail2")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail3")] -#[rustc_clean(label="FnSignature", cfg="cfail2")] -#[rustc_clean(label="FnSignature", cfg="cfail3")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail2")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail3")] pub fn change_mutability_of_slot() { let _x: u64 = 0; } @@ -197,26 +120,11 @@ pub fn change_simple_binding_to_pattern() { } #[cfg(not(cfail1))] -#[rustc_clean(label="Hir", cfg="cfail2")] -#[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_dirty(label="HirBody", cfg="cfail2")] -#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_clean(cfg="cfail2", + except="HirBody,TypeckTables,MirValidated,MirOptimized")] +#[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[rustc_dirty(label="MirValidated", cfg="cfail2")] -#[rustc_clean(label="MirValidated", cfg="cfail3")] -#[rustc_dirty(label="MirOptimized", cfg="cfail2")] -#[rustc_clean(label="MirOptimized", cfg="cfail3")] -#[rustc_dirty(label="TypeckTables", cfg="cfail2")] -#[rustc_clean(label="TypeckTables", cfg="cfail3")] -#[rustc_clean(label="TypeOfItem", cfg="cfail2")] -#[rustc_clean(label="TypeOfItem", cfg="cfail3")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail2")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail3")] -#[rustc_clean(label="FnSignature", cfg="cfail2")] -#[rustc_clean(label="FnSignature", cfg="cfail3")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail2")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail3")] pub fn change_simple_binding_to_pattern() { let (_a, _b) = (0u8, 'x'); } @@ -230,26 +138,11 @@ pub fn change_name_in_pattern() { } #[cfg(not(cfail1))] -#[rustc_clean(label="Hir", cfg="cfail2")] -#[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_dirty(label="HirBody", cfg="cfail2")] -#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_clean(cfg="cfail2", + except="HirBody,MirValidated,MirOptimized")] +#[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[rustc_dirty(label="MirValidated", cfg="cfail2")] -#[rustc_clean(label="MirValidated", cfg="cfail3")] -#[rustc_dirty(label="MirOptimized", cfg="cfail2")] -#[rustc_clean(label="MirOptimized", cfg="cfail3")] -#[rustc_clean(label="TypeckTables", cfg="cfail2")] -#[rustc_clean(label="TypeckTables", cfg="cfail3")] -#[rustc_clean(label="TypeOfItem", cfg="cfail2")] -#[rustc_clean(label="TypeOfItem", cfg="cfail3")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail2")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail3")] -#[rustc_clean(label="FnSignature", cfg="cfail2")] -#[rustc_clean(label="FnSignature", cfg="cfail3")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail2")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail3")] pub fn change_name_in_pattern() { let (_a, _c) = (1u8, 'y'); } @@ -263,26 +156,11 @@ pub fn add_ref_in_pattern() { } #[cfg(not(cfail1))] -#[rustc_clean(label="Hir", cfg="cfail2")] -#[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_dirty(label="HirBody", cfg="cfail2")] -#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_clean(cfg="cfail2", + except="HirBody,TypeckTables,MirValidated,MirOptimized")] +#[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[rustc_dirty(label="MirValidated", cfg="cfail2")] -#[rustc_clean(label="MirValidated", cfg="cfail3")] -#[rustc_dirty(label="MirOptimized", cfg="cfail2")] -#[rustc_clean(label="MirOptimized", cfg="cfail3")] -#[rustc_dirty(label="TypeckTables", cfg="cfail2")] -#[rustc_clean(label="TypeckTables", cfg="cfail3")] -#[rustc_clean(label="TypeOfItem", cfg="cfail2")] -#[rustc_clean(label="TypeOfItem", cfg="cfail3")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail2")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail3")] -#[rustc_clean(label="FnSignature", cfg="cfail2")] -#[rustc_clean(label="FnSignature", cfg="cfail3")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail2")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail3")] pub fn add_ref_in_pattern() { let (ref _a, _b) = (1u8, 'y'); } @@ -296,18 +174,11 @@ pub fn add_amp_in_pattern() { } #[cfg(not(cfail1))] -#[rustc_clean(label="Hir", cfg="cfail2")] -#[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_dirty(label="HirBody", cfg="cfail2")] -#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_clean(cfg="cfail2", + except="HirBody,TypeckTables,MirValidated,MirOptimized")] +#[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[rustc_dirty(label="MirValidated", cfg="cfail2")] -#[rustc_clean(label="MirValidated", cfg="cfail3")] -#[rustc_dirty(label="MirOptimized", cfg="cfail2")] -#[rustc_clean(label="MirOptimized", cfg="cfail3")] -#[rustc_dirty(label="TypeckTables", cfg="cfail2")] -#[rustc_clean(label="TypeckTables", cfg="cfail3")] pub fn add_amp_in_pattern() { let (&_a, _b) = (&1u8, 'y'); } @@ -321,26 +192,11 @@ pub fn change_mutability_of_binding_in_pattern() { } #[cfg(not(cfail1))] -#[rustc_clean(label="Hir", cfg="cfail2")] -#[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_dirty(label="HirBody", cfg="cfail2")] -#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_clean(cfg="cfail2", + except="HirBody,TypeckTables,MirValidated,MirOptimized")] +#[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[rustc_dirty(label="MirValidated", cfg="cfail2")] -#[rustc_clean(label="MirValidated", cfg="cfail3")] -#[rustc_dirty(label="MirOptimized", cfg="cfail2")] -#[rustc_clean(label="MirOptimized", cfg="cfail3")] -#[rustc_dirty(label="TypeckTables", cfg="cfail2")] -#[rustc_clean(label="TypeckTables", cfg="cfail3")] -#[rustc_clean(label="TypeOfItem", cfg="cfail2")] -#[rustc_clean(label="TypeOfItem", cfg="cfail3")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail2")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail3")] -#[rustc_clean(label="FnSignature", cfg="cfail2")] -#[rustc_clean(label="FnSignature", cfg="cfail3")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail2")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail3")] pub fn change_mutability_of_binding_in_pattern() { let (mut _a, _b) = (99u8, 'q'); } @@ -354,26 +210,11 @@ pub fn add_initializer() { } #[cfg(not(cfail1))] -#[rustc_clean(label="Hir", cfg="cfail2")] -#[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_dirty(label="HirBody", cfg="cfail2")] -#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_clean(cfg="cfail2", + except="HirBody,TypeckTables,MirValidated,MirOptimized")] +#[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[rustc_dirty(label="MirValidated", cfg="cfail2")] -#[rustc_clean(label="MirValidated", cfg="cfail3")] -#[rustc_dirty(label="MirOptimized", cfg="cfail2")] -#[rustc_clean(label="MirOptimized", cfg="cfail3")] -#[rustc_dirty(label="TypeckTables", cfg="cfail2")] -#[rustc_clean(label="TypeckTables", cfg="cfail3")] -#[rustc_clean(label="TypeOfItem", cfg="cfail2")] -#[rustc_clean(label="TypeOfItem", cfg="cfail3")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail2")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail3")] -#[rustc_clean(label="FnSignature", cfg="cfail2")] -#[rustc_clean(label="FnSignature", cfg="cfail3")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail2")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail3")] pub fn add_initializer() { let _x: i16 = 3i16; } @@ -387,26 +228,11 @@ pub fn change_initializer() { } #[cfg(not(cfail1))] -#[rustc_clean(label="Hir", cfg="cfail2")] -#[rustc_clean(label="Hir", cfg="cfail3")] -#[rustc_dirty(label="HirBody", cfg="cfail2")] -#[rustc_clean(label="HirBody", cfg="cfail3")] +#[rustc_clean(cfg="cfail2", + except="HirBody,MirValidated,MirOptimized")] +#[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[rustc_dirty(label="MirValidated", cfg="cfail2")] -#[rustc_clean(label="MirValidated", cfg="cfail3")] -#[rustc_dirty(label="MirOptimized", cfg="cfail2")] -#[rustc_clean(label="MirOptimized", cfg="cfail3")] -#[rustc_clean(label="TypeckTables", cfg="cfail2")] -#[rustc_clean(label="TypeckTables", cfg="cfail3")] -#[rustc_clean(label="TypeOfItem", cfg="cfail2")] -#[rustc_clean(label="TypeOfItem", cfg="cfail3")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail2")] -#[rustc_clean(label="GenericsOfItem", cfg="cfail3")] -#[rustc_clean(label="FnSignature", cfg="cfail2")] -#[rustc_clean(label="FnSignature", cfg="cfail3")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail2")] -#[rustc_clean(label="PredicatesOfItem", cfg="cfail3")] pub fn change_initializer() { let _x = 5u16; } From 8cd573550353427a8a66b6ddd676cb5731d4620e Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Wed, 15 Nov 2017 11:17:39 +0100 Subject: [PATCH 02/18] rustbuild: use a macro to define "extended" tools Signed-off-by: Marc-Antoine Perennou --- src/bootstrap/tool.rs | 185 ++++++++++++------------------------------ 1 file changed, 50 insertions(+), 135 deletions(-) diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 7175fed5410ba..eb403f88cb05f 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -403,71 +403,64 @@ impl Step for Cargo { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct Clippy { - pub compiler: Compiler, - pub target: Interned, -} +macro_rules! tool_extended { + (($sel:ident, $builder:ident), + $($name:ident, + $toolstate:ident, + $path:expr, + $tool_name:expr, + $extra_deps:block;)+) => { + $( + #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] + pub struct $name { + pub compiler: Compiler, + pub target: Interned, + } -impl Step for Clippy { - type Output = Option; - const DEFAULT: bool = true; - const ONLY_HOSTS: bool = true; + impl Step for $name { + type Output = Option; + const DEFAULT: bool = true; + const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { - let builder = run.builder; - run.path("src/tools/clippy").default_condition(builder.build.config.extended) - } + fn should_run(run: ShouldRun) -> ShouldRun { + let builder = run.builder; + run.path($path).default_condition(builder.build.config.extended) + } - fn make_run(run: RunConfig) { - run.builder.ensure(Clippy { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), - target: run.target, - }); + fn make_run(run: RunConfig) { + run.builder.ensure($name { + compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), + target: run.target, + }); + } + + fn run($sel, $builder: &Builder) -> Option { + $extra_deps + $builder.ensure(ToolBuild { + compiler: $sel.compiler, + target: $sel.target, + tool: $tool_name, + mode: Mode::Librustc, + path: $path, + expectation: $builder.build.config.toolstate.$toolstate.passes(ToolState::Compiling), + }) + } + } + )+ } +} - fn run(self, builder: &Builder) -> Option { +tool_extended!((self, builder), + Clippy, clippy, "src/tools/clippy", "clippy-driver", { // Clippy depends on procedural macros (serde), which requires a full host // compiler to be available, so we need to depend on that. builder.ensure(compile::Rustc { compiler: self.compiler, target: builder.build.build, }); - builder.ensure(ToolBuild { - compiler: self.compiler, - target: self.target, - tool: "clippy-driver", - mode: Mode::Librustc, - path: "src/tools/clippy", - expectation: builder.build.config.toolstate.clippy.passes(ToolState::Compiling), - }) - } -} - -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct Rls { - pub compiler: Compiler, - pub target: Interned, -} - -impl Step for Rls { - type Output = Option; - const DEFAULT: bool = true; - const ONLY_HOSTS: bool = true; - - fn should_run(run: ShouldRun) -> ShouldRun { - let builder = run.builder; - run.path("src/tools/rls").default_condition(builder.build.config.extended) - } - - fn make_run(run: RunConfig) { - run.builder.ensure(Rls { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), - target: run.target, - }); - } - - fn run(self, builder: &Builder) -> Option { + }; + Miri, miri, "src/tools/miri", "miri", {}; + Rls, rls, "src/tools/rls", "rls", { builder.ensure(native::Openssl { target: self.target, }); @@ -477,87 +470,9 @@ impl Step for Rls { compiler: self.compiler, target: builder.build.build, }); - builder.ensure(ToolBuild { - compiler: self.compiler, - target: self.target, - tool: "rls", - mode: Mode::Librustc, - path: "src/tools/rls", - expectation: builder.build.config.toolstate.rls.passes(ToolState::Compiling), - }) - } -} - -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct Rustfmt { - pub compiler: Compiler, - pub target: Interned, -} - -impl Step for Rustfmt { - type Output = Option; - const DEFAULT: bool = true; - const ONLY_HOSTS: bool = true; - - fn should_run(run: ShouldRun) -> ShouldRun { - let builder = run.builder; - run.path("src/tools/rustfmt").default_condition(builder.build.config.extended) - } - - fn make_run(run: RunConfig) { - run.builder.ensure(Rustfmt { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), - target: run.target, - }); - } - - fn run(self, builder: &Builder) -> Option { - builder.ensure(ToolBuild { - compiler: self.compiler, - target: self.target, - tool: "rustfmt", - mode: Mode::Librustc, - path: "src/tools/rustfmt", - expectation: builder.build.config.toolstate.rustfmt.passes(ToolState::Compiling), - }) - } -} - - -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct Miri { - pub compiler: Compiler, - pub target: Interned, -} - -impl Step for Miri { - type Output = Option; - const DEFAULT: bool = true; - const ONLY_HOSTS: bool = true; - - fn should_run(run: ShouldRun) -> ShouldRun { - let build_miri = run.builder.build.config.test_miri; - run.path("src/tools/miri").default_condition(build_miri) - } - - fn make_run(run: RunConfig) { - run.builder.ensure(Miri { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), - target: run.target, - }); - } - - fn run(self, builder: &Builder) -> Option { - builder.ensure(ToolBuild { - compiler: self.compiler, - target: self.target, - tool: "miri", - mode: Mode::Librustc, - path: "src/tools/miri", - expectation: builder.build.config.toolstate.miri.passes(ToolState::Compiling), - }) - } -} + }; + Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", {}; +); impl<'a> Builder<'a> { /// Get a `Command` which is ready to run `tool` in `stage` built for From 8f91a45e484796998942cfe2d7ae1c9aa24ccee2 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Wed, 15 Nov 2017 11:21:21 +0100 Subject: [PATCH 03/18] rustbuild: dist cargo-fmt as part of rustfmt Signed-off-by: Marc-Antoine Perennou --- src/bootstrap/dist.rs | 5 +++++ src/bootstrap/tool.rs | 1 + 2 files changed, 6 insertions(+) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 7bf385301fab5..9009be247a651 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1163,7 +1163,12 @@ impl Step for Rustfmt { compiler: builder.compiler(stage, build.build), target }).expect("Rustfmt to build: toolstate is testing"); + let cargofmt = builder.ensure(tool::Cargofmt { + compiler: builder.compiler(stage, build.build), + target + }).expect("Rustfmt to build: toolstate is testing"); install(&rustfmt, &image.join("bin"), 0o755); + install(&cargofmt, &image.join("bin"), 0o755); let doc = image.join("share/doc/rustfmt"); install(&src.join("README.md"), &doc, 0o644); install(&src.join("LICENSE-MIT"), &doc, 0o644); diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index eb403f88cb05f..bc7ec93ca8af0 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -451,6 +451,7 @@ macro_rules! tool_extended { } tool_extended!((self, builder), + Cargofmt, rustfmt, "src/tools/rustfmt", "cargo-fmt", {}; Clippy, clippy, "src/tools/clippy", "clippy-driver", { // Clippy depends on procedural macros (serde), which requires a full host // compiler to be available, so we need to depend on that. From 98175892b0fcbbb001235d3fe86cb9a5469ff171 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Thu, 16 Nov 2017 11:26:45 +0100 Subject: [PATCH 04/18] rustbuild: make tidy happy Signed-off-by: Marc-Antoine Perennou --- src/bootstrap/tool.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index bc7ec93ca8af0..9b16ca0980acb 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -436,13 +436,14 @@ macro_rules! tool_extended { fn run($sel, $builder: &Builder) -> Option { $extra_deps + let toolstate = $builder.build.config.toolstate.$toolstate; $builder.ensure(ToolBuild { compiler: $sel.compiler, target: $sel.target, tool: $tool_name, mode: Mode::Librustc, path: $path, - expectation: $builder.build.config.toolstate.$toolstate.passes(ToolState::Compiling), + expectation: toolstate.passes(ToolState::Compiling), }) } } From 6b1a3bc80af12a509ef8ca37f3dc1d1dc8541041 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 16 Nov 2017 13:08:17 -0800 Subject: [PATCH 05/18] Optimize `read_to_end`. This patch makes `read_to_end` use Vec's memory-growth pattern rather than using a custom pattern. This has some interesting effects: - If memory is reserved up front, `read_to_end` can be faster, as it starts reading at the buffer size, rather than always starting at 32 bytes. This speeds up file reading by 2x in one of my use cases. - It can reduce the number of syscalls when reading large files. Previously, `read_to_end` would settle into a sequence of 8192-byte reads. With this patch, the read size follows Vec's allocation pattern. For example, on a 16MiB file, it can do 21 read syscalls instead of 2057. In simple benchmarks of large files though, overall speed is still dominated by the actual I/O. - A downside is that Read implementations that don't implement `initializer()` may see increased memory zeroing overhead. I benchmarked this on a variety of data sizes, with and without preallocated buffers. Most benchmarks see no difference, but reading a small/medium file with a pre-allocated buffer is faster. --- src/libstd/io/mod.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 57f8c39756e3c..6149138901525 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -366,16 +366,13 @@ fn append_to_string(buf: &mut String, f: F) -> Result fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { let start_len = buf.len(); let mut g = Guard { len: buf.len(), buf: buf }; - let mut new_write_size = 16; let ret; loop { if g.len == g.buf.len() { - if new_write_size < DEFAULT_BUF_SIZE { - new_write_size *= 2; - } unsafe { - g.buf.reserve(new_write_size); - g.buf.set_len(g.len + new_write_size); + g.buf.reserve(32); + let capacity = g.buf.capacity(); + g.buf.set_len(capacity); r.initializer().initialize(&mut g.buf[g.len..]); } } From 1a9dc2e9023ffd42d7c1b06bf149a98df7a911af Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Sun, 19 Nov 2017 10:15:36 -0800 Subject: [PATCH 06/18] dead code lint to say "never constructed" for variants As reported in #19140, #44083, and #44565, some users were confused when the dead-code lint reported an enum variant to be "unused" when it was matched on (but not constructed). This wording change makes it clearer that the lint is in fact checking for construction. We continue to say "used" for all other items (it's tempting to say "called" for functions and methods, but this turns out not to be correct: functions can be passed as arguments and the dead-code lint isn't special-casing that or anything). Resolves #19140. --- src/librustc/middle/dead.rs | 23 +++++++++++-------- src/test/compile-fail/lint-dead-code-1.rs | 2 +- src/test/compile-fail/lint-dead-code-4.rs | 8 +++---- src/test/compile-fail/lint-dead-code-5.rs | 6 ++--- .../compile-fail/lint-dead-code-variant.rs | 2 +- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index a42ff543227a8..21eb772b1b376 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -531,13 +531,15 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { id: ast::NodeId, span: syntax_pos::Span, name: ast::Name, - node_type: &str) { + node_type: &str, + participle: &str) { if !name.as_str().starts_with("_") { self.tcx .lint_node(lint::builtin::DEAD_CODE, id, span, - &format!("{} is never used: `{}`", node_type, name)); + &format!("{} is never {}: `{}`", + node_type, participle, name)); } } } @@ -570,7 +572,8 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { item.id, span, item.name, - item.node.descriptive_variant() + item.node.descriptive_variant(), + "used", ); } else { // Only continue if we didn't warn @@ -583,7 +586,8 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { g: &'tcx hir::Generics, id: ast::NodeId) { if self.should_warn_about_variant(&variant.node) { - self.warn_dead_code(variant.node.data.id(), variant.span, variant.node.name, "variant"); + self.warn_dead_code(variant.node.data.id(), variant.span, variant.node.name, + "variant", "constructed"); } else { intravisit::walk_variant(self, variant, g, id); } @@ -591,15 +595,15 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem) { if self.should_warn_about_foreign_item(fi) { - self.warn_dead_code(fi.id, fi.span, fi.name, fi.node.descriptive_variant()); + self.warn_dead_code(fi.id, fi.span, fi.name, + fi.node.descriptive_variant(), "used"); } intravisit::walk_foreign_item(self, fi); } fn visit_struct_field(&mut self, field: &'tcx hir::StructField) { if self.should_warn_about_field(&field) { - self.warn_dead_code(field.id, field.span, - field.name, "field"); + self.warn_dead_code(field.id, field.span, field.name, "field", "used"); } intravisit::walk_struct_field(self, field); } @@ -611,14 +615,15 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { self.warn_dead_code(impl_item.id, impl_item.span, impl_item.name, - "associated const"); + "associated const", + "used"); } self.visit_nested_body(body_id) } hir::ImplItemKind::Method(_, body_id) => { if !self.symbol_is_live(impl_item.id, None) { let span = self.tcx.sess.codemap().def_span(impl_item.span); - self.warn_dead_code(impl_item.id, span, impl_item.name, "method"); + self.warn_dead_code(impl_item.id, span, impl_item.name, "method", "used"); } self.visit_nested_body(body_id) } diff --git a/src/test/compile-fail/lint-dead-code-1.rs b/src/test/compile-fail/lint-dead-code-1.rs index f45e80f5252e3..d6ca5e6b1d969 100644 --- a/src/test/compile-fail/lint-dead-code-1.rs +++ b/src/test/compile-fail/lint-dead-code-1.rs @@ -74,7 +74,7 @@ pub enum pub_enum3 { enum priv_enum { foo2, bar2 } //~ ERROR: enum is never used enum used_enum { foo3, - bar3 //~ ERROR variant is never used + bar3 //~ ERROR variant is never constructed } fn f() {} diff --git a/src/test/compile-fail/lint-dead-code-4.rs b/src/test/compile-fail/lint-dead-code-4.rs index 3df089fc20048..1296cf46e6fe4 100644 --- a/src/test/compile-fail/lint-dead-code-4.rs +++ b/src/test/compile-fail/lint-dead-code-4.rs @@ -22,8 +22,8 @@ fn field_read(f: Foo) -> usize { } enum XYZ { - X, //~ ERROR variant is never used - Y { //~ ERROR variant is never used + X, //~ ERROR variant is never constructed + Y { //~ ERROR variant is never constructed a: String, b: i32, c: i32, @@ -43,13 +43,13 @@ enum ABC { //~ ERROR enum is never used // ensure struct variants get warning for their fields enum IJK { - I, //~ ERROR variant is never used + I, //~ ERROR variant is never constructed J { a: String, b: i32, //~ ERROR field is never used c: i32, //~ ERROR field is never used }, - K //~ ERROR variant is never used + K //~ ERROR variant is never constructed } diff --git a/src/test/compile-fail/lint-dead-code-5.rs b/src/test/compile-fail/lint-dead-code-5.rs index 04d6547d93812..ee5cf24823d40 100644 --- a/src/test/compile-fail/lint-dead-code-5.rs +++ b/src/test/compile-fail/lint-dead-code-5.rs @@ -13,15 +13,15 @@ enum Enum1 { Variant1(isize), - Variant2 //~ ERROR: variant is never used + Variant2 //~ ERROR: variant is never constructed } enum Enum2 { Variant3(bool), #[allow(dead_code)] Variant4(isize), - Variant5 { _x: isize }, //~ ERROR: variant is never used: `Variant5` - Variant6(isize), //~ ERROR: variant is never used: `Variant6` + Variant5 { _x: isize }, //~ ERROR: variant is never constructed: `Variant5` + Variant6(isize), //~ ERROR: variant is never constructed: `Variant6` _Variant7, } diff --git a/src/test/compile-fail/lint-dead-code-variant.rs b/src/test/compile-fail/lint-dead-code-variant.rs index 0116d63caf230..3301560c31500 100644 --- a/src/test/compile-fail/lint-dead-code-variant.rs +++ b/src/test/compile-fail/lint-dead-code-variant.rs @@ -12,7 +12,7 @@ #[derive(Clone)] enum Enum { - Variant1, //~ ERROR: variant is never used + Variant1, //~ ERROR: variant is never constructed Variant2, } From 78e269ee0b8050bf91ed35b08b93b922c334d21f Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 17 Nov 2017 08:55:22 +0100 Subject: [PATCH 07/18] Include rendered diagnostic in json --- src/libsyntax/json.rs | 28 +++- .../lint/unused_parens_json_suggestion.stderr | 14 +- src/test/ui/lint/use_suggestion_json.stderr | 139 ++++++++++++++++-- src/tools/compiletest/src/runtest.rs | 14 +- 4 files changed, 172 insertions(+), 23 deletions(-) diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index e739c6d04e18a..d3f69a66557e8 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -24,11 +24,12 @@ use syntax_pos::{self, MacroBacktrace, Span, SpanLabel, MultiSpan}; use errors::registry::Registry; use errors::{DiagnosticBuilder, SubDiagnostic, CodeSuggestion, CodeMapper}; use errors::DiagnosticId; -use errors::emitter::Emitter; +use errors::emitter::{Emitter, EmitterWriter}; use std::rc::Rc; use std::io::{self, Write}; use std::vec; +use std::sync::{Arc, Mutex}; use rustc_serialize::json::{as_json, as_pretty_json}; @@ -95,7 +96,7 @@ struct Diagnostic { spans: Vec, /// Associated diagnostic messages. children: Vec, - /// The message as rustc would render it. Currently this is always `None` + /// The message as rustc would render it. rendered: Option, } @@ -170,6 +171,27 @@ impl Diagnostic { rendered: None, } }); + + // generate regular command line output and store it in the json + + // A threadsafe buffer for writing. + #[derive(Default, Clone)] + struct BufWriter(Arc>>); + + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + self.0.lock().unwrap().write(buf) + } + fn flush(&mut self) -> io::Result<()> { + self.0.lock().unwrap().flush() + } + } + let buf = BufWriter::default(); + let output = buf.clone(); + EmitterWriter::new(Box::new(buf), Some(je.cm.clone()), false).emit(db); + let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap(); + let output = String::from_utf8(output).unwrap(); + Diagnostic { message: db.message(), code: DiagnosticCode::map_opt_string(db.code.clone(), je), @@ -178,7 +200,7 @@ impl Diagnostic { children: db.children.iter().map(|c| { Diagnostic::from_sub_diagnostic(c, je) }).chain(sugg).collect(), - rendered: None, + rendered: Some(output.to_owned()), } } diff --git a/src/test/ui/lint/unused_parens_json_suggestion.stderr b/src/test/ui/lint/unused_parens_json_suggestion.stderr index e166f7011b58a..fe113eda3dd22 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.stderr +++ b/src/test/ui/lint/unused_parens_json_suggestion.stderr @@ -87,5 +87,17 @@ "rendered": null } ], - "rendered": null + "rendered": "warning: unnecessary parentheses around assigned value + --> $DIR/unused_parens_json_suggestion.rs:24:14 + | +24 | let _a = (1 / (2 + 3)); + | ^^^^^^^^^^^^^ help: remove these parentheses + | +note: lint level defined here + --> $DIR/unused_parens_json_suggestion.rs:19:9 + | +19 | #![warn(unused_parens)] + | ^^^^^^^^^^^^^ + +" } diff --git a/src/test/ui/lint/use_suggestion_json.stderr b/src/test/ui/lint/use_suggestion_json.stderr index fd3b5fe1adadf..d716dd53b97d5 100644 --- a/src/test/ui/lint/use_suggestion_json.stderr +++ b/src/test/ui/lint/use_suggestion_json.stderr @@ -2,7 +2,72 @@ "message": "cannot find type `Iter` in this scope", "code": { "code": "E0412", - "explanation": "/nThe type name used is not in scope./n/nErroneous code examples:/n/n```compile_fail,E0412/nimpl Something {} // error: type name `Something` is not in scope/n/n// or:/n/ntrait Foo {/n fn bar(N); // error: type name `N` is not in scope/n}/n/n// or:/n/nfn foo(x: T) {} // type name `T` is not in scope/n```/n/nTo fix this error, please verify you didn't misspell the type name, you did/ndeclare it or imported it into the scope. Examples:/n/n```/nstruct Something;/n/nimpl Something {} // ok!/n/n// or:/n/ntrait Foo {/n type N;/n/n fn bar(_: Self::N); // ok!/n}/n/n// or:/n/nfn foo(x: T) {} // ok!/n```/n/nAnother case that causes this error is when a type is imported into a parent/nmodule. To fix this, you can follow the suggestion and use File directly or/n`use super::File;` which will import the types from the parent namespace. An/nexample that causes this error is below:/n/n```compile_fail,E0412/nuse std::fs::File;/n/nmod foo {/n fn some_function(f: File) {}/n}/n```/n/n```/nuse std::fs::File;/n/nmod foo {/n // either/n use super::File;/n // or/n // use std::fs::File;/n fn foo(f: File) {}/n}/n# fn main() {} // don't insert it for us; that'll break imports/n```/n" + "explanation": " +The type name used is not in scope. + +Erroneous code examples: + +```compile_fail,E0412 +impl Something {} // error: type name `Something` is not in scope + +// or: + +trait Foo { + fn bar(N); // error: type name `N` is not in scope +} + +// or: + +fn foo(x: T) {} // type name `T` is not in scope +``` + +To fix this error, please verify you didn't misspell the type name, you did +declare it or imported it into the scope. Examples: + +``` +struct Something; + +impl Something {} // ok! + +// or: + +trait Foo { + type N; + + fn bar(_: Self::N); // ok! +} + +// or: + +fn foo(x: T) {} // ok! +``` + +Another case that causes this error is when a type is imported into a parent +module. To fix this, you can follow the suggestion and use File directly or +`use super::File;` which will import the types from the parent namespace. An +example that causes this error is below: + +```compile_fail,E0412 +use std::fs::File; + +mod foo { + fn some_function(f: File) {} +} +``` + +``` +use std::fs::File; + +mod foo { + // either + use super::File; + // or + // use std::fs::File; + fn foo(f: File) {} +} +# fn main() {} // don't insert it for us; that'll break imports +``` +" }, "level": "error", "spans": [ @@ -50,7 +115,9 @@ } ], "label": null, - "suggested_replacement": "use std::collections::binary_heap::Iter;/n/n", + "suggested_replacement": "use std::collections::binary_heap::Iter; + +", "expansion": null }, { @@ -70,7 +137,9 @@ } ], "label": null, - "suggested_replacement": "use std::collections::btree_map::Iter;/n/n", + "suggested_replacement": "use std::collections::btree_map::Iter; + +", "expansion": null }, { @@ -90,7 +159,9 @@ } ], "label": null, - "suggested_replacement": "use std::collections::btree_set::Iter;/n/n", + "suggested_replacement": "use std::collections::btree_set::Iter; + +", "expansion": null }, { @@ -110,7 +181,9 @@ } ], "label": null, - "suggested_replacement": "use std::collections::hash_map::Iter;/n/n", + "suggested_replacement": "use std::collections::hash_map::Iter; + +", "expansion": null }, { @@ -130,7 +203,9 @@ } ], "label": null, - "suggested_replacement": "use std::collections::hash_set::Iter;/n/n", + "suggested_replacement": "use std::collections::hash_set::Iter; + +", "expansion": null }, { @@ -150,7 +225,9 @@ } ], "label": null, - "suggested_replacement": "use std::collections::linked_list::Iter;/n/n", + "suggested_replacement": "use std::collections::linked_list::Iter; + +", "expansion": null }, { @@ -170,7 +247,9 @@ } ], "label": null, - "suggested_replacement": "use std::collections::vec_deque::Iter;/n/n", + "suggested_replacement": "use std::collections::vec_deque::Iter; + +", "expansion": null }, { @@ -190,7 +269,9 @@ } ], "label": null, - "suggested_replacement": "use std::option::Iter;/n/n", + "suggested_replacement": "use std::option::Iter; + +", "expansion": null }, { @@ -210,7 +291,9 @@ } ], "label": null, - "suggested_replacement": "use std::path::Iter;/n/n", + "suggested_replacement": "use std::path::Iter; + +", "expansion": null }, { @@ -230,7 +313,9 @@ } ], "label": null, - "suggested_replacement": "use std::result::Iter;/n/n", + "suggested_replacement": "use std::result::Iter; + +", "expansion": null }, { @@ -250,7 +335,9 @@ } ], "label": null, - "suggested_replacement": "use std::slice::Iter;/n/n", + "suggested_replacement": "use std::slice::Iter; + +", "expansion": null }, { @@ -270,7 +357,9 @@ } ], "label": null, - "suggested_replacement": "use std::sync::mpsc::Iter;/n/n", + "suggested_replacement": "use std::sync::mpsc::Iter; + +", "expansion": null } ], @@ -278,7 +367,25 @@ "rendered": null } ], - "rendered": null + "rendered": "error[E0412]: cannot find type `Iter` in this scope + --> $DIR/use_suggestion_json.rs:20:12 + | +20 | let x: Iter; + | ^^^^ not found in this scope + | +help: possible candidates are found in other modules, you can import them into scope + | +19 | use std::collections::binary_heap::Iter; + | +19 | use std::collections::btree_map::Iter; + | +19 | use std::collections::btree_set::Iter; + | +19 | use std::collections::hash_map::Iter; + | +and 8 other candidates + +" } { "message": "aborting due to previous error", @@ -286,5 +393,7 @@ "level": "error", "spans": [], "children": [], - "rendered": null + "rendered": "error: aborting due to previous error + +" } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index b5a8a15b1a8fa..b74867aba2d74 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2400,15 +2400,21 @@ actual:\n\ fn normalize_output(&self, output: &str, custom_rules: &[(String, String)]) -> String { let parent_dir = self.testpaths.file.parent().unwrap(); let cflags = self.props.compile_flags.join(" "); - let parent_dir_str = if cflags.contains("--error-format json") - || cflags.contains("--error-format pretty-json") { + let json = cflags.contains("--error-format json") || + cflags.contains("--error-format pretty-json"); + let parent_dir_str = if json { parent_dir.display().to_string().replace("\\", "\\\\") } else { parent_dir.display().to_string() }; - let mut normalized = output.replace(&parent_dir_str, "$DIR") - .replace("\\\\", "\\") // denormalize for paths on windows + let mut normalized = output.replace(&parent_dir_str, "$DIR"); + + if json { + normalized = normalized.replace("\\n", "\n"); // verbatim newline in json strings + } + + normalized = normalized.replace("\\\\", "\\") // denormalize for paths on windows .replace("\\", "/") // normalize for paths on windows .replace("\r\n", "\n") // normalize for linebreaks on windows .replace("\t", "\\t"); // makes tabs visible From ddaf523aa437c8f6386a5f40e527b6d21ecb1a36 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 17 Nov 2017 13:13:02 +0100 Subject: [PATCH 08/18] The end of a span can be *before* the first char in a line --- src/librustc_errors/snippet.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index 2e8deeee5a599..69aade21c7263 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -70,7 +70,7 @@ impl MultilineAnnotation { pub fn as_end(&self) -> Annotation { Annotation { - start_col: self.end_col - 1, + start_col: self.end_col.saturating_sub(1), end_col: self.end_col, is_primary: self.is_primary, label: self.label.clone(), From 3864d8943b99138d46751aadda58e27a1f4e06e8 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 20 Nov 2017 09:40:55 +0100 Subject: [PATCH 09/18] Address PR comments --- src/libsyntax/json.rs | 2 +- src/tools/compiletest/src/runtest.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index d3f69a66557e8..80ac0cb4faf7d 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -200,7 +200,7 @@ impl Diagnostic { children: db.children.iter().map(|c| { Diagnostic::from_sub_diagnostic(c, je) }).chain(sugg).collect(), - rendered: Some(output.to_owned()), + rendered: Some(output), } } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index b74867aba2d74..633f349ba5066 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2411,7 +2411,11 @@ actual:\n\ let mut normalized = output.replace(&parent_dir_str, "$DIR"); if json { - normalized = normalized.replace("\\n", "\n"); // verbatim newline in json strings + // escaped newlines in json strings should be readable + // in the stderr files. There's no point int being correct, + // since only humans process the stderr files. + // Thus we just turn escaped newlines back into newlines. + normalized = normalized.replace("\\n", "\n"); } normalized = normalized.replace("\\\\", "\\") // denormalize for paths on windows From b29a61e51b14276edf0d2110901129ab4e92fc5e Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Mon, 20 Nov 2017 10:02:08 +0100 Subject: [PATCH 10/18] rustbuild: fix expectation message Signed-off-by: Marc-Antoine Perennou --- src/bootstrap/dist.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 9009be247a651..81b3b04411965 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1166,7 +1166,7 @@ impl Step for Rustfmt { let cargofmt = builder.ensure(tool::Cargofmt { compiler: builder.compiler(stage, build.build), target - }).expect("Rustfmt to build: toolstate is testing"); + }).expect("Cargofmt to build: toolstate is testing"); install(&rustfmt, &image.join("bin"), 0o755); install(&cargofmt, &image.join("bin"), 0o755); let doc = image.join("share/doc/rustfmt"); From e7b2702172b91624406e8c90716a225e8ec1a299 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 20 Nov 2017 12:42:38 +0100 Subject: [PATCH 11/18] Update ui test to rustc master --- src/test/ui/lint/use_suggestion_json.stderr | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/ui/lint/use_suggestion_json.stderr b/src/test/ui/lint/use_suggestion_json.stderr index d716dd53b97d5..846d7df445d58 100644 --- a/src/test/ui/lint/use_suggestion_json.stderr +++ b/src/test/ui/lint/use_suggestion_json.stderr @@ -372,7 +372,6 @@ mod foo { | 20 | let x: Iter; | ^^^^ not found in this scope - | help: possible candidates are found in other modules, you can import them into scope | 19 | use std::collections::binary_heap::Iter; From 09dcc5f361bb6d68251ff2cbc4a76b13f173ec7b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 20 Nov 2017 21:50:05 +0100 Subject: [PATCH 12/18] Display negative traits implementation --- src/librustdoc/html/render.rs | 28 +++++++++++++++-------- src/test/rustdoc/negative-impl-sidebar.rs | 19 +++++++++++++++ 2 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 src/test/rustdoc/negative-impl-sidebar.rs diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index e79a63fb8d86f..c1402e0027202 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -3613,18 +3613,24 @@ fn sidebar_assoc_items(it: &clean::Item) -> String { } let mut links = HashSet::new(); let ret = v.iter() - .filter_map(|i| if let Some(ref i) = i.inner_impl().trait_ { - let i_display = format!("{:#}", i); - let out = Escape(&i_display); - let encoded = small_url_encode(&format!("{:#}", i)); - let generated = format!("{}", encoded, out); - if !links.contains(&generated) && links.insert(generated.clone()) { - Some(generated) + .filter_map(|i| { + let is_negative_impl = is_negative_impl(i.inner_impl()); + if let Some(ref i) = i.inner_impl().trait_ { + let i_display = format!("{:#}", i); + let out = Escape(&i_display); + let encoded = small_url_encode(&format!("{:#}", i)); + let generated = format!("{}{}", + encoded, + if is_negative_impl { "!" } else { "" }, + out); + if !links.contains(&generated) && links.insert(generated.clone()) { + Some(generated) + } else { + None + } } else { None } - } else { - None }) .collect::(); if !ret.is_empty() { @@ -3671,6 +3677,10 @@ fn extract_for_impl_name(item: &clean::Item) -> Option<(String, String)> { } } +fn is_negative_impl(i: &clean::Impl) -> bool { + i.polarity == Some(clean::ImplPolarity::Negative) +} + fn sidebar_trait(fmt: &mut fmt::Formatter, it: &clean::Item, t: &clean::Trait) -> fmt::Result { let mut sidebar = String::new(); diff --git a/src/test/rustdoc/negative-impl-sidebar.rs b/src/test/rustdoc/negative-impl-sidebar.rs new file mode 100644 index 0000000000000..dc27b26241d59 --- /dev/null +++ b/src/test/rustdoc/negative-impl-sidebar.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] +#![crate_name = "foo"] + +pub struct Foo; + +// @has foo/struct.Foo.html +// @has - '//*[@class="sidebar-title"][@href="#implementations"]' 'Trait Implementations' +// @has - '//*[@class="sidebar-links"]/a' '!Sync' +impl !Sync for Foo {} From 0789a1df65f313a0b01214eb64d973ba68d21700 Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Tue, 21 Nov 2017 01:53:36 +0200 Subject: [PATCH 13/18] Fix a typo in ToSocketAddrs documentation Fix a typo in ToSocketAddrs documentation: s/ToSocketsAddr/ToSocketAddrs --- src/libstd/net/addr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index e1d7a2531b6c9..1ca7e66ed9ca9 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -759,7 +759,7 @@ impl hash::Hash for SocketAddrV6 { /// ``` /// /// [`TcpStream::connect`] is an example of an function that utilizes -/// `ToSocketsAddr` as a trait bound on its parameter in order to accept +/// `ToSocketAddrs` as a trait bound on its parameter in order to accept /// different types: /// /// ```no_run From b9a7601913ddcd261c0c3a5713d8024780f6ca2b Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 21 Nov 2017 08:37:34 +0100 Subject: [PATCH 14/18] Expand a couple points in 1.22.0 release notes --- RELEASES.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 7a3b097611e8c..d46208831ef61 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -7,7 +7,8 @@ Language - [Now accepts underscores in unicode escapes][43716] - [`#![feature(const_fn)]` is now no longer required for calling const functions.][43017] It's still required for creating - constant functions. + constant functions, and const functions in the standard libraries + now have individual feature gates. - [`T op= &T` now works for numeric types.][44287] eg. `let mut x = 2; x += &8;` - [types that impl `Drop` are now allowed in `const` and `static` types][44456] @@ -45,8 +46,8 @@ Cargo Misc ---- - [`libbacktrace` is now available on Apple platforms.][44251] -- [Stabilised the `compile_fail` attribute for code fences.][43949] This now - lets you specify that a given code example will fail to compile. +- [Stabilised the `compile_fail` attribute for code fences in doc-comments.][43949] + This now lets you specify that a given code example will fail to compile. Compatibility Notes ------------------- From 13c1cbe749a5d6f737152454ea4041b5d53d9acb Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 21 Nov 2017 12:43:24 +0100 Subject: [PATCH 15/18] Remove 1.23.0 release notes entry on const_fn MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It doesn’t change anything for stable users in practice. See discussion in https://github.com/rust-lang/rust/pull/46148 --- RELEASES.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index d46208831ef61..fff5feb2aefff 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -5,10 +5,6 @@ Language -------- - [`non_snake_case` lint now allows extern no-mangle functions][44966] - [Now accepts underscores in unicode escapes][43716] -- [`#![feature(const_fn)]` is now no longer required for - calling const functions.][43017] It's still required for creating - constant functions, and const functions in the standard libraries - now have individual feature gates. - [`T op= &T` now works for numeric types.][44287] eg. `let mut x = 2; x += &8;` - [types that impl `Drop` are now allowed in `const` and `static` types][44456] From ad6f4dcea76172e0ad98d67b46e45190b06ffd18 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 21 Nov 2017 14:21:24 +0100 Subject: [PATCH 16/18] Revert servo to upstream in cargotest This is a follow-up to https://github.com/rust-lang/rust/pull/45225#issuecomment-345503017 now that upstream has adjusted https://github.com/servo/servo/pull/19316 --- src/tools/cargotest/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/cargotest/main.rs b/src/tools/cargotest/main.rs index b1122f401feb9..d04231bbac089 100644 --- a/src/tools/cargotest/main.rs +++ b/src/tools/cargotest/main.rs @@ -60,8 +60,8 @@ const TEST_REPOS: &'static [Test] = &[ }, Test { name: "servo", - repo: "https://github.com/eddyb/servo", - sha: "6031de9a397e2feba4ff98725991825f62b68518", + repo: "https://github.com/servo/servo", + sha: "17e97b9320fdb7cdb33bbc5f4d0fde0653bbf2e4", lock: None, // Only test Stylo a.k.a. Quantum CSS, the parts of Servo going into Firefox. // This takes much less time to build than all of Servo and supports stable Rust. From e7c8fbf1f7ee5268736876365ed80c159eab9bdf Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Mon, 20 Nov 2017 17:49:21 +0200 Subject: [PATCH 17/18] clean the Debug impl for CrateNum and DefId before: DefId { krate: CrateNum(11), index: DefIndex(0:6) => foo[8787]::Mapper[0]::OtherType[0] } } after: DefId(11:0:6 ~ foo[8787]::Mapper[0]::OtherType[0]) --- src/librustc/hir/def_id.rs | 12 +++++++----- src/test/mir-opt/validate_1.rs | 4 ++-- src/test/mir-opt/validate_4.rs | 12 ++++++------ src/test/mir-opt/validate_5.rs | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/librustc/hir/def_id.rs b/src/librustc/hir/def_id.rs index f6fcff37ca53e..8858023ec1d7b 100644 --- a/src/librustc/hir/def_id.rs +++ b/src/librustc/hir/def_id.rs @@ -17,8 +17,8 @@ use std::u32; newtype_index!(CrateNum { - derive[Debug] ENCODABLE = custom + DEBUG_FORMAT = "crate{}", /// Item definitions in the currently-compiled crate would have the CrateNum /// LOCAL_CRATE in their DefId. @@ -172,17 +172,19 @@ pub struct DefId { impl fmt::Debug for DefId { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "DefId {{ krate: {:?}, index: {:?}", - self.krate, self.index)?; + write!(f, "DefId({:?}/{}:{}", + self.krate.index(), + self.index.address_space().index(), + self.index.as_array_index())?; ty::tls::with_opt(|opt_tcx| { if let Some(tcx) = opt_tcx { - write!(f, " => {}", tcx.def_path_debug_str(*self))?; + write!(f, " ~ {}", tcx.def_path_debug_str(*self))?; } Ok(()) })?; - write!(f, " }}") + write!(f, ")") } } diff --git a/src/test/mir-opt/validate_1.rs b/src/test/mir-opt/validate_1.rs index f4d1caa6a9553..b7360a0e08733 100644 --- a/src/test/mir-opt/validate_1.rs +++ b/src/test/mir-opt/validate_1.rs @@ -30,7 +30,7 @@ fn main() { // END RUST SOURCE // START rustc.{{impl}}-foo.EraseRegions.after.mir // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:5) => validate_1[317d]::{{impl}}[0]::foo[0] }, BrAnon(0)) Test, _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:5) => validate_1[317d]::{{impl}}[0]::foo[0] }, BrAnon(1)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId(0/0:5 ~ validate_1[317d]::{{impl}}[0]::foo[0]), BrAnon(0)) Test, _2: &ReFree(DefId(0/0:5 ~ validate_1[317d]::{{impl}}[0]::foo[0]), BrAnon(1)) mut i32]); // ... // return; // } @@ -62,7 +62,7 @@ fn main() { // fn main::{{closure}}(_1: &ReErased [closure@NodeId(50)], _2: &ReErased mut i32) -> i32 { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[317d]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(50)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[317d]::main[0]::{{closure}}[0] }, BrAnon(0)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId(0/1:11 ~ validate_1[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(50)], _2: &ReFree(DefId(0/1:11 ~ validate_1[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]); // StorageLive(_3); // Validate(Suspend(ReScope(Remainder(BlockRemainder { block: ItemLocalId(22), first_statement_index: 0 }))), [(*_2): i32]); // _3 = &ReErased (*_2); diff --git a/src/test/mir-opt/validate_4.rs b/src/test/mir-opt/validate_4.rs index 80224ddc58668..39438af4b449a 100644 --- a/src/test/mir-opt/validate_4.rs +++ b/src/test/mir-opt/validate_4.rs @@ -51,8 +51,8 @@ fn main() { // fn write_42::{{closure}}(_1: &ReErased [closure@NodeId(22)], _2: *mut i32) -> () { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[317d]::write_42[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(22)], _2: *mut i32]); -// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[317d]::write_42[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(22)], _2: *mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId(0/1:9 ~ validate_4[317d]::write_42[0]::{{closure}}[0]), BrEnv) [closure@NodeId(22)], _2: *mut i32]); +// Validate(Release, [_1: &ReFree(DefId(0/1:9 ~ validate_4[317d]::write_42[0]::{{closure}}[0]), BrEnv) [closure@NodeId(22)], _2: *mut i32]); // (*_2) = const 23i32; // return; // } @@ -62,8 +62,8 @@ fn main() { // fn test(_1: &ReErased mut i32) -> () { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_4[317d]::test[0] }, BrAnon(0)) mut i32]); -// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_4[317d]::test[0] }, BrAnon(0)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId(0/0:4 ~ validate_4[317d]::test[0]), BrAnon(0)) mut i32]); +// Validate(Release, [_1: &ReFree(DefId(0/0:4 ~ validate_4[317d]::test[0]), BrAnon(0)) mut i32]); // ... // _2 = const write_42(_3) -> bb1; // } @@ -78,8 +78,8 @@ fn main() { // fn main::{{closure}}(_1: &ReErased [closure@NodeId(60)], _2: &ReErased mut i32) -> bool { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[317d]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[317d]::main[0]::{{closure}}[0] }, BrAnon(0)) mut i32]); -// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[317d]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[317d]::main[0]::{{closure}}[0] }, BrAnon(0)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId(0/1:10 ~ validate_4[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId(0/1:10 ~ validate_4[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]); +// Validate(Release, [_1: &ReFree(DefId(0/1:10 ~ validate_4[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId(0/1:10 ~ validate_4[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]); // StorageLive(_3); // ... // _0 = const write_42(_3) -> bb1; diff --git a/src/test/mir-opt/validate_5.rs b/src/test/mir-opt/validate_5.rs index a945b7dbc5fa8..043338c808983 100644 --- a/src/test/mir-opt/validate_5.rs +++ b/src/test/mir-opt/validate_5.rs @@ -37,7 +37,7 @@ fn main() { // fn test(_1: &ReErased mut i32) -> () { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_5[317d]::test[0] }, BrAnon(0)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId(0/0:4 ~ validate_5[317d]::test[0]), BrAnon(0)) mut i32]); // ... // Validate(Release, [_2: bool, _3: *mut i32]); // _2 = const write_42(_3) -> bb1; @@ -49,7 +49,7 @@ fn main() { // fn main::{{closure}}(_1: &ReErased [closure@NodeId(46)], _2: &ReErased mut i32) -> bool { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[317d]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(46)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[317d]::main[0]::{{closure}}[0] }, BrAnon(0)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId(0/1:9 ~ validate_5[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(46)], _2: &ReFree(DefId(0/1:9 ~ validate_5[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]); // StorageLive(_3); // StorageLive(_4); // Validate(Suspend(ReScope(Node(ItemLocalId(9)))), [(*_2): i32]); From ece9a57d1b6e10ef2ad1dffd19fd6033cdc760ee Mon Sep 17 00:00:00 2001 From: Martin Lindhe Date: Tue, 21 Nov 2017 15:33:45 +0100 Subject: [PATCH 18/18] fix some typos --- CONTRIBUTING.md | 2 +- RELEASES.md | 20 +++++++++---------- src/bootstrap/job.rs | 2 +- src/bootstrap/sanity.rs | 2 +- src/ci/docker/README.md | 4 ++-- .../build-netbsd-toolchain.sh | 2 +- src/ci/run.sh | 2 +- src/doc/rustdoc/src/command-line-arguments.md | 4 ++-- src/doc/rustdoc/src/documentation-tests.md | 2 +- .../language-features/optin-builtin-traits.md | 2 +- .../src/language-features/unboxed-closures.md | 2 +- src/etc/installer/exe/modpath.iss | 2 +- src/liballoc/fmt.rs | 2 +- src/liballoc/macros.rs | 2 +- src/liballoc/rc.rs | 2 +- src/liballoc/string.rs | 2 +- src/liballoc/tests/str.rs | 6 +++--- src/liballoc/vec.rs | 2 +- src/libbacktrace/configure | 2 +- src/libbacktrace/ltmain.sh | 2 +- src/libcore/fmt/mod.rs | 2 +- src/librustc_data_structures/array_vec.rs | 2 +- src/libstd/path.rs | 2 +- src/test/mir-opt/issue-41697.rs | 2 +- 24 files changed, 37 insertions(+), 37 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4c296a28e90b4..e3767df2808fa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -421,7 +421,7 @@ Here are those same steps in detail: These instructions are specific to updating `rustfmt`, however they may apply to the other submodules as well. Please help by improving these instructions -if you find any discrepencies or special cases that need to be addressed. +if you find any discrepancies or special cases that need to be addressed. To update the `rustfmt` submodule, start by running the appropriate [`git submodule` command](https://git-scm.com/book/en/v2/Git-Tools-Submodules). diff --git a/RELEASES.md b/RELEASES.md index 7a3b097611e8c..5edaab63a76b4 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -624,7 +624,7 @@ Misc ---- - [rustdoc can now use pulldown-cmark with the `--enable-commonmark` flag][40338] -- [Added rust-winbg script for better debugging on Windows][39983] +- [Added rust-windbg script for better debugging on Windows][39983] - [Rust now uses the official cross compiler for NetBSD][40612] - [rustdoc now accepts `#` at the start of files][40828] - [Fixed jemalloc support for musl][41168] @@ -1658,7 +1658,7 @@ Diagnostics ----------- * [Replace macro backtraces with labeled local uses][35702] -* [Improve error message for missplaced doc comments][33922] +* [Improve error message for misplaced doc comments][33922] * [Buffer unix and lock windows to prevent message interleaving][35975] * [Update lifetime errors to specifically note temporaries][36171] * [Special case a few colors for Windows][36178] @@ -1966,7 +1966,7 @@ Language useful](https://github.com/rust-lang/rust/pull/34908) * [`macro_rules!` `stmt` matchers correctly consume the entire contents when inside non-braces invocations](https://github.com/rust-lang/rust/pull/34886) -* [Semicolons are properly required as statement delimeters inside +* [Semicolons are properly required as statement delimiters inside `macro_rules!` invocations](https://github.com/rust-lang/rust/pull/34660) * [`cfg_attr` works on `path` attributes](https://github.com/rust-lang/rust/pull/34546) @@ -2191,7 +2191,7 @@ Compatibility Notes * [`const`s and `static`s may not have unsized types](https://github.com/rust-lang/rust/pull/34443) * [The new follow-set rules that place restrictions on `macro_rules!` in order to ensure syntax forward-compatibility have been enabled](https://github.com/rust-lang/rust/pull/33982) - This was an [ammendment to RFC 550](https://github.com/rust-lang/rfcs/pull/1384), + This was an [amendment to RFC 550](https://github.com/rust-lang/rfcs/pull/1384), and has been a warning since 1.10. * [`cfg` attribute process has been refactored to fix various bugs](https://github.com/rust-lang/rust/pull/33706). This causes breakage in some corner cases. @@ -3348,7 +3348,7 @@ Libraries * `FromStr` is [implemented for `SockAddrV4` and `SockAddrV6`][1.5s]. * There are now `From` conversions [between floating point types][1.5f] where the conversions are lossless. -* Thera are now `From` conversions [between integer types][1.5i] where +* There are now `From` conversions [between integer types][1.5i] where the conversions are lossless. * [`fs::Metadata` implements `Clone`][1.5fs]. * The `parse` method [accepts a leading "+" when parsing @@ -3548,7 +3548,7 @@ Libraries * [`IntoIterator` is implemented for references to `Option` and `Result`][into2]. * [`HashMap` and `HashSet` implement `Extend<&T>` where `T: - Copy`][ext] as part of [RFC 839]. This will cause type inferance + Copy`][ext] as part of [RFC 839]. This will cause type inference breakage in rare situations. * [`BinaryHeap` implements `Debug`][bh2]. * [`Borrow` and `BorrowMut` are implemented for fixed-size @@ -3559,7 +3559,7 @@ Libraries * `&mut T` where `T: std::fmt::Write` [also implements `std::fmt::Write`][mutw]. * [A stable regression in `VecDeque::push_back` and other - capicity-altering methods that caused panics for zero-sized types + capacity-altering methods that caused panics for zero-sized types was fixed][vd]. * [Function pointers implement traits for up to 12 parameters][fp2]. @@ -3746,7 +3746,7 @@ Libraries [better for long data][sh]. * [`AtomicPtr`] implements [`Send`]. * The [`read_to_end`] implementations for [`Stdin`] and [`File`] - are now [specialized to use uninitalized buffers for increased + are now [specialized to use uninitialized buffers for increased performance][rte]. * Lifetime parameters of foreign functions [are now resolved properly][f]. @@ -3875,7 +3875,7 @@ Highlights * This is the first release with [experimental support for linking with the MSVC linker and lib C on Windows (instead of using the GNU variants via MinGW)][win]. It is yet recommended only for the most - intrepid Rusticians. + intrepid Rustaceans. * Benchmark compilations are showing a 30% improvement in bootstrapping over 1.1. @@ -4741,7 +4741,7 @@ Version 0.11.0 (2014-07-02) * Libraries * The standard library is now a "facade" over a number of underlying libraries. This means that development on the standard library should - be speeder due to smaller crates, as well as a clearer line between + be speedier due to smaller crates, as well as a clearer line between all dependencies. * A new library, libcore, lives under the standard library's facade which is Rust's "0-assumption" library, suitable for embedded and diff --git a/src/bootstrap/job.rs b/src/bootstrap/job.rs index 72a5d1338b8d0..fa3ba02482f56 100644 --- a/src/bootstrap/job.rs +++ b/src/bootstrap/job.rs @@ -185,7 +185,7 @@ pub unsafe fn setup(build: &mut Build) { 0, FALSE, DUPLICATE_SAME_ACCESS); // If this failed, well at least we tried! An example of DuplicateHandle - // failing in the past has been when the wrong python2 package spawed this + // failing in the past has been when the wrong python2 package spawned this // build system (e.g. the `python2` package in MSYS instead of // `mingw-w64-x86_64-python2`. Not sure why it failed, but the "failure // mode" here is that we only clean everything up when the build system diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs index 8b23be69a85cf..bc275b7fc745c 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -78,7 +78,7 @@ pub fn check(build: &mut Build) { } let mut cmd_finder = Finder::new(); - // If we've got a git directory we're gona need git to update + // If we've got a git directory we're gonna need git to update // submodules and learn about various other aspects. if build.rust_info.is_git() { cmd_finder.must_have("git"); diff --git a/src/ci/docker/README.md b/src/ci/docker/README.md index 922deba7367e9..8d4dbc399986f 100644 --- a/src/ci/docker/README.md +++ b/src/ci/docker/README.md @@ -36,14 +36,14 @@ a Docker image. 1. Select the "default" virtual machine inside VirtualBox, then click "Settings" - 2. Go to "Shared Folders", click "Add shared foldrer" (the folder icon with + 2. Go to "Shared Folders", click "Add shared folder" (the folder icon with a plus sign), fill in the following information, then click "OK": * Folder path: `E:\rust` * Folder name: `e/rust` * Read-only: ☐ *unchecked* * Auto-mount: ☑ *checked* - * Make Permanant: ☑ *checked* + * Make Permanent: ☑ *checked* 3. VirtualBox might not support creating symbolic links inside a shared folder by default. You can enable it manually by running these from `cmd.exe`: diff --git a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh index 9e1b769f6c405..5b4314d57e6cc 100755 --- a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh +++ b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh @@ -52,7 +52,7 @@ curl $URL/2017-03-17-netbsd-comp.tgz | \ cd usr/src # The options, in order, do the following -# * this is an unpriviledged build +# * this is an unprivileged build # * output to a predictable location # * disable various uneeded stuff MKUNPRIVED=yes TOOLDIR=/x-tools/x86_64-unknown-netbsd \ diff --git a/src/ci/run.sh b/src/ci/run.sh index a8a7dd5bc27aa..ffb3532f497f9 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -37,7 +37,7 @@ if [ "$DIST_SRC" = "" ]; then fi # If we're deploying artifacts then we set the release channel, otherwise if -# we're not deploying then we want to be sure to enable all assertions becauase +# we're not deploying then we want to be sure to enable all assertions because # we'll be running tests # # FIXME: need a scheme for changing this `nightly` value to `beta` and `stable` diff --git a/src/doc/rustdoc/src/command-line-arguments.md b/src/doc/rustdoc/src/command-line-arguments.md index 8e8e2a7ff1dd5..e51c63cf00898 100644 --- a/src/doc/rustdoc/src/command-line-arguments.md +++ b/src/doc/rustdoc/src/command-line-arguments.md @@ -279,7 +279,7 @@ $ rustdoc README.md --markdown-playground-url https://play.rust-lang.org/ ``` When rendering a Markdown file, this flag gives the base URL of the Rust -Playround, to use for generating `Run` buttons. +Playground, to use for generating `Run` buttons. ## `--markdown-no-toc`: don't generate a table of contents @@ -291,7 +291,7 @@ $ rustdoc README.md --markdown-no-toc ``` When generating documentation from a Markdown file, by default, `rustdoc` will -generate a table of contents. This flag supresses that, and no TOC will be +generate a table of contents. This flag suppresses that, and no TOC will be generated. diff --git a/src/doc/rustdoc/src/documentation-tests.md b/src/doc/rustdoc/src/documentation-tests.md index 9c6b86d6ddc8e..e5a603a3709f6 100644 --- a/src/doc/rustdoc/src/documentation-tests.md +++ b/src/doc/rustdoc/src/documentation-tests.md @@ -50,7 +50,7 @@ running them. Here's the full algorithm rustdoc uses to preprocess examples: 5. Finally, if the example does not contain `fn main`, the remainder of the text is wrapped in `fn main() { your_code }`. -For more about that caveat in rule 4, see "Documeting Macros" below. +For more about that caveat in rule 4, see "Documenting Macros" below. ## Hiding portions of the example diff --git a/src/doc/unstable-book/src/language-features/optin-builtin-traits.md b/src/doc/unstable-book/src/language-features/optin-builtin-traits.md index 97b57c690fcc8..5c8124c9c6b7d 100644 --- a/src/doc/unstable-book/src/language-features/optin-builtin-traits.md +++ b/src/doc/unstable-book/src/language-features/optin-builtin-traits.md @@ -10,7 +10,7 @@ The `optin_builtin_traits` feature gate allows you to define auto traits. Auto traits, like [`Send`] or [`Sync`] in the standard library, are marker traits that are automatically implemented for every type, unless the type, or a type it contains, -has explictly opted out via a negative impl. +has explicitly opted out via a negative impl. [`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html diff --git a/src/doc/unstable-book/src/language-features/unboxed-closures.md b/src/doc/unstable-book/src/language-features/unboxed-closures.md index 0eaed7a1989c5..d845c99a88a69 100644 --- a/src/doc/unstable-book/src/language-features/unboxed-closures.md +++ b/src/doc/unstable-book/src/language-features/unboxed-closures.md @@ -9,7 +9,7 @@ See Also: [`fn_traits`](library-features/fn-traits.html) ---- The `unboxed_closures` feature allows you to write functions using the `"rust-call"` ABI, -required for implmenting the [`Fn*`] family of traits. `"rust-call"` functions must have +required for implementing the [`Fn*`] family of traits. `"rust-call"` functions must have exactly one (non self) argument, a tuple representing the argument list. [`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html diff --git a/src/etc/installer/exe/modpath.iss b/src/etc/installer/exe/modpath.iss index 35cc0097035c3..2cfc8698c4b67 100644 --- a/src/etc/installer/exe/modpath.iss +++ b/src/etc/installer/exe/modpath.iss @@ -144,7 +144,7 @@ begin end; end; -// Split a string into an array using passed delimeter +// Split a string into an array using passed delimiter procedure Explode(var Dest: TArrayOfString; Text: String; Separator: String); var i: Integer; diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs index 77f65412bd3e1..7148a1143fd46 100644 --- a/src/liballoc/fmt.rs +++ b/src/liballoc/fmt.rs @@ -536,7 +536,7 @@ use string; /// assert_eq!(s, "Hello, world!"); /// ``` /// -/// Please note that using [`format!`] might be preferrable. +/// Please note that using [`format!`] might be preferable. /// Example: /// /// ``` diff --git a/src/liballoc/macros.rs b/src/liballoc/macros.rs index c2a3019515f10..472eef77d7956 100644 --- a/src/liballoc/macros.rs +++ b/src/liballoc/macros.rs @@ -72,7 +72,7 @@ macro_rules! vec { /// Creates a `String` using interpolation of runtime expressions. /// -/// The first argument `format!` recieves is a format string. This must be a string +/// The first argument `format!` receives is a format string. This must be a string /// literal. The power of the formatting string is in the `{}`s contained. /// /// Additional parameters passed to `format!` replace the `{}`s within the diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 72b9fa0eb4721..58f08fd8bc11d 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -346,7 +346,7 @@ impl Rc { unsafe { let val = ptr::read(&*this); // copy the contained object - // Indicate to Weaks that they can't be promoted by decrememting + // Indicate to Weaks that they can't be promoted by decrementing // the strong count, and then remove the implicit "strong weak" // pointer while also handling drop logic by just crafting a // fake Weak. diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 25fcc1ccdab58..cd0f4a22e9cfa 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -596,7 +596,7 @@ impl String { /// Decode a UTF-16 encoded vector `v` into a `String`, returning [`Err`] /// if `v` contains any invalid data. /// - /// [`Err`]: ../../std/result/enum.Result.htlm#variant.Err + /// [`Err`]: ../../std/result/enum.Result.html#variant.Err /// /// # Examples /// diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index 6b075e7ac0e0d..a14a5d32738b3 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -1427,12 +1427,12 @@ mod pattern { Reject(6, 7), Match (7, 7), ]); - make_test!(str_searcher_mulibyte_haystack, " ", "├──", [ + make_test!(str_searcher_multibyte_haystack, " ", "├──", [ Reject(0, 3), Reject(3, 6), Reject(6, 9), ]); - make_test!(str_searcher_empty_needle_mulibyte_haystack, "", "├──", [ + make_test!(str_searcher_empty_needle_multibyte_haystack, "", "├──", [ Match (0, 0), Reject(0, 3), Match (3, 3), @@ -1455,7 +1455,7 @@ mod pattern { Match (5, 6), Reject(6, 7), ]); - make_test!(char_searcher_mulibyte_haystack, ' ', "├──", [ + make_test!(char_searcher_multibyte_haystack, ' ', "├──", [ Reject(0, 3), Reject(3, 6), Reject(6, 9), diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 5aca199cf40c0..c29449a241e45 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1089,7 +1089,7 @@ impl Vec { // Memory safety // // When the Drain is first created, it shortens the length of - // the source vector to make sure no uninitalized or moved-from elements + // the source vector to make sure no uninitialized or moved-from elements // are accessible at all if the Drain's destructor never gets to run. // // Drain will ptr::read out the values to remove. diff --git a/src/libbacktrace/configure b/src/libbacktrace/configure index 873220794bd0a..8bdb29d25606f 100755 --- a/src/libbacktrace/configure +++ b/src/libbacktrace/configure @@ -14584,7 +14584,7 @@ func_basename () # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. -# value retuned in "$func_basename_result" +# value returned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. diff --git a/src/libbacktrace/ltmain.sh b/src/libbacktrace/ltmain.sh index eaef55a59332a..eff9e62be8a05 100644 --- a/src/libbacktrace/ltmain.sh +++ b/src/libbacktrace/ltmain.sh @@ -177,7 +177,7 @@ basename="s,^.*/,," # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. -# value retuned in "$func_basename_result" +# value returned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index e2d61890c3096..cc324b585bcf9 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -952,7 +952,7 @@ pub trait UpperExp { /// assert_eq!(output, "Hello world!"); /// ``` /// -/// Please note that using [`write!`] might be preferrable. Example: +/// Please note that using [`write!`] might be preferable. Example: /// /// ``` /// use std::fmt::Write; diff --git a/src/librustc_data_structures/array_vec.rs b/src/librustc_data_structures/array_vec.rs index 1e67461e0556d..1b39e029604d5 100644 --- a/src/librustc_data_structures/array_vec.rs +++ b/src/librustc_data_structures/array_vec.rs @@ -111,7 +111,7 @@ impl ArrayVec { // Memory safety // // When the Drain is first created, it shortens the length of - // the source vector to make sure no uninitalized or moved-from elements + // the source vector to make sure no uninitialized or moved-from elements // are accessible at all if the Drain's destructor never gets to run. // // Drain will ptr::read out the values to remove. diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 69922470cff4a..4e35cf840de96 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -3752,7 +3752,7 @@ mod tests { } #[test] - fn test_eq_recievers() { + fn test_eq_receivers() { use borrow::Cow; let borrowed: &Path = Path::new("foo/bar"); diff --git a/src/test/mir-opt/issue-41697.rs b/src/test/mir-opt/issue-41697.rs index 47eeffe35a83e..4d2ba5e2b120c 100644 --- a/src/test/mir-opt/issue-41697.rs +++ b/src/test/mir-opt/issue-41697.rs @@ -12,7 +12,7 @@ // artificial cycles: during type-checking, we had to get the MIR for // the constant expressions in `[u8; 2]`, which in turn would trigger // an attempt to get the item-path, which in turn would request the -// types of the impl, which would trigger a cycle. We supressed this +// types of the impl, which would trigger a cycle. We suppressed this // cycle now by forcing mir-dump to avoid asking for types of an impl. #![feature(rustc_attrs)]