Skip to content

Commit 53d3bc0

Browse files
committed
Auto merge of rust-lang#70655 - oli-obk:subrepo_funness, r=Mark-Simulacrum
Make clippy a git subtree instead of a git submodule r? @eddyb cc rust-lang#70651 documentation at rust-lang#70654
2 parents 7184d13 + bce9fae commit 53d3bc0

File tree

1,294 files changed

+114583
-133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,294 files changed

+114583
-133
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
[submodule "src/tools/rls"]
1717
path = src/tools/rls
1818
url = https://github.com/rust-lang/rls.git
19-
[submodule "src/tools/clippy"]
20-
path = src/tools/clippy
21-
url = https://github.com/rust-lang/rust-clippy.git
2219
[submodule "src/tools/rustfmt"]
2320
path = src/tools/rustfmt
2421
url = https://github.com/rust-lang/rustfmt.git

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl<'a> Builder<'a> {
351351
native::Lld
352352
),
353353
Kind::Check | Kind::Clippy | Kind::Fix | Kind::Format => {
354-
describe!(check::Std, check::Rustc, check::Rustdoc)
354+
describe!(check::Std, check::Rustc, check::Rustdoc, check::Clippy)
355355
}
356356
Kind::Test => describe!(
357357
crate::toolstate::ToolStateCheck,

src/bootstrap/check.rs

+74-68
Original file line numberDiff line numberDiff line change
@@ -112,83 +112,89 @@ impl Step for Rustc {
112112
}
113113
}
114114

115-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
116-
pub struct Rustdoc {
117-
pub target: Interned<String>,
115+
macro_rules! tool_check_step {
116+
($name:ident, $path:expr) => {
117+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
118+
pub struct $name {
119+
pub target: Interned<String>,
120+
}
121+
122+
impl Step for $name {
123+
type Output = ();
124+
const ONLY_HOSTS: bool = true;
125+
const DEFAULT: bool = true;
126+
127+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
128+
run.path($path)
129+
}
130+
131+
fn make_run(run: RunConfig<'_>) {
132+
run.builder.ensure($name { target: run.target });
133+
}
134+
135+
fn run(self, builder: &Builder<'_>) {
136+
let compiler = builder.compiler(0, builder.config.build);
137+
let target = self.target;
138+
139+
builder.ensure(Rustc { target });
140+
141+
let cargo = prepare_tool_cargo(
142+
builder,
143+
compiler,
144+
Mode::ToolRustc,
145+
target,
146+
cargo_subcommand(builder.kind),
147+
$path,
148+
SourceType::InTree,
149+
&[],
150+
);
151+
152+
println!(
153+
"Checking {} artifacts ({} -> {})",
154+
stringify!($name).to_lowercase(),
155+
&compiler.host,
156+
target
157+
);
158+
run_cargo(
159+
builder,
160+
cargo,
161+
args(builder.kind),
162+
&stamp(builder, compiler, target),
163+
vec![],
164+
true,
165+
);
166+
167+
let libdir = builder.sysroot_libdir(compiler, target);
168+
let hostdir = builder.sysroot_libdir(compiler, compiler.host);
169+
add_to_sysroot(&builder, &libdir, &hostdir, &stamp(builder, compiler, target));
170+
171+
/// Cargo's output path in a given stage, compiled by a particular
172+
/// compiler for the specified target.
173+
fn stamp(
174+
builder: &Builder<'_>,
175+
compiler: Compiler,
176+
target: Interned<String>,
177+
) -> PathBuf {
178+
builder
179+
.cargo_out(compiler, Mode::ToolRustc, target)
180+
.join(format!(".{}-check.stamp", stringify!($name).to_lowercase()))
181+
}
182+
}
183+
}
184+
};
118185
}
119186

