Skip to content

Commit 555ee8f

Browse files
committed
Update clippy
1 parent 2a1c0f9 commit 555ee8f

36 files changed

+1879
-1034
lines changed

.github/deploy.sh

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
1313
SHA=$(git rev-parse --verify HEAD)
1414

1515
# Clone the existing gh-pages for this repo into out/
16-
(
17-
git clone "$REPO" out
18-
cd out
19-
git checkout $TARGET_BRANCH
20-
)
16+
git clone --quiet --single-branch --branch "$TARGET_BRANCH" "$REPO" out
2117

2218
echo "Removing the current docs for master"
2319
rm -rf out/master/ || exit 0
@@ -27,35 +23,44 @@ mkdir out/master/
2723
cp util/gh-pages/index.html out/master
2824
python ./util/export.py out/master/lints.json
2925

30-
if [ -n "$TRAVIS_TAG" ]; then
26+
if [[ -n "$TRAVIS_TAG" ]]; then
3127
echo "Save the doc for the current tag ($TRAVIS_TAG) and point current/ to it"
3228
cp -r out/master "out/$TRAVIS_TAG"
3329
rm -f out/current
3430
ln -s "$TRAVIS_TAG" out/current
3531
fi
3632

3733
# Generate version index that is shown as root index page
38-
(
39-
cp util/gh-pages/versions.html out/index.html
40-
41-
cd out
42-
python -c '\
43-
import os, json;\
44-
print json.dumps([\
45-
dir for dir in os.listdir(".")\
46-
if not dir.startswith(".") and os.path.isdir(dir)\
47-
])' > versions.json
48-
)
34+
cp util/gh-pages/versions.html out/index.html
35+
pushd out
36+
37+
cat <<-EOF | python - > versions.json
38+
import os, json
39+
print json.dumps([
40+
dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir)
41+
])
42+
EOF
43+
popd
4944

