Skip to content

Commit 1b55d19

Browse files
committed
Auto merge of #44679 - oli-obk:clippy_ci, r=alexcrichton
Add clippy to `toolstate.toml` r? @alexcrichton cc @Manishearth I have no idea how to get clippy working... it needs proc macros, and I think I did everything right (I just did what the cargo step is doing), but it's not working: ``` error: libproc_macro-6210e4b46662ec28.so: cannot open shared object file: No such file or directory --> src/tools/clippy/clippy_lints/src/lib.rs:47:1 | 47 | extern crate serde_derive; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: libproc_macro-6210e4b46662ec28.so: cannot open shared object file: No such file or directory --> src/tools/clippy/clippy_lints/src/lib.rs:47:1 | 47 | extern crate serde_derive; | ^ ``` It's especially weird since it used to work Anyway. Fixing it can be left for a future PR, this one adds it to CI, but marks it as "broken"
2 parents 35edf7d + 7d7e7d4 commit 1b55d19

File tree

6 files changed

+59
-21
lines changed

6 files changed

+59
-21
lines changed

CONTRIBUTING.md

+2-14
Original file line numberDiff line numberDiff line change
@@ -330,23 +330,11 @@ it can be found
330330
Currently building Rust will also build the following external projects:
331331

332332
* [clippy](https://github.com/rust-lang-nursery/rust-clippy)
333+
* [miri](https://github.com/solson/miri)
333334

334335
If your changes break one of these projects, you need to fix them by opening
335336
a pull request against the broken project. When you have opened a pull request,
336-
you can point the submodule at your pull request by calling
337-
338-
```
339-
git fetch origin pull/$id_of_your_pr/head:my_pr
340-
git checkout my_pr
341-
```
342-
343-
within the submodule's directory. Don't forget to also add your changes with
344-
345-
```
346-
git add path/to/submodule
347-
```
348-
349-
outside the submodule.
337+
you can disable the tool via `src/tools/toolstate.toml`.
350338

351339
It can also be more convenient during development to set `submodules = false`
352340
in the `config.toml` to prevent `x.py` from resetting to the original branch.

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl<'a> Builder<'a> {
254254
Kind::Test => describe!(check::Tidy, check::Bootstrap, check::DefaultCompiletest,
255255
check::HostCompiletest, check::Crate, check::CrateLibrustc, check::Rustdoc,
256256
check::Linkcheck, check::Cargotest, check::Cargo, check::Rls, check::Docs,
257-
check::ErrorIndex, check::Distcheck, check::Rustfmt, check::Miri),
257+
check::ErrorIndex, check::Distcheck, check::Rustfmt, check::Miri, check::Clippy),
258258
Kind::Bench => describe!(check::Crate, check::CrateLibrustc),
259259
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
260260
doc::Standalone, doc::Std, doc::Test, doc::Rustc, doc::ErrorIndex, doc::Nomicon,

src/bootstrap/check.rs

+44
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,50 @@ impl Step for Miri {
348348
}
349349
}
350350

351+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
352+
pub struct Clippy {
353+
host: Interned<String>,
354+
}
355+
356+
impl Step for Clippy {
357+
type Output = ();
358+
const ONLY_HOSTS: bool = true;
359+
const DEFAULT: bool = false;
360+
361+
fn should_run(run: ShouldRun) -> ShouldRun {
362+
run.path("src/tools/clippy")
363+
}
364+
365+
fn make_run(run: RunConfig) {
366+
run.builder.ensure(Clippy {
367+
host: run.target,
368+
});
369+
}
370+
371+
/// Runs `cargo test` for clippy.
372+
fn run(self, builder: &Builder) {
373+
let build = builder.build;
374+
let host = self.host;
375+
let compiler = builder.compiler(1, host);
376+
377+
let _clippy = builder.ensure(tool::Clippy { compiler, target: self.host });
378+
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
379+
cargo.arg("--manifest-path").arg(build.src.join("src/tools/clippy/Cargo.toml"));
380+
381+
// Don't build tests dynamically, just a pain to work with
382+
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
383+
// clippy tests need to know about the stage sysroot
384+
cargo.env("SYSROOT", builder.sysroot(compiler));
385+
386+
builder.add_rustc_lib_path(compiler, &mut cargo);
387+
388+
try_run_expecting(
389+
build,
390+
&mut cargo,
391+
builder.build.config.toolstate.clippy.passes(ToolState::Testing),
392+
);
393+
}
394+
}
351395

352396
fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString {
353397
// Configure PATH to find the right rustc. NB. we have to use PATH

src/bootstrap/tool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ impl Step for Clippy {
405405
tool: "clippy",
406406
mode: Mode::Librustc,
407407
path: "src/tools/clippy",
408-
expectation: BuildExpectation::None,
408+
expectation: builder.build.config.toolstate.clippy.passes(ToolState::Compiling),
409409
})
410410
}
411411
}

src/bootstrap/toolstate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ impl Default for ToolState {
4545
/// This is created from `toolstate.toml`.
4646
pub struct ToolStates {
4747
pub miri: ToolState,
48+
pub clippy: ToolState,
4849
}

src/tools/toolstate.toml

+10-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@
1010
# configures whether the tool is included in the Rust distribution.
1111
#
1212
# If a tool was working before your PR but is broken now, consider
13-
# updating the tool within your PR. How to do that is described in
13+
# opening a PR against the tool so that it works with your changes.
14+
# If the tool stops compiling, change its state to `Broken`. If it
15+
# still builds, change it to `Compiling`.
16+
# How to do that is described in
1417
# "CONTRIBUTING.md#External Dependencies". If the effort required is not
1518
# warranted (e.g. due to the tool abusing some API that you changed, and
16-
# fixing the tool would mean a significant refactoring), you can disable
17-
# the tool here, by changing its state to `Broken`. Remember to ping
18-
# the tool authors if you do not fix their tool, so they can proactively
19-
# fix it, instead of being surprised by the breakage.
19+
# fixing the tool would mean a significant refactoring) remember to ping
20+
# the tool authors, so they can fix it, instead of being surprised by the
21+
# breakage.
2022
#
2123
# Each tool has a list of people to ping
2224

2325
# ping @oli-obk @RalfJung @eddyb
2426
miri = "Testing"
27+
28+
# ping @Manishearth @llogiq @mcarton @oli-obk
29+
clippy = "Broken"

0 commit comments

Comments
 (0)