Skip to content

Commit 204c0a4

Browse files
committed
Auto merge of #43886 - oli-obk:clippy, r=nrc
Add clippy as a submodule ~~This builds clippy as part of `./x.py build` (locally and in CI).~~ This allows building clippy with `./x.py build src/tools/clippy` ~~Needs rust-dev-tools/dev-tools-team#18 (comment) to be resolved before it can be merged.~~ Contributers can simply open a PR to clippy and point the submodule at the `pull/$pr_number/head` branch. This does **not** build clippy or test the clippy test suite at all as per rust-dev-tools/dev-tools-team#18 (comment) r? @nrc cc @Manishearth @llogiq @mcarton @alexcrichton
2 parents 8d83c15 + 20f1e68 commit 204c0a4

File tree

6 files changed

+70
-1
lines changed

6 files changed

+70
-1
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@
3333
[submodule "src/libcompiler_builtins"]
3434
path = src/libcompiler_builtins
3535
url = https://github.com/rust-lang-nursery/compiler-builtins
36+
[submodule "src/tools/clippy"]
37+
path = src/tools/clippy
38+
url = https://github.com/rust-lang-nursery/rust-clippy.git

CONTRIBUTING.md

+26
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,32 @@ Speaking of tests, Rust has a comprehensive test suite. More information about
298298
it can be found
299299
[here](https://github.com/rust-lang/rust-wiki-backup/blob/master/Note-testsuite.md).
300300

301+
### External Dependencies
302+
303+
Currently building Rust will also build the following external projects:
304+
305+
* [clippy](https://github.com/rust-lang-nursery/rust-clippy)
306+
307+
If your changes break one of these projects, you need to fix them by opening
308+
a pull request against the broken project. When you have opened a pull request,
309+
you can point the submodule at your pull request by calling
310+
311+
```
312+
git fetch origin pull/$id_of_your_pr/head:my_pr
313+
git checkout my_pr
314+
```
315+
316+
within the submodule's directory. Don't forget to also add your changes with
317+
318+
```
319+
git add path/to/submodule
320+
```
321+
322+
outside the submodule.
323+
324+
It can also be more convenient during development to set `submodules = false`
325+
in the `config.toml` to prevent `x.py` from resetting to the original branch.
326+
301327
## Writing Documentation
302328

303329
Documentation improvements are very welcome. The source of `doc.rust-lang.org`

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl<'a> Builder<'a> {
248248
compile::StartupObjects, tool::BuildManifest, tool::Rustbook, tool::ErrorIndex,
249249
tool::UnstableBookGen, tool::Tidy, tool::Linkchecker, tool::CargoTest,
250250
tool::Compiletest, tool::RemoteTestServer, tool::RemoteTestClient,
251-
tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc,
251+
tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc, tool::Clippy,
252252
native::Llvm),
253253
Kind::Test => describe!(check::Tidy, check::Bootstrap, check::DefaultCompiletest,
254254
check::HostCompiletest, check::Crate, check::CrateLibrustc, check::Linkcheck,

src/bootstrap/tool.rs

+38
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,44 @@ impl Step for Cargo {
340340
}
341341
}
342342

343+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
344+
pub struct Clippy {
345+
pub compiler: Compiler,
346+
pub target: Interned<String>,
347+
}
348+
349+
impl Step for Clippy {
350+
type Output = PathBuf;
351+
const DEFAULT: bool = false;
352+
const ONLY_HOSTS: bool = true;
353+
354+
fn should_run(run: ShouldRun) -> ShouldRun {
355+
run.path("src/tools/clippy")
356+
}
357+
358+
fn make_run(run: RunConfig) {
359+
run.builder.ensure(Clippy {
360+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
361+
target: run.target,
362+
});
363+
}
364+
365+
fn run(self, builder: &Builder) -> PathBuf {
366+
// Clippy depends on procedural macros (serde), which requires a full host
367+
// compiler to be available, so we need to depend on that.
368+
builder.ensure(compile::Rustc {
369+
compiler: self.compiler,
370+
target: builder.build.build,
371+
});
372+
builder.ensure(ToolBuild {
373+
compiler: self.compiler,
374+
target: self.target,
375+
tool: "clippy",
376+
mode: Mode::Librustc,
377+
})
378+
}
379+
}
380+
343381
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
344382
pub struct Rls {
345383
pub compiler: Compiler,

src/tools/clippy

Submodule clippy added at 4402bc7

src/tools/tidy/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ fn filter_dirs(path: &Path) -> bool {
6262
"src/rt/hoedown",
6363
"src/tools/cargo",
6464
"src/tools/rls",
65+
"src/tools/clippy",
6566
"src/tools/rust-installer",
6667
];
6768
skip.iter().any(|p| path.ends_with(p))

0 commit comments

Comments
 (0)