Skip to content

Commit eac3c7c

Browse files
committed
Auto merge of rust-lang#82208 - jyn514:rustfmt-subtree, r=Mark-Simulacrum
Convert rustfmt from a submodule to a subtree r? `@calebcartwright` cc `@Manishearth` `@Mark-Simulacrum` The motivation is that submodule updates cause rustfmt to not be available on nightly a lot; most recently it was unavailable for over 10 days, causing the beta release to be delayed. Additionally this is much less work on the part of the rustfmt maintainers to keep the rustfmt compiling, since now people making breaking changes will be responsible for fixing them. I kept the rustfmt git history so it looks like there are thousands of commits. The important commits are https://github.com/rust-lang/rust/compare/851dee3af9404bf399c3c4ffefe5105edb3debad~..pull/82208/head. This adds about 10 MB of git history, which is not terribly much compared to the 702 MB that already exist. - Add `src/tools/rustfmt` to `x.py check` - Fix CRLF issues with rustfmt tests (see commit for details) - Use `rustc_private` instead of crates.io dependencies This was already switched upstream and would have landed in the next submodule bump anyway. This just updates Cargo.lock for rust-lang/rust. - Add `yansi-term` to the list of allowed dependencies. This is a false positive - rustc doesn't actually use it, only rustfmt, but because it's activated by the cargo feature of a dependency, tidy gets confused. It's fairly innocuous in any case, it's used for color printing. This would have happened in the next submodule bump. - Remove rustfmt from the list of toolstate tools. - Give a hard error if testing or building rustfmt fails. - Update log to 0.4.14 This avoids a warning about semicolons in macros; see the commit for details. - Don't add tools to the sysroot when they finish building. This is the only change that could be considered a regression - this avoids a "colliding StableCrateId" error due to a bug in resolve (rust-lang#56935). The regression is that this rebuilds dependencies more often than strictly necessary. See the commit for details. Fixes rust-lang#85226 (permanently). Closes rust-lang#82385. Helps with rust-lang#70651. Helps with rust-lang#80639.
2 parents 2a245f4 + 34368ec commit eac3c7c

File tree

1,276 files changed

+78110
-37
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,276 files changed

+78110
-37
lines changed

.gitattributes

+8
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ config.toml.example linguist-language=TOML
1616
*.ico binary
1717
*.woff binary
1818
*.woff2 binary
19+
20+
# Needed as part of converting rustfmt to a subtree, can hopefully be removed later.
21+
src/tools/rustfmt/tests/source/issue-3494/crlf.rs -text
22+
src/tools/rustfmt/tests/source/comment_crlf_newline.rs -text
23+
src/tools/rustfmt/tests/source/configs/enum_discrim_align_threshold/40.rs -text
24+
src/tools/rustfmt/tests/target/issue-3494/crlf.rs -text
25+
src/tools/rustfmt/tests/target/comment_crlf_newline.rs -text
26+
src/tools/rustfmt/tests/target/configs/enum_discrim_align_threshold/40.rs -text

.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/rustfmt"]
20-
path = src/tools/rustfmt
21-
url = https://github.com/rust-lang/rustfmt.git
2219
[submodule "src/tools/miri"]
2320
path = src/tools/miri
2421
url = https://github.com/rust-lang/miri.git