120-
impl Step for Rustdoc {
121-
type Output = ();
122-
const ONLY_HOSTS: bool = true;
123-
const DEFAULT: bool = true;
124-
125-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
126-
run.path("src/tools/rustdoc")
127-
}
128-
129-
fn make_run(run: RunConfig<'_>) {
130-
run.builder.ensure(Rustdoc { target: run.target });
131-
}
132-
133-
fn run(self, builder: &Builder<'_>) {
134-
let compiler = builder.compiler(0, builder.config.build);
135-
let target = self.target;
136-
137-
builder.ensure(Rustc { target });
138-
139-
let cargo = prepare_tool_cargo(
140-
builder,
141-
compiler,
142-
Mode::ToolRustc,
143-
target,
144-
cargo_subcommand(builder.kind),
145-
"src/tools/rustdoc",
146-
SourceType::InTree,
147-
&[],
148-
);
149-
150-
println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);
151-
run_cargo(
152-
builder,
153-
cargo,
154-
args(builder.kind),
155-
&rustdoc_stamp(builder, compiler, target),
156-
vec![],
157-
true,
158-
);
159-
160-
let libdir = builder.sysroot_libdir(compiler, target);
161-
let hostdir = builder.sysroot_libdir(compiler, compiler.host);
162-
add_to_sysroot(&builder, &libdir, &hostdir, &rustdoc_stamp(builder, compiler, target));
163-
}
164-
}
187+
tool_check_step!(Rustdoc, "src/tools/rustdoc");
188+
tool_check_step!(Clippy, "src/tools/clippy");
165189

166190
/// Cargo's output path for the standard library in a given stage, compiled
167191
/// by a particular compiler for the specified target.
168-
pub fn libstd_stamp(
169-
builder: &Builder<'_>,
170-
compiler: Compiler,
171-
target: Interned<String>,
172-
) -> PathBuf {
192+
fn libstd_stamp(builder: &Builder<'_>, compiler: Compiler, target: Interned<String>) -> PathBuf {
173193
builder.cargo_out(compiler, Mode::Std, target).join(".libstd-check.stamp")
174194
}
175195

176196
/// Cargo's output path for librustc in a given stage, compiled by a particular
177197
/// compiler for the specified target.
178-
pub fn librustc_stamp(
179-
builder: &Builder<'_>,
180-
compiler: Compiler,
181-
target: Interned<String>,
182-
) -> PathBuf {
198+
fn librustc_stamp(builder: &Builder<'_>, compiler: Compiler, target: Interned<String>) -> PathBuf {
183199
builder.cargo_out(compiler, Mode::Rustc, target).join(".librustc-check.stamp")
184200
}
185-
186-
/// Cargo's output path for rustdoc in a given stage, compiled by a particular
187-
/// compiler for the specified target.
188-
pub fn rustdoc_stamp(
189-
builder: &Builder<'_>,
190-
compiler: Compiler,
191-
target: Interned<String>,
192-
) -> PathBuf {
193-
builder.cargo_out(compiler, Mode::ToolRustc, target).join(".rustdoc-check.stamp")
194-
}

src/bootstrap/dist.rs

+28-49
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ pub struct Clippy {
13301330
}
13311331

13321332
impl Step for Clippy {
1333-
type Output = Option<PathBuf>;
1333+
type Output = PathBuf;
13341334
const ONLY_HOSTS: bool = true;
13351335

13361336
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -1348,7 +1348,7 @@ impl Step for Clippy {
13481348
});
13491349
}
13501350

1351-
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
1351+
fn run(self, builder: &Builder<'_>) -> PathBuf {
13521352
let compiler = self.compiler;
13531353
let target = self.target;
13541354
assert!(builder.config.extended);
@@ -1368,16 +1368,10 @@ impl Step for Clippy {
13681368
// state for clippy isn't testing.
13691369
let clippy = builder
13701370
.ensure(tool::Clippy { compiler, target, extra_features: Vec::new() })
1371-
.or_else(|| {
1372-
missing_tool("clippy", builder.build.config.missing_tools);
1373-
None
1374-
})?;
1371+
.expect("clippy expected to build - essential tool");
13751372
let cargoclippy = builder
13761373
.ensure(tool::CargoClippy { compiler, target, extra_features: Vec::new() })
1377-
.or_else(|| {
1378-
missing_tool("cargo clippy", builder.build.config.missing_tools);
1379-
None
1380-
})?;
1374+
.expect("clippy expected to build - essential tool");
13811375

13821376
builder.install(&clippy, &image.join("bin"), 0o755);
13831377
builder.install(&cargoclippy, &image.join("bin"), 0o755);
@@ -1416,7 +1410,7 @@ impl Step for Clippy {
14161410
builder.info(&format!("Dist clippy stage{} ({})", compiler.stage, target));
14171411
let _time = timeit(builder);
14181412
builder.run(&mut cmd);
1419-
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target)))
1413+
distdir(builder).join(format!("{}-{}.tar.gz", name, target))
14201414
}
14211415
}
14221416

