Skip to content

Commit 02ac15c

Browse files
committed
Automatically enable the clippy feature of rls if clippy builds
1 parent 3b6412b commit 02ac15c

File tree

9 files changed

+67
-183
lines changed

9 files changed

+67
-183
lines changed

src/Cargo.lock

+24-170
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ cargo = { path = "tools/cargo" }
7272
# RLS depends on `rustfmt` from crates.io, so we put this in a `[patch]` section
7373
# for crates.io
7474
rustfmt-nightly = { path = "tools/rustfmt" }
75+
clippy_lints = { path = "tools/clippy/clippy_lints" }

src/bootstrap/dist.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ impl Step for Rls {
11201120
// state for RLS isn't testing.
11211121
let rls = builder.ensure(tool::Rls {
11221122
compiler: builder.compiler(stage, build.build),
1123-
target
1123+
target, extra_features: Vec::new()
11241124
}).or_else(|| { println!("Unable to build RLS, skipping dist"); None })?;
11251125

11261126
install(&rls, &image.join("bin"), 0o755);
@@ -1199,11 +1199,11 @@ impl Step for Rustfmt {
11991199
// Prepare the image directory
12001200
let rustfmt = builder.ensure(tool::Rustfmt {
12011201
compiler: builder.compiler(stage, build.build),
1202-
target
1202+
target, extra_features: Vec::new()
12031203
}).or_else(|| { println!("Unable to build Rustfmt, skipping dist"); None })?;
12041204
let cargofmt = builder.ensure(tool::Cargofmt {
12051205
compiler: builder.compiler(stage, build.build),
1206-
target
1206+
target, extra_features: Vec::new()
12071207
}).or_else(|| { println!("Unable to build Cargofmt, skipping dist"); None })?;
12081208

12091209
install(&rustfmt, &image.join("bin"), 0o755);

src/bootstrap/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
116116
#![deny(warnings)]
117117
#![feature(core_intrinsics)]
118+
#![feature(slice_concat_ext)]
118119

119120
#[macro_use]
120121
extern crate build_helper;

src/bootstrap/test.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl Step for Rls {
245245
let host = self.host;
246246
let compiler = builder.compiler(stage, host);
247247

248-
builder.ensure(tool::Rls { compiler, target: self.host });
248+
builder.ensure(tool::Rls { compiler, target: self.host, extra_features: Vec::new() });
249249
let mut cargo = tool::prepare_tool_cargo(builder,
250250
compiler,
251251
host,
@@ -291,7 +291,7 @@ impl Step for Rustfmt {
291291
let host = self.host;
292292
let compiler = builder.compiler(stage, host);
293293

294-
builder.ensure(tool::Rustfmt { compiler, target: self.host });
294+
builder.ensure(tool::Rustfmt { compiler, target: self.host, extra_features: Vec::new() });
295295
let mut cargo = tool::prepare_tool_cargo(builder,
296296
compiler,
297297
host,
@@ -339,7 +339,12 @@ impl Step for Miri {
339339
let host = self.host;
340340
let compiler = builder.compiler(stage, host);
341341

342-
if let Some(miri) = builder.ensure(tool::Miri { compiler, target: self.host }) {
342+
let miri = builder.ensure(tool::Miri {
343+
compiler,
344+
target: self.host,
345+
extra_features: Vec::new(),
346+
});
347+
if let Some(miri) = miri {
343348
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
344349
cargo.arg("--manifest-path").arg(build.src.join("src/tools/miri/Cargo.toml"));
345350

@@ -391,7 +396,12 @@ impl Step for Clippy {
391396
let host = self.host;
392397
let compiler = builder.compiler(stage, host);
393398

394-
if let Some(clippy) = builder.ensure(tool::Clippy { compiler, target: self.host }) {
399+
let clippy = builder.ensure(tool::Clippy {
400+
compiler,
401+
target: self.host,
402+
extra_features: Vec::new(),
403+
});
404+
if let Some(clippy) = clippy {
395405
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
396406
cargo.arg("--manifest-path").arg(build.src.join("src/tools/clippy/Cargo.toml"));
397407

src/bootstrap/tool.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::fs;
1212
use std::env;
1313
use std::path::PathBuf;
1414
use std::process::{Command, exit};
15+
use std::slice::SliceConcatExt;
1516

1617
use Mode;
1718
use Compiler;
@@ -74,14 +75,15 @@ impl Step for CleanTools {
7475
}
7576
}
7677

77-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
78+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
7879
struct ToolBuild {
7980
compiler: Compiler,
8081
target: Interned<String>,
8182
tool: &'static str,
8283
path: &'static str,
8384
mode: Mode,
8485
is_ext_tool: bool,
86+
extra_features: Vec<String>,
8587
}
8688

8789
impl Step for ToolBuild {
@@ -114,6 +116,7 @@ impl Step for ToolBuild {
114116
println!("Building stage{} tool {} ({})", compiler.stage, tool, target);
115117

116118
let mut cargo = prepare_tool_cargo(builder, compiler, target, "build", path);
119+
cargo.arg("--features").arg(self.extra_features.join(" "));
117120
let is_expected = build.try_run(&mut cargo);
118121
build.save_toolstate(tool, if is_expected {
119122
ToolState::TestFail
@@ -242,6 +245,7 @@ macro_rules! tool {
242245
mode: $mode,
243246
path: $path,
244247
is_ext_tool: false,
248+
extra_features: Vec::new(),
245249
}).expect("expected to build -- essential tool")
246250
}
247251
}
@@ -291,6 +295,7 @@ impl Step for RemoteTestServer {
291295
mode: Mode::Libstd,
292296
path: "src/tools/remote-test-server",
293297
is_ext_tool: false,
298+
extra_features: Vec::new(),
294299
}).expect("expected to build -- essential tool")
295300
}
296301
}
@@ -409,6 +414,7 @@ impl Step for Cargo {
409414
mode: Mode::Librustc,
410415
path: "src/tools/cargo",
411416
is_ext_tool: false,
417+
extra_features: Vec::new(),
412418
}).expect("expected to build -- essential tool")
413419
}
414420
}
@@ -421,10 +427,11 @@ macro_rules! tool_extended {
421427
$tool_name:expr,
422428
$extra_deps:block;)+) => {
423429
$(
424-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
430+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
425431
pub struct $name {
426432
pub compiler: Compiler,
427433
pub target: Interned<String>,
434+
pub extra_features: Vec<String>,
428435
}
429436

430437
impl Step for $name {
@@ -441,17 +448,20 @@ macro_rules! tool_extended {
441448
run.builder.ensure($name {
442449
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
443450
target: run.target,
451+
extra_features: Vec::new(),
444452
});
445453
}
446454

447-
fn run($sel, $builder: &Builder) -> Option<PathBuf> {
455+
#[allow(unused_mut)]
456+
fn run(mut $sel, $builder: &Builder) -> Option<PathBuf> {
448457
$extra_deps
449458
$builder.ensure(ToolBuild {
450459
compiler: $sel.compiler,
451460
target: $sel.target,
452461
tool: $tool_name,
453462
mode: Mode::Librustc,
454463
path: $path,
464+
extra_features: $sel.extra_features,
455465
is_ext_tool: true,
456466
})
457467
}
@@ -472,6 +482,14 @@ tool_extended!((self, builder),
472482
};
473483
Miri, miri, "src/tools/miri", "miri", {};
474484
Rls, rls, "src/tools/rls", "rls", {
485+
let clippy = builder.ensure(Clippy {
486+
compiler: self.compiler,
487+
target: self.target,
488+
extra_features: Vec::new(),
489+
});
490+
if clippy.is_some() {
491+
self.extra_features.push("clippy".to_owned());
492+
}
475493
builder.ensure(native::Openssl {
476494
target: self.target,
477495
});

src/tools/clippy

src/tools/miri

Submodule miri updated from 61833b9 to d4712ca

src/tools/rls

Submodule rls updated from b6c5244 to fc4db0a

0 commit comments

Comments
 (0)