Cargo.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -1985,11 +1985,11 @@ dependencies = [
19851985

19861986
[[package]]
19871987
name = "log"
1988-
version = "0.4.11"
1988+
version = "0.4.14"
19891989
source = "registry+https://github.com/rust-lang/crates.io-index"
1990-
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
1990+
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
19911991
dependencies = [
1992-
"cfg-if 0.1.10",
1992+
"cfg-if 1.0.0",
19931993
]
19941994

19951995
[[package]]

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ impl<'a> Builder<'a> {
379379
check::Clippy,
380380
check::Miri,
381381
check::Rls,
382+
check::Rustfmt,
382383
check::Bootstrap
383384
),
384385
Kind::Test => describe!(

src/bootstrap/check.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,6 @@ macro_rules! tool_check_step {
342342
true,
343343
);
344344

345-
let libdir = builder.sysroot_libdir(compiler, target);
346-
let hostdir = builder.sysroot_libdir(compiler, compiler.host);
347-
add_to_sysroot(&builder, &libdir, &hostdir, &stamp(builder, compiler, target));
348-
349345
/// Cargo's output path in a given stage, compiled by a particular
350346
/// compiler for the specified target.
351347
fn stamp(
@@ -363,13 +359,14 @@ macro_rules! tool_check_step {
363359
}
364360

365361
tool_check_step!(Rustdoc, "src/tools/rustdoc", "src/librustdoc", SourceType::InTree);
366-
// Clippy is a hybrid. It is an external tool, but uses a git subtree instead
362+
// Clippy and Rustfmt are hybrids. They are external tools, but use a git subtree instead
367363
// of a submodule. Since the SourceType only drives the deny-warnings
368364
// behavior, treat it as in-tree so that any new warnings in clippy will be
369365
// rejected.
370366
tool_check_step!(Clippy, "src/tools/clippy", SourceType::InTree);
371367
tool_check_step!(Miri, "src/tools/miri", SourceType::Submodule);
372368
tool_check_step!(Rls, "src/tools/rls", SourceType::Submodule);
369+
tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree);
373370

374371
tool_check_step!(Bootstrap, "src/bootstrap", SourceType::InTree, false);
375372

src/bootstrap/test.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,9 @@ impl Step for Rustfmt {
319319
let host = self.host;
320320
let compiler = builder.compiler(stage, host);
321321

322-
let build_result = builder.ensure(tool::Rustfmt {
323-
compiler,
324-
target: self.host,
325-
extra_features: Vec::new(),
326-
});
327-
if build_result.is_none() {
328-
eprintln!("failed to test rustfmt: could not build");
329-
return;
330-
}
322+
builder
323+
.ensure(tool::Rustfmt { compiler, target: self.host, extra_features: Vec::new() })
324+
.expect("in-tree tool");
331325

332326
let mut cargo = tool::prepare_tool_cargo(
333327
builder,
@@ -346,9 +340,7 @@ impl Step for Rustfmt {
346340

347341
cargo.add_rustc_lib_path(builder, compiler);
348342

349-
if try_run(builder, &mut cargo.into()) {
350-
builder.save_toolstate("rustfmt", ToolState::TestPass);
351-
}
343+
builder.run(&mut cargo.into());
352344
}
353345
}
354346

src/bootstrap/tool.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ macro_rules! tool_extended {
726726
// Note: tools need to be also added to `Builder::get_step_descriptions` in `builder.rs`
727727
// to make `./x.py build <tool>` work.
728728
tool_extended!((self, builder),
729-
Cargofmt, rustfmt, "src/tools/rustfmt", "cargo-fmt", stable=true, {};
729+
Cargofmt, rustfmt, "src/tools/rustfmt", "cargo-fmt", stable=true, in_tree=true, {};
730730
CargoClippy, clippy, "src/tools/clippy", "cargo-clippy", stable=true, in_tree=true, {};
731731
Clippy, clippy, "src/tools/clippy", "clippy-driver", stable=true, in_tree=true, {};
732732
Miri, miri, "src/tools/miri", "miri", stable=false, {};
@@ -740,7 +740,7 @@ tool_extended!((self, builder),
740740
self.extra_features.push("clippy".to_owned());
741741
};
742742
RustDemangler, rust_demangler, "src/tools/rust-demangler", "rust-demangler", stable=false, in_tree=true, {};
743-
Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, {};
743+
Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, in_tree=true, {};
744744
RustAnalyzer, rust_analyzer, "src/tools/rust-analyzer/crates/rust-analyzer", "rust-analyzer", stable=false, {};
745745
);
746746

src/bootstrap/toolstate.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ static STABLE_TOOLS: &[(&str, &str)] = &[
7777
("rust-by-example", "src/doc/rust-by-example"),
7878
("edition-guide", "src/doc/edition-guide"),
7979
("rls", "src/tools/rls"),
80-
("rustfmt", "src/tools/rustfmt"),
8180
];
8281

8382
// These tools are permitted to not build on the beta/stable channels.
@@ -278,10 +277,9 @@ impl Builder<'_> {
278277
if self.config.dry_run {
279278
return;
280279
}
281-
// Toolstate isn't tracked for clippy, but since most tools do, we avoid
282-
// checking in all the places we could save toolstate and just do so
283-
// here.
284-
if tool == "clippy-driver" {
280+
// Toolstate isn't tracked for clippy or rustfmt, but since most tools do, we avoid checking
281+
// in all the places we could save toolstate and just do so here.
282+
if tool == "clippy-driver" || tool == "rustfmt" {
285283
return;
286284
}
287285
if let Some(ref path) = self.config.save_toolstates {

src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ python3 "$X_PY" test --stage 2 --no-fail-fast \
1515
src/doc/embedded-book \
1616
src/doc/edition-guide \
1717
src/tools/rls \
18-
src/tools/rustfmt \
1918
src/tools/miri \
2019

2120
set -e
@@ -24,3 +23,4 @@ set -e
2423
cat /tmp/toolstate/toolstates.json
2524
python3 "$X_PY" test --stage 2 check-tools
2625
python3 "$X_PY" test --stage 2 src/tools/clippy
26+
python3 "$X_PY" test --stage 2 src/tools/rustfmt

src/ci/scripts/should-skip-this.sh

+13-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,23 @@ source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
1010

1111
if [[ -z "${CI_ONLY_WHEN_SUBMODULES_CHANGED+x}" ]]; then
1212
echo "Executing the job since there is no skip rule in effect"
13-
elif git diff HEAD^ | grep --quiet "^index .* 160000"; then
13+
exit 0
14+
fi
15+
16+
git fetch "https://github.com/$GITHUB_REPOSITORY" "$GITHUB_BASE_REF"
17+
BASE_COMMIT="$(git merge-base FETCH_HEAD HEAD)"
18+
19+
echo "Searching for toolstate changes between $BASE_COMMIT and $(git rev-parse HEAD)"
20+
21+
if git diff "$BASE_COMMIT" | grep --quiet "^index .* 160000"; then
1422
# Submodules pseudo-files inside git have the 160000 permissions, so when
1523
# those files are present in the diff a submodule was updated.
1624
echo "Executing the job since submodules are updated"
17-
elif git diff --name-only HEAD^ | grep --quiet src/tools/clippy; then
25+
elif ! git diff --quiet "$BASE_COMMIT" -- src/tools/clippy src/tools/rustfmt; then
1826
# There is not an easy blanket search for subtrees. For now, manually list
19-
# clippy.
20-
echo "Executing the job since clippy subtree was updated"
27+
# the subtrees.
28+
echo "Executing the job since clippy or rustfmt subtree was updated"
2129
else
22-
echo "Not executing this job since no submodules were updated"
30+
echo "Not executing this job since no submodules nor subtrees were updated"
2331
ciCommandSetEnv SKIP_JOB 1
2432
fi

src/tools/rustfmt

-1
This file was deleted.

src/tools/rustfmt/.editorconfig

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = space
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.rs]
15+
indent_size = 4
16+
17+
[tests/**/*.rs]
18+
charset = utf-8
19+
end_of_line = unset
20+
indent_size = unset
21+
indent_style = unset
22+
trim_trailing_whitespace = unset
23+
insert_final_newline = unset
24+
25+
[appveyor.yml]
26+
end_of_line = unset

src/tools/rustfmt/.gitattributes

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
* text=auto eol=lf
2+
tests/source/issue-3494/crlf.rs -text
3+
tests/source/comment_crlf_newline.rs -text
4+
tests/source/configs/enum_discrim_align_threshold/40.rs -text
5+
tests/target/issue-3494/crlf.rs -text
6+
tests/target/comment_crlf_newline.rs -text
7+
tests/target/configs/enum_discrim_align_threshold/40.rs -text
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: integration
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
8+
jobs:
9+
integration-tests:
10+
runs-on: ubuntu-latest
11+
name: ${{ matrix.integration }}
12+
strategy:
13+
# https://help.github.com/en/actions/getting-started-with-github-actions/about-github-actions#usage-limits
14+
# There's a limit of 60 concurrent jobs across all repos in the rust-lang organization.
15+
# In order to prevent overusing too much of that 60 limit, we throttle the
16+
# number of rustfmt jobs that will run concurrently.
17+
max-parallel: 4
18+
fail-fast: false
19+
matrix:
20+
integration: [
21+
bitflags,
22+
error-chain,
23+
log,
24+
mdbook,
25+
packed_simd,
26+
rust-semverver,
27+
tempdir,
28+
futures-rs,
29+
rust-clippy,
30+
failure,
31+
]
32+
include:
33+
# Allowed Failures
34+
# Actions doesn't yet support explicitly marking matrix legs as allowed failures
35+
# https://github.community/t5/GitHub-Actions/continue-on-error-allow-failure-UI-indication/td-p/37033
36+
# https://github.community/t5/GitHub-Actions/Why-a-matrix-step-will-be-canceled-if-another-one-failed/td-p/30920
37+
# Instead, leverage `continue-on-error`
38+
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error
39+
#
40+
# Failing due to breaking changes in rustfmt 2.0 where empty
41+
# match blocks have trailing commas removed
42+
# https://github.com/rust-lang/rustfmt/pull/4226
43+
- integration: chalk
44+
allow-failure: true
45+
- integration: crater
46+
allow-failure: true
47+
- integration: glob
48+
allow-failure: true
49+
- integration: stdsimd
50+
allow-failure: true
51+
# Using old rustfmt configuration option
52+
- integration: rand
53+
allow-failure: true
54+
# Keep this as an allowed failure as it's fragile to breaking changes of rustc.
55+
- integration: rust-clippy
56+
allow-failure: true
57+
# Using old rustfmt configuration option
58+
- integration: packed_simd
59+
allow-failure: true
60+
# calebcartwright (2019-12-24)
61+
# Keeping this as an allowed failure since it was flagged as such in the TravisCI config, even though
62+
# it appears to have been passing for quite some time.
63+
# Original comment was: temporal build failure due to breaking changes in the nightly compiler
64+
- integration: rust-semverver
65+
allow-failure: true
66+
# Can be moved back to include section after https://github.com/rust-lang-nursery/failure/pull/298 is merged
67+
- integration: failure
68+
allow-failure: true
69+
70+
steps:
71+
- name: checkout
72+
uses: actions/checkout@v2
73+
74+
# Run build
75+
- name: install rustup
76+
run: |
77+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
78+
sh rustup-init.sh -y --default-toolchain none
79+
80+
- name: run integration tests
81+
env:
82+
INTEGRATION: ${{ matrix.integration }}
83+
TARGET: x86_64-unknown-linux-gnu
84+
run: ./ci/integration.sh
85+
continue-on-error: ${{ matrix.allow-failure == true }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: linux
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
name: (${{ matrix.target }}, nightly)
12+
strategy:
13+
# https://help.github.com/en/actions/getting-started-with-github-actions/about-github-actions#usage-limits
14+
# There's a limit of 60 concurrent jobs across all repos in the rust-lang organization.
15+
# In order to prevent overusing too much of that 60 limit, we throttle the
16+
# number of rustfmt jobs that will run concurrently.
17+
max-parallel: 1
18+
fail-fast: false
19+
matrix:
20+
target: [
21+
x86_64-unknown-linux-gnu,
22+
]
23+
24+
steps:
25+
- name: checkout
26+
uses: actions/checkout@v2
27+
28+
# Run build
29+
- name: install rustup
30+
run: |
31+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
32+
sh rustup-init.sh -y --default-toolchain none
33+
rustup target add ${{ matrix.target }}
34+
35+
- name: build
36+
run: |
37+
rustc -Vv
38+
cargo -V
39+
cargo build
40+
41+
- name: test
42+
run: cargo test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: mac
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners#supported-runners-and-hardware-resources
11+
# macOS Catalina 10.15
12+
runs-on: macos-latest
13+
name: (${{ matrix.target }}, nightly)
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
target: [
18+
x86_64-apple-darwin,
19+
]
20+
21+
steps:
22+
- name: checkout
23+
uses: actions/checkout@v2
24+
25+
# Run build
26+
- name: install rustup
27+
run: |
28+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
29+
sh rustup-init.sh -y --default-toolchain none
30+
rustup target add ${{ matrix.target }}
31+
32+
- name: build
33+
run: |
34+
rustc -Vv
35+
cargo -V
36+
cargo build
37+
38+
- name: test
39+
run: cargo test

0 commit comments

Comments
 (0)