Skip to content

Commit 4faaf7e

Browse files
committedJul 2, 2018
Auto merge of #51122 - oli-obk:clippy, r=Mark-Simulacrum
Did you mean to block nightlies on clippy? Discussion: https://gitter.im/rust-lang/WG-clippy?at=5b073b6597a0361fb760cdc2 r? @alexcrichton did I forget anything? cc @nrc @Manishearth
2 parents e75e782 + 78adefd commit 4faaf7e

File tree

8 files changed

+165
-7
lines changed

8 files changed

+165
-7
lines changed
 

‎src/Cargo.lock

+8-5
Original file line numberDiff line numberDiff line change
@@ -307,20 +307,23 @@ dependencies = [
307307

308308
[[package]]
309309
name = "clippy"
310-
version = "0.0.202"
310+
version = "0.0.211"
311311
dependencies = [
312312
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
313+
"backtrace 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
313314
"cargo_metadata 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
314315
"clippy-mini-macro-test 0.2.0",
315-
"clippy_lints 0.0.202",
316+
"clippy_lints 0.0.211",
316317
"compiletest_rs 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
317318
"derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
318319
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
320+
"num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
319321
"regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
320322
"rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
321323
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
322324
"serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
323325
"serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
326+
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
324327
]
325328

326329
[[package]]
@@ -329,7 +332,8 @@ version = "0.2.0"
329332

330333
[[package]]
331334
name = "clippy_lints"
332-
version = "0.0.202"
335+
version = "0.0.205"
336+
source = "registry+https://github.com/rust-lang/crates.io-index"
333337
dependencies = [
334338
"cargo_metadata 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
335339
"if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -349,8 +353,7 @@ dependencies = [
349353

350354
[[package]]
351355
name = "clippy_lints"
352-
version = "0.0.205"
353-
source = "registry+https://github.com/rust-lang/crates.io-index"
356+
version = "0.0.211"
354357
dependencies = [
355358
"cargo_metadata 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
356359
"if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",

‎src/bootstrap/bootstrap.py

+1
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ def bootstrap(help_triggered):
815815
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
816816
env["BOOTSTRAP_PYTHON"] = sys.executable
817817
env["BUILD_DIR"] = build.build_dir
818+
env["RUSTC_BOOTSTRAP"] = '1'
818819
run(args, env=env, verbose=build.verbose)
819820

820821

‎src/bootstrap/dist.rs

+113
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ pub fn pkgname(builder: &Builder, component: &str) -> String {
4141
format!("{}-{}", component, builder.cargo_package_vers())
4242
} else if component == "rls" {
4343
format!("{}-{}", component, builder.rls_package_vers())
44+
} else if component == "clippy" {
45+
format!("{}-{}", component, builder.clippy_package_vers())
4446
} else if component == "rustfmt" {
4547
format!("{}-{}", component, builder.rustfmt_package_vers())
4648
} else if component == "llvm-tools" {
@@ -1183,6 +1185,82 @@ impl Step for Rls {
11831185
}
11841186
}
11851187

1188+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
1189+
pub struct Clippy {
1190+
pub stage: u32,
1191+
pub target: Interned<String>,
1192+
}
1193+
1194+
impl Step for Clippy {
1195+
type Output = Option<PathBuf>;
1196+
const ONLY_HOSTS: bool = true;
1197+
1198+
fn should_run(run: ShouldRun) -> ShouldRun {
1199+
run.path("clippy")
1200+
}
1201+
1202+
fn make_run(run: RunConfig) {
1203+
run.builder.ensure(Clippy {
1204+
stage: run.builder.top_stage,
1205+
target: run.target,
1206+
});
1207+
}
1208+
1209+
fn run(self, builder: &Builder) -> Option<PathBuf> {
1210+
let stage = self.stage;
1211+
let target = self.target;
1212+
assert!(builder.config.extended);
1213+
1214+
builder.info(&format!("Dist clippy stage{} ({})", stage, target));
1215+
let src = builder.src.join("src/tools/clippy");
1216+
let release_num = builder.release_num("clippy");
1217+
let name = pkgname(builder, "clippy");
1218+
let version = builder.clippy_info.version(builder, &release_num);
1219+
1220+
let tmp = tmpdir(builder);
1221+
let image = tmp.join("clippy-image");
1222+
drop(fs::remove_dir_all(&image));
1223+
t!(fs::create_dir_all(&image));
1224+
1225+
// Prepare the image directory
1226+
// We expect clippy to build, because we've exited this step above if tool
1227+
// state for clippy isn't testing.
1228+
let clippy = builder.ensure(tool::Clippy {
1229+
compiler: builder.compiler(stage, builder.config.build),
1230+
target, extra_features: Vec::new()
1231+
}).or_else(|| { println!("Unable to build clippy, skipping dist"); None })?;
1232+
1233+
builder.install(&clippy, &image.join("bin"), 0o755);
1234+
let doc = image.join("share/doc/clippy");
1235+
builder.install(&src.join("README.md"), &doc, 0o644);
1236+
builder.install(&src.join("LICENSE"), &doc, 0o644);
1237+
1238+
// Prepare the overlay
1239+
let overlay = tmp.join("clippy-overlay");
1240+
drop(fs::remove_dir_all(&overlay));
1241+
t!(fs::create_dir_all(&overlay));
1242+
builder.install(&src.join("README.md"), &overlay, 0o644);
1243+
builder.install(&src.join("LICENSE"), &doc, 0o644);
1244+
builder.create(&overlay.join("version"), &version);
1245+
1246+
// Generate the installer tarball
1247+
let mut cmd = rust_installer(builder);
1248+
cmd.arg("generate")
1249+
.arg("--product-name=Rust")
1250+
.arg("--rel-manifest-dir=rustlib")
1251+
.arg("--success-message=clippy-ready-to-serve.")
1252+
.arg("--image-dir").arg(&image)
1253+
.arg("--work-dir").arg(&tmpdir(builder))
1254+
.arg("--output-dir").arg(&distdir(builder))
1255+
.arg("--non-installed-overlay").arg(&overlay)
1256+
.arg(format!("--package-name={}-{}", name, target))
1257+
.arg("--legacy-manifest-dirs=rustlib,cargo")
1258+
.arg("--component-name=clippy-preview");
1259+
1260+
builder.run(&mut cmd);
1261+
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target)))
1262+
}
1263+
}
11861264