@@ -1683,7 +1677,7 @@ impl Step for Extended {
16831677
tarballs.push(rustc_installer);
16841678
tarballs.push(cargo_installer);
16851679
tarballs.extend(rls_installer.clone());
1686-
tarballs.extend(clippy_installer.clone());
1680+
tarballs.push(clippy_installer);
16871681
tarballs.extend(miri_installer.clone());
16881682
tarballs.extend(rustfmt_installer.clone());
16891683
tarballs.extend(llvm_tools_installer);
@@ -1761,9 +1755,6 @@ impl Step for Extended {
17611755
if rls_installer.is_none() {
17621756
contents = filter(&contents, "rls");
17631757
}
1764-
if clippy_installer.is_none() {
1765-
contents = filter(&contents, "clippy");
1766-
}
17671758
if miri_installer.is_none() {
17681759
contents = filter(&contents, "miri");
17691760
}
@@ -1805,13 +1796,11 @@ impl Step for Extended {
18051796
prepare("rust-docs");
18061797
prepare("rust-std");
18071798
prepare("rust-analysis");
1799+
prepare("clippy");
18081800

18091801
if rls_installer.is_some() {
18101802
prepare("rls");
18111803
}
1812-
if clippy_installer.is_some() {
1813-
prepare("clippy");
1814-
}
18151804
if miri_installer.is_some() {
18161805
prepare("miri");
18171806
}
@@ -1863,12 +1852,10 @@ impl Step for Extended {
18631852
prepare("rust-analysis");
18641853
prepare("rust-docs");
18651854
prepare("rust-std");
1855+
prepare("clippy");
18661856
if rls_installer.is_some() {
18671857
prepare("rls");
18681858
}
1869-
if clippy_installer.is_some() {
1870-
prepare("clippy");
1871-
}
18721859
if miri_installer.is_some() {
18731860
prepare("miri");
18741861
}
@@ -1989,25 +1976,23 @@ impl Step for Extended {
19891976
.arg(etc.join("msi/remove-duplicates.xsl")),
19901977
);
19911978
}
1992-
if clippy_installer.is_some() {
1993-
builder.run(
1994-
Command::new(&heat)
1995-
.current_dir(&exe)
1996-
.arg("dir")
1997-
.arg("clippy")
1998-
.args(&heat_flags)
1999-
.arg("-cg")
2000-
.arg("ClippyGroup")
2001-
.arg("-dr")
2002-
.arg("Clippy")
2003-
.arg("-var")
2004-
.arg("var.ClippyDir")
2005-
.arg("-out")
2006-
.arg(exe.join("ClippyGroup.wxs"))
2007-
.arg("-t")
2008-
.arg(etc.join("msi/remove-duplicates.xsl")),
2009-
);
2010-
}
1979+
builder.run(
1980+
Command::new(&heat)
1981+
.current_dir(&exe)
1982+
.arg("dir")
1983+
.arg("clippy")
1984+
.args(&heat_flags)
1985+
.arg("-cg")
1986+
.arg("ClippyGroup")
1987+
.arg("-dr")
1988+
.arg("Clippy")
1989+
.arg("-var")
1990+
.arg("var.ClippyDir")
1991+
.arg("-out")
1992+
.arg(exe.join("ClippyGroup.wxs"))
1993+
.arg("-t")
1994+
.arg(etc.join("msi/remove-duplicates.xsl")),
1995+
);
20111996
if miri_installer.is_some() {
20121997
builder.run(
20131998
Command::new(&heat)
@@ -2073,6 +2058,7 @@ impl Step for Extended {
20732058
.arg("-dCargoDir=cargo")
20742059
.arg("-dStdDir=rust-std")
20752060
.arg("-dAnalysisDir=rust-analysis")
2061+
.arg("-dClippyDir=clippy")
20762062
.arg("-arch")
20772063
.arg(&arch)
20782064
.arg("-out")
@@ -2083,9 +2069,6 @@ impl Step for Extended {
20832069
if rls_installer.is_some() {
20842070
cmd.arg("-dRlsDir=rls");
20852071
}
2086-
if clippy_installer.is_some() {
2087-
cmd.arg("-dClippyDir=clippy");
2088-
}
20892072
if miri_installer.is_some() {
20902073
cmd.arg("-dMiriDir=miri");
20912074
}
@@ -2101,12 +2084,10 @@ impl Step for Extended {
21012084
candle("DocsGroup.wxs".as_ref());
21022085
candle("CargoGroup.wxs".as_ref());
21032086
candle("StdGroup.wxs".as_ref());
2087+
candle("ClippyGroup.wxs".as_ref());
21042088
if rls_installer.is_some() {
21052089
candle("RlsGroup.wxs".as_ref());
21062090
}
2107-
if clippy_installer.is_some() {
2108-
candle("ClippyGroup.wxs".as_ref());
2109-
}
21102091
if miri_installer.is_some() {
21112092
candle("MiriGroup.wxs".as_ref());
21122093
}
@@ -2138,14 +2119,12 @@ impl Step for Extended {
21382119
.arg("CargoGroup.wixobj")
21392120
.arg("StdGroup.wixobj")
21402121
.arg("AnalysisGroup.wixobj")
2122+
.arg("ClippyGroup.wixobj")
21412123
.current_dir(&exe);
21422124

21432125
if rls_installer.is_some() {
21442126
cmd.arg("RlsGroup.wixobj");
21452127
}
2146-
if clippy_installer.is_some() {
2147-
cmd.arg("ClippyGroup.wixobj");
2148-
}
21492128
if miri_installer.is_some() {
21502129
cmd.arg("MiriGroup.wixobj");
21512130
}

src/bootstrap/install.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,8 @@ install!((self, builder, _config),
214214
}
215215
};
216216
Clippy, "clippy", Self::should_build(_config), only_hosts: true, {
217-
if builder.ensure(dist::Clippy {
218-
compiler: self.compiler,
219-
target: self.target,
220-
}).is_some() || Self::should_install(builder) {
217+
builder.ensure(dist::Clippy { compiler: self.compiler, target: self.target });
218+
if Self::should_install(builder) {
221219
install_clippy(builder, self.compiler.stage, self.target);
222220
} else {
223221
builder.info(

src/bootstrap/test.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,7 @@ impl Step for Clippy {
548548

549549
builder.add_rustc_lib_path(compiler, &mut cargo);
550550

551-
if try_run(builder, &mut cargo.into()) {
552-
builder.save_toolstate("clippy-driver", ToolState::TestPass);
553-
}
551+
try_run(builder, &mut cargo.into());
554552
} else {
555553
eprintln!("failed to test clippy: could not build");
556554
}

0 commit comments

Comments
 (0)