5045
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
51-
if [ "$TRAVIS_PULL_REQUEST" != "false" ] || [ "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
46+
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]] || [[ "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]]; then
5247
# Tags should deploy
53-
if [ -z "$TRAVIS_TAG" ]; then
48+
if [[ -z "$TRAVIS_TAG" ]]; then
5449
echo "Generated, won't push"
5550
exit 0
5651
fi
5752
fi
5853

54+
# Now let's go have some fun with the cloned repo
55+
cd out
56+
git config user.name "Travis CI"
57+
git config user.email "travis@ci.invalid"
58+
59+
if git diff --exit-code --quiet; then
60+
echo "No changes to the output on this push; exiting."
61+
exit 0
62+
fi
63+
5964
# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
6065
ENCRYPTION_LABEL=e3a2d77100be
6166
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
@@ -64,19 +69,9 @@ ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
6469
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
6570
openssl aes-256-cbc -K "$ENCRYPTED_KEY" -iv "$ENCRYPTED_IV" -in .github/deploy_key.enc -out .github/deploy_key -d
6671
chmod 600 .github/deploy_key
67-
eval $(ssh-agent -s)
72+
eval "$(ssh-agent -s)"
6873
ssh-add .github/deploy_key
6974

70-
# Now let's go have some fun with the cloned repo
71-
cd out
72-
git config user.name "Travis CI"
73-
git config user.email "travis@ci.invalid"
74-
75-
if [ -z "$(git diff --exit-code)" ]; then
76-
echo "No changes to the output on this push; exiting."
77-
exit 0
78-
fi
79-
8075
git add .
8176
git commit -m "Automatic deploy to GitHub Pages: ${SHA}"
8277

.travis.yml

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
dist: xenial
22
language: bash
33

4-
os:
5-
- linux
6-
- osx
7-
- windows
8-
94
branches:
105
# Don't build these branches
116
except:
@@ -34,13 +29,12 @@ install:
3429
if ! rustup component add rustfmt; then
3530
cargo install -Z install-upgrade --git https://github.com/rust-lang/rustfmt --bin rustfmt
3631
fi
37-
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
32+
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
3833
. $HOME/.nvm/nvm.sh
3934
nvm install stable
4035
nvm use stable
4136
npm install remark-cli remark-lint
42-
fi
43-
if [ "$TRAVIS_OS_NAME" == "windows" ]; then
37+
elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
4438
choco install windows-sdk-10.1
4539
fi
4640
fi
@@ -53,11 +47,9 @@ matrix:
5347
include:
5448
# Builds that are executed for every PR
5549
- os: osx # run base tests on both platforms
56-
env: BASE_TESTS=true
5750
- os: linux
58-
env: BASE_TESTS=true
5951
- os: windows
60-
env: CARGO_INCREMENTAL=0 BASE_TESTS=true OS_WINDOWS=true
52+
env: CARGO_INCREMENTAL=0 OS_WINDOWS=true
6153

6254
# Builds that are only executed when a PR is r+ed or a try build is started
6355
# We don't want to run these always because they go towards
@@ -95,51 +87,51 @@ matrix:
9587
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
9688
allow_failures:
9789
- os: windows
98-
env: CARGO_INCREMENTAL=0 BASE_TESTS=true OS_WINDOWS=true
99-
# prevent these jobs with default env vars
100-
exclude:
101-
- os: linux
102-
- os: osx
103-
- os: windows
90+
env: CARGO_INCREMENTAL=0 OS_WINDOWS=true
10491

10592
before_script:
10693
- |
107-
if [ "$TRAVIS_BRANCH" == "auto" ] || [ "$TRAVIS_BRANCH" == "try" ]; then
108-
pr=$(echo $TRAVIS_COMMIT_MESSAGE | grep -o "#[0-9]*" | head -1 | sed 's/^#//g')
109-
output=$(curl -H "Authorization: token $GITHUB_API_TOKEN" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$pr" | \
94+
if [[ "$TRAVIS_BRANCH" == "auto" ]] || [[ "$TRAVIS_BRANCH" == "try" ]]; then
95+
PR=$(echo "$TRAVIS_COMMIT_MESSAGE" | grep -o "#[0-9]*" | head -1 | sed 's/^#//g')
96+
output=$(curl -H "Authorization: token $GITHUB_API_TOKEN" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \
11097
python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \
11198
grep "^changelog: " | \
11299
sed "s/changelog: //g")
113-
if [ -z "$output" ]; then
100+
if [[ -z "$output" ]]; then
114101
echo "ERROR: PR body must contain 'changelog: ...'"
115102
exit 1
116-
elif [ "$output" = "none" ]; then
103+
elif [[ "$output" = "none" ]]; then
117104
echo "WARNING: changelog is 'none'"
118105
fi
119106
fi
120107
- |
121108
rm rust-toolchain
122109
./setup-toolchain.sh
123110
- |
124-
if [ "$TRAVIS_OS_NAME" == "windows" ]; then
125-
export PATH=$PATH:$(rustc --print sysroot)/bin
126-
else
127-
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
128-
fi
111+
SYSROOT=$(rustc --print sysroot)
112+
case "$TRAVIS_OS_NAME" in
113+
windows ) export PATH="${SYSROOT}/bin:${PATH}" ;;
114+
linux ) export LD_LIBRARY_PATH="${SYSROOT}/lib" ;;
115+
osx )
116+
# See <https://github.com/nteract/nteract/issues/1523#issuecomment-301623519>
117+
sudo mkdir -p /usr/local/lib
118+
sudo find "$SYSROOT/lib" -maxdepth 1 -name '*.dylib' -exec ln -s {} /usr/local/lib \;
119+
;;
120+
esac
129121
130122
script:
131123
- |
132-
if [ -z ${INTEGRATION} ]; then
133-
travis_wait 30 ./ci/base-tests.sh && sleep 5
134-
else
124+
if [[ -n ${INTEGRATION} ]]; then
135125
./ci/integration-tests.sh && sleep 5
126+
else
127+
./ci/base-tests.sh && sleep 5
136128
fi
137129
138130
after_success:
139131
- |
140-
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
132+
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
141133
set -e
142-
if [ -z ${INTEGRATION} ]; then
134+
if [[ -z ${INTEGRATION} ]]; then
143135
./.github/deploy.sh
144136
else
145137
echo "Not deploying, because we're in an integration test run"

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ Released 2018-09-13
966966
[`copy_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#copy_iterator
967967
[`crosspointer_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#crosspointer_transmute
968968
[`dbg_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#dbg_macro
969+
[`debug_assert_with_mut_call`]: https://rust-lang.github.io/rust-clippy/master/index.html#debug_assert_with_mut_call
969970
[`decimal_literal_representation`]: https://rust-lang.github.io/rust-clippy/master/index.html#decimal_literal_representation
970971
[`declare_interior_mutable_const`]: https://rust-lang.github.io/rust-clippy/master/index.html#declare_interior_mutable_const
971972
[`default_trait_access`]: https://rust-lang.github.io/rust-clippy/master/index.html#default_trait_access

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ You can use [rustup-toolchain-install-master][rtim] to do that:
147147

148148
```bash
149149
cargo install rustup-toolchain-install-master
150-
rustup-toolchain-install-master --force -n master
150+
rustup-toolchain-install-master --force -n master -c rustc-dev
151151
rustup override set master
152152
cargo test
153153
```

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ semver = "0.9"
4545
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
4646

4747
[dev-dependencies]
48-
cargo_metadata = "0.8.0"
48+
cargo_metadata = "0.9.0"
4949
compiletest_rs = { version = "0.3.24", features = ["tmp"] }
5050
lazy_static = "1.0"
5151
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
88

9-
[There are 331 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
9+
[There are 332 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
1010

1111
We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:
1212

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ install:
2525
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
2626
- del rust-toolchain
2727
- cargo install -Z install-upgrade rustup-toolchain-install-master
28-
- rustup-toolchain-install-master -f -n master
28+
- rustup-toolchain-install-master -f -n master -c rustc-dev
2929
- rustup component add rustfmt --toolchain nightly & exit 0 # Format test handles missing rustfmt
3030
- rustup default master
3131
- set PATH=%PATH%;C:\Users\appveyor\.rustup\toolchains\master\bin

ci/base-tests.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1+
#!/usr/bin/env bash
12
set -ex
23

4+
# for faster build, share target dir between subcrates
5+
CARGO_TARGET_DIR=$(pwd)/target/
6+
export CARGO_TARGET_DIR
7+
38
echo "Running clippy base tests"
49

510
PATH=$PATH:./node_modules/.bin
6-
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
7-
remark -f *.md -f doc/*.md > /dev/null
11+
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
12+
remark -f ./*.md -f doc/*.md > /dev/null
813
fi
914
# build clippy in debug mode and run tests
1015
cargo build --features "debugging deny-warnings"
1116
cargo test --features "debugging deny-warnings"
12-
# for faster build, share target dir between subcrates
13-
export CARGO_TARGET_DIR=`pwd`/target/
17+
1418
(cd clippy_lints && cargo test)
1519
(cd rustc_tools_util && cargo test)
1620
(cd clippy_dev && cargo test)
@@ -29,26 +33,27 @@ export CARGO_TARGET_DIR=`pwd`/target/
2933
(
3034
# Check sysroot handling
3135
sysroot=$(./target/debug/clippy-driver --print sysroot)
32-
test $sysroot = $(rustc --print sysroot)
36+
test "$sysroot" = "$(rustc --print sysroot)"
3337

34-
if [ -z $OS_WINDOWS ]; then
38+
if [[ -z "$OS_WINDOWS" ]]; then
3539
desired_sysroot=/tmp
3640
else
3741
desired_sysroot=C:/tmp
3842
fi
3943
sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
40-
test $sysroot = $desired_sysroot
44+
test "$sysroot" = $desired_sysroot
4145

4246
sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
43-
test $sysroot = $desired_sysroot
47+
test "$sysroot" = $desired_sysroot
4448

4549
# Make sure this isn't set - clippy-driver should cope without it
4650
unset CARGO_MANIFEST_DIR
4751

4852
# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
49-
# XXX How to match the clippy invocation in compile-test.rs?
50-
! ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr
51-
diff <(sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr) tests/ui/cstring.stderr
53+
# FIXME: How to match the clippy invocation in compile-test.rs?
54+
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1
55+
sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr
56+
diff normalized.stderr tests/ui/cstring.stderr
5257

5358
# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
5459
)

ci/integration-tests.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#!/usr/bin/env bash
2-
set -x
2+
set -ex
33

44
if [[ -z "$INTEGRATION" ]]; then
55
exit 0
66
fi
77

8+
CARGO_TARGET_DIR=$(pwd)/target/
9+
export CARGO_TARGET_DIR
10+
811
rm ~/.cargo/bin/cargo-clippy
912
cargo install --force --debug --path .
1013

clippy_dev/src/lib.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn gen_lint_group_list(lints: Vec<Lint>) -> Vec<String> {
8282
if l.is_internal() || l.deprecation.is_some() {
8383
None
8484
} else {
85-
Some(format!(" {}::{},", l.module, l.name.to_uppercase()))
85+
Some(format!(" LintId::of(&{}::{}),", l.module, l.name.to_uppercase()))
8686
}
8787
})
8888
.sorted()
@@ -143,6 +143,26 @@ pub fn gen_deprecated(lints: &[Lint]) -> Vec<String> {
143143
.collect::<Vec<String>>()
144144
}
145145

146+
#[must_use]
147+
pub fn gen_register_lint_list(lints: &[Lint]) -> Vec<String> {
148+
let pre = " store.register_lints(&[".to_string();
149+
let post = " ]);".to_string();
150+
let mut inner = lints
151+
.iter()
152+
.filter_map(|l| {
153+
if !l.is_internal() && l.deprecation.is_none() {
154+
Some(format!(" &{}::{},", l.module, l.name.to_uppercase()))
155+
} else {
156+
None
157+
}
158+
})
159+
.sorted()
160+
.collect::<Vec<String>>();
161+
inner.insert(0, pre);
162+
inner.push(post);
163+
inner
164+
}
165+
146166
/// Gathers all files in `src/clippy_lints` and gathers all lints inside
147167
pub fn gather_all() -> impl Iterator<Item = Lint> {
148168
lint_files().flat_map(|f| gather_from_file(&f))
@@ -487,8 +507,8 @@ fn test_gen_lint_group_list() {
487507
Lint::new("incorrect_internal", "internal_style", "abc", None, "module_name"),
488508
];
489509
let expected = vec![
490-
" module_name::ABC,".to_string(),
491-
" module_name::SHOULD_ASSERT_EQ,".to_string(),
510+
" LintId::of(&module_name::ABC),".to_string(),
511+
" LintId::of(&module_name::SHOULD_ASSERT_EQ),".to_string(),
492512
];
493513
assert_eq!(expected, gen_lint_group_list(lints));
494514
}

0 commit comments

Comments
 (0)