11871265
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
11881266
pub struct Rustfmt {
@@ -1304,6 +1382,7 @@ impl Step for Extended {
13041382
let rustfmt_installer = builder.ensure(Rustfmt { stage, target });
13051383
let rls_installer = builder.ensure(Rls { stage, target });
13061384
let llvm_tools_installer = builder.ensure(LlvmTools { stage, target });
1385+
let clippy_installer = builder.ensure(Clippy { stage, target });
13071386
let mingw_installer = builder.ensure(Mingw { host: target });
13081387
let analysis_installer = builder.ensure(Analysis {
13091388
compiler: builder.compiler(stage, self.host),
@@ -1340,6 +1419,7 @@ impl Step for Extended {
13401419
tarballs.push(rustc_installer);
13411420
tarballs.push(cargo_installer);
13421421
tarballs.extend(rls_installer.clone());
1422+
tarballs.extend(clippy_installer.clone());
13431423
tarballs.extend(rustfmt_installer.clone());
13441424
tarballs.extend(llvm_tools_installer.clone());
13451425
tarballs.push(analysis_installer);
@@ -1409,6 +1489,9 @@ impl Step for Extended {
14091489
if rls_installer.is_none() {
14101490
contents = filter(&contents, "rls");
14111491
}
1492+
if clippy_installer.is_none() {
1493+
contents = filter(&contents, "clippy");
1494+
}
14121495
if rustfmt_installer.is_none() {
14131496
contents = filter(&contents, "rustfmt");
14141497
}
@@ -1446,6 +1529,9 @@ impl Step for Extended {
14461529
if rls_installer.is_some() {
14471530
prepare("rls");
14481531
}
1532+
if clippy_installer.is_some() {
1533+
prepare("clippy");
1534+
}
14491535

14501536
// create an 'uninstall' package
14511537
builder.install(&etc.join("pkg/postinstall"), &pkg.join("uninstall"), 0o755);
@@ -1474,6 +1560,8 @@ impl Step for Extended {
14741560
format!("{}-{}", name, target)
14751561
} else if name == "rls" {
14761562
"rls-preview".to_string()
1563+
} else if name == "clippy" {
1564+
"clippy-preview".to_string()
14771565
} else {
14781566
name.to_string()
14791567
};
@@ -1490,6 +1578,9 @@ impl Step for Extended {
14901578
if rls_installer.is_some() {
14911579
prepare("rls");
14921580
}
1581+
if clippy_installer.is_some() {
1582+
prepare("clippy");
1583+
}
14931584
if target.contains("windows-gnu") {
14941585
prepare("rust-mingw");
14951586
}
@@ -1570,6 +1661,18 @@ impl Step for Extended {
15701661
.arg("-out").arg(exe.join("RlsGroup.wxs"))
15711662
.arg("-t").arg(etc.join("msi/remove-duplicates.xsl")));
15721663
}
1664+
if clippy_installer.is_some() {
1665+
builder.run(Command::new(&heat)
1666+
.current_dir(&exe)
1667+
.arg("dir")
1668+
.arg("clippy")
1669+
.args(&heat_flags)
1670+
.arg("-cg").arg("ClippyGroup")
1671+
.arg("-dr").arg("Clippy")
1672+
.arg("-var").arg("var.ClippyDir")
1673+
.arg("-out").arg(exe.join("ClippyGroup.wxs"))
1674+
.arg("-t").arg(etc.join("msi/remove-duplicates.xsl")));
1675+
}
15731676
builder.run(Command::new(&heat)
15741677
.current_dir(&exe)
15751678
.arg("dir")
@@ -1612,6 +1715,9 @@ impl Step for Extended {
16121715
if rls_installer.is_some() {
16131716
cmd.arg("-dRlsDir=rls");
16141717
}
1718+
if clippy_installer.is_some() {
1719+
cmd.arg("-dClippyDir=clippy");
1720+
}
16151721
if target.contains("windows-gnu") {
16161722
cmd.arg("-dGccDir=rust-mingw");
16171723
}
@@ -1627,6 +1733,9 @@ impl Step for Extended {
16271733
if rls_installer.is_some() {
16281734
candle("RlsGroup.wxs".as_ref());
16291735
}
1736+
if clippy_installer.is_some() {
1737+
candle("ClippyGroup.wxs".as_ref());
1738+
}
16301739
candle("AnalysisGroup.wxs".as_ref());
16311740

16321741
if target.contains("windows-gnu") {
@@ -1656,6 +1765,9 @@ impl Step for Extended {
16561765
if rls_installer.is_some() {
16571766
cmd.arg("RlsGroup.wixobj");
16581767
}
1768+
if clippy_installer.is_some() {
1769+
cmd.arg("ClippyGroup.wixobj");
1770+
}
16591771

16601772
if target.contains("windows-gnu") {
16611773
cmd.arg("GccGroup.wixobj");
@@ -1741,6 +1853,7 @@ impl Step for HashSign {
17411853
cmd.arg(builder.rust_package_vers());
17421854
cmd.arg(builder.package_vers(&builder.release_num("cargo")));
17431855
cmd.arg(builder.package_vers(&builder.release_num("rls")));
1856+
cmd.arg(builder.package_vers(&builder.release_num("clippy")));
17441857
cmd.arg(builder.package_vers(&builder.release_num("rustfmt")));
17451858
cmd.arg(builder.llvm_tools_package_vers());
17461859
cmd.arg(addr);

‎src/bootstrap/install.rs

+11
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ pub fn install_cargo(builder: &Builder, stage: u32, host: Interned<String>) {
3939
pub fn install_rls(builder: &Builder, stage: u32, host: Interned<String>) {
4040
install_sh(builder, "rls", "rls", stage, Some(host));
4141
}
42+
pub fn install_clippy(builder: &Builder, stage: u32, host: Interned<String>) {
43+
install_sh(builder, "clippy", "clippy", stage, Some(host));
44+
}
4245

4346
pub fn install_rustfmt(builder: &Builder, stage: u32, host: Interned<String>) {
4447
install_sh(builder, "rustfmt", "rustfmt", stage, Some(host));
@@ -216,6 +219,14 @@ install!((self, builder, _config),
216219
builder.info(&format!("skipping Install RLS stage{} ({})", self.stage, self.target));
217220
}
218221
};
222+
Clippy, "clippy", Self::should_build(_config), only_hosts: true, {
223+
if builder.ensure(dist::Clippy { stage: self.stage, target: self.target }).is_some() ||
224+
Self::should_install(builder) {
225+
install_clippy(builder, self.stage, self.target);
226+
} else {
227+
builder.info(&format!("skipping Install clippy stage{} ({})", self.stage, self.target));
228+
}
229+
};
219230
Rustfmt, "rustfmt", Self::should_build(_config), only_hosts: true, {
220231
if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() ||
221232
Self::should_install(builder) {

‎src/bootstrap/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ pub struct Build {
248248
rust_info: channel::GitInfo,
249249
cargo_info: channel::GitInfo,
250250
rls_info: channel::GitInfo,
251+
clippy_info: channel::GitInfo,
251252
rustfmt_info: channel::GitInfo,
252253
local_rebuild: bool,
253254
fail_fast: bool,
@@ -363,6 +364,7 @@ impl Build {
363364
let rust_info = channel::GitInfo::new(&config, &src);
364365
let cargo_info = channel::GitInfo::new(&config, &src.join("src/tools/cargo"));
365366
let rls_info = channel::GitInfo::new(&config, &src.join("src/tools/rls"));
367+
let clippy_info = channel::GitInfo::new(&config, &src.join("src/tools/clippy"));
366368
let rustfmt_info = channel::GitInfo::new(&config, &src.join("src/tools/rustfmt"));
367369

368370
let mut build = Build {
@@ -384,6 +386,7 @@ impl Build {
384386
rust_info,
385387
cargo_info,
386388
rls_info,
389+
clippy_info,
387390
rustfmt_info,
388391
cc: HashMap::new(),
389392
cxx: HashMap::new(),
@@ -968,6 +971,11 @@ impl Build {
968971
self.package_vers(&self.release_num("rls"))
969972
}
970973

974+
/// Returns the value of `package_vers` above for clippy
975+
fn clippy_package_vers(&self) -> String {
976+
self.package_vers(&self.release_num("clippy"))
977+
}
978+
971979
/// Returns the value of `package_vers` above for rustfmt
972980
fn rustfmt_package_vers(&self) -> String {
973981
self.package_vers(&self.release_num("rustfmt"))

‎src/bootstrap/tool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl Step for ToolBuild {
118118
let mut duplicates = Vec::new();
119119
let is_expected = compile::stream_cargo(builder, &mut cargo, &mut |msg| {
120120
// Only care about big things like the RLS/Cargo for now
121-
if tool != "rls" && tool != "cargo" {
121+
if tool != "rls" && tool != "cargo" && tool != "clippy-driver" {
122122
return
123123
}
124124
let (id, features, filenames) = match msg {

‎src/tools/build-manifest/src/main.rs

+22
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ struct Builder {
183183
rust_release: String,
184184
cargo_release: String,
185185
rls_release: String,
186+
clippy_release: String,
186187
rustfmt_release: String,
187188
llvm_tools_release: String,
188189

@@ -196,12 +197,14 @@ struct Builder {
196197
rust_version: Option<String>,
197198
cargo_version: Option<String>,
198199
rls_version: Option<String>,
200+
clippy_version: Option<String>,
199201
rustfmt_version: Option<String>,
200202
llvm_tools_version: Option<String>,
201203

202204
rust_git_commit_hash: Option<String>,
203205
cargo_git_commit_hash: Option<String>,
204206
rls_git_commit_hash: Option<String>,
207+
clippy_git_commit_hash: Option<String>,
205208
rustfmt_git_commit_hash: Option<String>,
206209
llvm_tools_git_commit_hash: Option<String>,
207210
}
@@ -214,6 +217,7 @@ fn main() {
214217
let rust_release = args.next().unwrap();
215218
let cargo_release = args.next().unwrap();
216219
let rls_release = args.next().unwrap();
220+
let clippy_release = args.next().unwrap();
217221
let rustfmt_release = args.next().unwrap();
218222
let llvm_tools_release = args.next().unwrap();
219223
let s3_address = args.next().unwrap();
@@ -224,6 +228,7 @@ fn main() {
224228
rust_release,
225229
cargo_release,
226230
rls_release,
231+
clippy_release,
227232
rustfmt_release,
228233
llvm_tools_release,
229234

@@ -237,12 +242,14 @@ fn main() {
237242
rust_version: None,
238243
cargo_version: None,
239244
rls_version: None,
245+
clippy_version: None,
240246
rustfmt_version: None,
241247
llvm_tools_version: None,
242248

243249
rust_git_commit_hash: None,
244250
cargo_git_commit_hash: None,
245251
rls_git_commit_hash: None,
252+
clippy_git_commit_hash: None,
246253
rustfmt_git_commit_hash: None,
247254
llvm_tools_git_commit_hash: None,
248255
}.build();
@@ -259,6 +266,7 @@ impl Builder {
259266
self.rust_git_commit_hash = self.git_commit_hash("rust", "x86_64-unknown-linux-gnu");
260267
self.cargo_git_commit_hash = self.git_commit_hash("cargo", "x86_64-unknown-linux-gnu");
261268
self.rls_git_commit_hash = self.git_commit_hash("rls", "x86_64-unknown-linux-gnu");
269+
self.clippy_git_commit_hash = self.git_commit_hash("clippy", "x86_64-unknown-linux-gnu");
262270
self.rustfmt_git_commit_hash = self.git_commit_hash("rustfmt", "x86_64-unknown-linux-gnu");
263271
self.llvm_tools_git_commit_hash = self.git_commit_hash("llvm-tools",
264272
"x86_64-unknown-linux-gnu");
@@ -296,10 +304,12 @@ impl Builder {
296304
self.package("rust-docs", &mut manifest.pkg, TARGETS);
297305
self.package("rust-src", &mut manifest.pkg, &["*"]);
298306
self.package("rls-preview", &mut manifest.pkg, HOSTS);
307+
self.package("clippy-preview", &mut manifest.pkg, HOSTS);
299308
self.package("rustfmt-preview", &mut manifest.pkg, HOSTS);
300309
self.package("rust-analysis", &mut manifest.pkg, TARGETS);
301310
self.package("llvm-tools-preview", &mut manifest.pkg, TARGETS);
302311

312+
let clippy_present = manifest.pkg.contains_key("clippy-preview");
303313
let rls_present = manifest.pkg.contains_key("rls-preview");
304314
let rustfmt_present = manifest.pkg.contains_key("rustfmt-preview");
305315
let llvm_tools_present = manifest.pkg.contains_key("llvm-tools-preview");
@@ -345,6 +355,12 @@ impl Builder {
345355
});
346356
}
347357

358+
if clippy_present {
359+
extensions.push(Component {
360+
pkg: "clippy-preview".to_string(),
361+
target: host.to_string(),
362+
});
363+
}
348364
if rls_present {
349365
extensions.push(Component {
350366
pkg: "rls-preview".to_string(),
@@ -470,6 +486,8 @@ impl Builder {
470486
format!("cargo-{}-{}.tar.gz", self.cargo_release, target)
471487
} else if component == "rls" || component == "rls-preview" {
472488
format!("rls-{}-{}.tar.gz", self.rls_release, target)
489+
} else if component == "clippy" || component == "clippy-preview" {
490+
format!("clippy-{}-{}.tar.gz", self.clippy_release, target)
473491
} else if component == "rustfmt" || component == "rustfmt-preview" {
474492
format!("rustfmt-{}-{}.tar.gz", self.rustfmt_release, target)
475493
} else if component == "llvm_tools" {
@@ -484,6 +502,8 @@ impl Builder {
484502
&self.cargo_version
485503
} else if component == "rls" || component == "rls-preview" {
486504
&self.rls_version
505+
} else if component == "clippy" || component == "clippy-preview" {
506+
&self.clippy_version
487507
} else if component == "rustfmt" || component == "rustfmt-preview" {
488508
&self.rustfmt_version
489509
} else if component == "llvm-tools" || component == "llvm-tools-preview" {
@@ -498,6 +518,8 @@ impl Builder {
498518
&self.cargo_git_commit_hash
499519
} else if component == "rls" || component == "rls-preview" {
500520
&self.rls_git_commit_hash
521+
} else if component == "clippy" || component == "clippy-preview" {
522+
&self.clippy_git_commit_hash
501523
} else if component == "rustfmt" || component == "rustfmt-preview" {
502524
&self.rustfmt_git_commit_hash
503525
} else if component == "llvm-tools" || component == "llvm-tools-preview" {

‎src/tools/clippy

0 commit comments

Comments
 (0)
Please sign in to comment.