Skip to content

Commit bce9fae

Browse files
committed
Add 'src/tools/clippy/' from commit 'd2708873ef711ec8ab45df1e984ecf24a96cd369'
git-subtree-dir: src/tools/clippy git-subtree-mainline: 06c4481 git-subtree-split: d270887
2 parents 06c4481 + d270887 commit bce9fae

File tree

1,286 files changed

+114475
-0
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,286 files changed

+114475
-0
lines changed

src/tools/clippy/.cargo/config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[alias]
2+
uitest = "test --test compile-test"
3+
dev = "run --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
4+
5+
[build]
6+
rustflags = ["-Zunstable-options"]

src/tools/clippy/.editorconfig

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
indent_style = space
13+
indent_size = 4
14+
15+
[*.md]
16+
trim_trailing_whitespace = false
17+
18+
[*.yml]
19+
indent_size = 2

src/tools/clippy/.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto eol=lf
2+
*.rs text eol=lf whitespace=tab-in-indent,trailing-space,tabwidth=4
3+
*.fixed linguist-language=Rust
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!--
2+
Hi there! Whether you've come to make a suggestion for a new lint, an improvement to an existing lint or to report a bug or a false positive in Clippy, you've come to the right place.
3+
4+
For bug reports and false positives, please include the output of `cargo clippy -V` in the report.
5+
6+
Thank you for using Clippy!
7+
8+
Write your comment below this line: -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Thank you for making Clippy better!
2+
3+
We're collecting our changelog from pull request descriptions.
4+
If your PR only updates to the latest nightly, you can leave the
5+
`changelog` entry as `none`. Otherwise, please write a short comment
6+
explaining your change.
7+
8+
If your PR fixes an issue, you can add "fixes #issue_number" into this
9+
PR description. This way the issue will be automatically closed when
10+
your PR is merged.
11+
12+
If you added a new lint, here's a checklist for things that will be
13+
checked during review or continuous integration.
14+
15+
- [ ] Followed [lint naming conventions][lint_naming]
16+
- [ ] Added passing UI tests (including committed `.stderr` file)
17+
- [ ] `cargo test` passes locally
18+
- [ ] Executed `cargo dev update_lints`
19+
- [ ] Added lint documentation
20+
- [ ] Run `cargo dev fmt`
21+
22+
[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
23+
24+
Note that you can skip the above if you are just opening a WIP PR in
25+
order to get feedback.
26+
27+
Delete this line and everything above before opening your PR.
28+
29+
---
30+
31+
changelog: none

src/tools/clippy/.github/deploy.sh

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
echo "Removing the current docs for master"
6+
rm -rf out/master/ || exit 0
7+
8+
echo "Making the docs for master"
9+
mkdir out/master/
10+
cp util/gh-pages/index.html out/master
11+
python3 ./util/export.py out/master/lints.json
12+
13+
if [[ -n $TAG_NAME ]]; then
14+
echo "Save the doc for the current tag ($TAG_NAME) and point stable/ to it"
15+
cp -r out/master "out/$TAG_NAME"
16+
rm -f out/stable
17+
ln -s "$TAG_NAME" out/stable
18+
fi
19+
20+
if [[ $BETA = "true" ]]; then
21+
echo "Update documentation for the beta release"
22+
cp -r out/master out/beta
23+
fi
24+
25+
# Generate version index that is shown as root index page
26+
cp util/gh-pages/versions.html out/index.html
27+
28+
echo "Making the versions.json file"
29+
python3 ./util/versions.py out
30+
31+
cd out
32+
# Now let's go have some fun with the cloned repo
33+
git config user.name "GHA CI"
34+
git config user.email "[email protected]"
35+
36+
if git diff --exit-code --quiet; then
37+
echo "No changes to the output on this push; exiting."
38+
exit 0
39+
fi
40+
41+
if [[ -n $TAG_NAME ]]; then
42+
# Add the new dir
43+
git add "$TAG_NAME"
44+
# Update the symlink
45+
git add stable
46+
# Update versions file
47+
git add versions.json
48+
git commit -m "Add documentation for ${TAG_NAME} release: ${SHA}"
49+
elif [[ $BETA = "true" ]]; then
50+
git add beta
51+
git commit -m "Automatic deploy to GitHub Pages (beta): ${SHA}"
52+
else
53+
git add .
54+
git commit -m "Automatic deploy to GitHub Pages: ${SHA}"
55+
fi
56+
57+
git push "$SSH_REPO" "$TARGET_BRANCH"

src/tools/clippy/.github/driver.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
# Check sysroot handling
6+
sysroot=$(./target/debug/clippy-driver --print sysroot)
7+
test "$sysroot" = "$(rustc --print sysroot)"
8+
9+
if [[ ${OS} == "Windows" ]]; then
10+
desired_sysroot=C:/tmp
11+
else
12+
desired_sysroot=/tmp
13+
fi
14+
sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
15+
test "$sysroot" = $desired_sysroot
16+
17+
sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
18+
test "$sysroot" = $desired_sysroot
19+
20+
# Make sure this isn't set - clippy-driver should cope without it
21+
unset CARGO_MANIFEST_DIR
22+
23+
# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
24+
# FIXME: How to match the clippy invocation in compile-test.rs?
25+
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1
26+
sed -e "s,tests/ui,\$DIR," -e "/= help/d" cstring.stderr > normalized.stderr
27+
diff normalized.stderr tests/ui/cstring.stderr
28+
29+
# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Clippy Test
2+
3+
on:
4+
push:
5+
# Ignore bors branches, since they are covered by `clippy_bors.yml`
6+
branches-ignore:
7+
- auto
8+
- try
9+
# Don't run Clippy tests, when only textfiles were modified
10+
paths-ignore:
11+
- 'COPYRIGHT'
12+
- 'LICENSE-*'
13+
- '**.md'
14+
- '**.txt'
15+
pull_request:
16+
# Don't run Clippy tests, when only textfiles were modified
17+
paths-ignore:
18+
- 'COPYRIGHT'
19+
- 'LICENSE-*'
20+
- '**.md'
21+
- '**.txt'
22+
23+
env:
24+
RUST_BACKTRACE: 1
25+
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
26+
NO_FMT_TEST: 1
27+
28+
jobs:
29+
base:
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
# Setup
34+
- uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
35+
with:
36+
github_token: "${{ secrets.github_token }}"
37+
38+
- name: rust-toolchain
39+
uses: actions-rs/[email protected]
40+
with:
41+
toolchain: nightly
42+
target: x86_64-unknown-linux-gnu
43+
profile: minimal
44+
45+
- name: Checkout
46+
uses: actions/[email protected]
47+
48+
- name: Run cargo update
49+
run: cargo update
50+
51+
- name: Cache cargo dir
52+
uses: actions/cache@v1
53+
with:
54+
path: ~/.cargo
55+
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
56+
restore-keys: |
57+
${{ runner.os }}-x86_64-unknown-linux-gnu
58+
59+
- name: Master Toolchain Setup
60+
run: bash setup-toolchain.sh
61+
62+
# Run
63+
- name: Set LD_LIBRARY_PATH (Linux)
64+
run: |
65+
SYSROOT=$(rustc --print sysroot)
66+
echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}"
67+
68+
- name: Build
69+
run: cargo build --features deny-warnings
70+
71+
- name: Test
72+
run: cargo test --features deny-warnings
73+
74+
- name: Test clippy_lints
75+
run: cargo test --features deny-warnings
76+
working-directory: clippy_lints
77+
78+
- name: Test rustc_tools_util
79+
run: cargo test --features deny-warnings
80+
working-directory: rustc_tools_util
81+
82+
- name: Test clippy_dev
83+
run: cargo test --features deny-warnings
84+
working-directory: clippy_dev
85+
86+
- name: Test cargo-clippy
87+
run: ../target/debug/cargo-clippy
88+
working-directory: clippy_workspace_tests
89+
90+
- name: Test clippy-driver
91+
run: bash .github/driver.sh
92+
env:
93+
OS: ${{ runner.os }}
94+
95+
# Cleanup
96+
- name: Run cargo-cache --autoclean
97+
run: |
98+
cargo +nightly install cargo-cache --no-default-features --features ci-autoclean cargo-cache
99+
cargo cache

0 commit comments

Comments
 (0)