Skip to content

Commit 05d9f88

Browse files
committed
Merge branch 'origin/master' into flat-map
2 parents c7da4c2 + 72da101 commit 05d9f88

File tree

213 files changed

+3333
-1571
lines changed

Some content is hidden

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

213 files changed

+3333
-1571
lines changed

.github/PULL_REQUEST_TEMPLATE

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ checked during review or continuous integration.
1616
- [ ] Followed [lint naming conventions][lint_naming]
1717
- [ ] Added passing UI tests (including committed `.stderr` file)
1818
- [ ] `cargo test` passes locally
19-
- [ ] Executed `util/dev update_lints`
19+
- [ ] Executed `./util/dev update_lints`
2020
- [ ] Added lint documentation
21-
- [ ] Run `cargo fmt`
21+
- [ ] Run `./util/dev fmt`
22+
23+
[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
2224

2325
Note that you can skip the above if you are just opening a WIP PR in
2426
order to get feedback.

.travis.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ branches:
1717
env:
1818
global:
1919
- RUST_BACKTRACE=1
20+
- secure: "OKulfkA5OGd/d1IhvBKzRkHQwMcWjzrzbimo7+5NhkUkWxndAzl+719TB3wWvIh1i2wXXrEXsyZkXM5FtRrHm55v1VKQ5ibjEvFg1w3NIg81iDyoLq186fLqywvxGkOAFPrsePPsBj5USd5xvhwwbrjO6L7/RK6Z8shBwOSc41s="
2021

2122
install:
2223
- |
@@ -45,7 +46,7 @@ matrix:
4546
- os: linux
4647
env: BASE_TESTS=true
4748
- os: windows
48-
env: CARGO_INCREMENTAL=0 BASE_TESTS=true
49+
env: CARGO_INCREMENTAL=0 BASE_TESTS=true OS_WINDOWS=true
4950

5051
# Builds that are only executed when a PR is r+ed or a try build is started
5152
# We don't want to run these always because they go towards
@@ -81,20 +82,35 @@ matrix:
8182
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
8283
- env: INTEGRATION=chronotope/chrono
8384
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
84-
allow_failures:
85-
- os: windows
86-
env: CARGO_INCREMENTAL=0 BASE_TESTS=true
8785
# prevent these jobs with default env vars
8886
exclude:
8987
- os: linux
9088
- os: osx
9189
- os: windows
9290

9391
script:
92+
- |
93+
if [ "$TRAVIS_BRANCH" == "auto" ] || [ "$TRAVIS_BRANCH" == "try" ]; then
94+
pr=$(echo $TRAVIS_COMMIT_MESSAGE | grep -o "#[0-9]*" | head -1 | sed 's/^#//g')
95+
output=$(curl -H "Authorization: token $GITHUB_API_TOKEN" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$pr" | \
96+
python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \
97+
grep "^changelog: " | \
98+
sed "s/changelog: //g")
99+
if [ -z "$output" ]; then
100+
echo "ERROR: PR body must contain 'changelog: ...'"
101+
exit 1
102+
elif [ "$output" = "none" ]; then
103+
echo "WARNING: changelog is 'none'"
104+
fi
105+
fi
94106
- |
95107
rm rust-toolchain
96108
./setup-toolchain.sh
97-
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
109+
if [ "$TRAVIS_OS_NAME" == "windows" ]; then
110+
export PATH=$PATH:$(rustc --print sysroot)/bin
111+
else
112+
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
113+
fi
98114
- |
99115
if [ -z ${INTEGRATION} ]; then
100116
travis_wait 30 ./ci/base-tests.sh && sleep 5
@@ -104,7 +120,7 @@ script:
104120
105121
after_success: |
106122
#!/bin/bash
107-
if [ $(uname) == Linux ]; then
123+
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
108124
set -ex
109125
if [ -z ${INTEGRATION} ]; then
110126
./.github/deploy.sh

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,14 +974,15 @@ Released 2018-09-13
974974
[`ineffective_bit_mask`]: https://rust-lang.github.io/rust-clippy/master/index.html#ineffective_bit_mask
975975
[`infallible_destructuring_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#infallible_destructuring_match
976976
[`infinite_iter`]: https://rust-lang.github.io/rust-clippy/master/index.html#infinite_iter
977+
[`inherent_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#inherent_to_string
978+
[`inherent_to_string_shadow_display`]: https://rust-lang.github.io/rust-clippy/master/index.html#inherent_to_string_shadow_display
977979
[`inline_always`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_always
978980
[`inline_fn_without_body`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_fn_without_body
979981
[`int_plus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#int_plus_one
980982
[`integer_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#integer_arithmetic
981983
[`integer_division`]: https://rust-lang.github.io/rust-clippy/master/index.html#integer_division
982984
[`into_iter_on_array`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_array
983985
[`into_iter_on_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref
984-
[`invalid_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_ref
985986
[`invalid_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_regex
986987
[`invalid_upcast_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_upcast_comparisons
987988
[`items_after_statements`]: https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
@@ -999,6 +1000,7 @@ Released 2018-09-13
9991000
[`let_unit_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
10001001
[`linkedlist`]: https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist
10011002
[`logic_bug`]: https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug
1003+
[`main_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#main_recursion
10021004
[`manual_memcpy`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_memcpy
10031005
[`manual_swap`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_swap
10041006
[`many_single_char_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names
@@ -1137,6 +1139,7 @@ Released 2018-09-13
11371139
[`trivially_copy_pass_by_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref
11381140
[`try_err`]: https://rust-lang.github.io/rust-clippy/master/index.html#try_err
11391141
[`type_complexity`]: https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
1142+
[`type_repetition_in_bounds`]: https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds
11401143
[`unicode_not_nfc`]: https://rust-lang.github.io/rust-clippy/master/index.html#unicode_not_nfc
11411144
[`unimplemented`]: https://rust-lang.github.io/rust-clippy/master/index.html#unimplemented
11421145
[`unit_arg`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ rustc-workspace-hack = "1.0.0"
6161
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
6262

6363
[features]
64+
deny-warnings = []
6465
debugging = []

README.md

Lines changed: 20 additions & 11 deletions
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 306 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
9+
[There are 309 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

@@ -36,6 +36,7 @@ Table of contents:
3636

3737
* [Usage instructions](#usage)
3838
* [Configuration](#configuration)
39+
* [Contributing](#contributing)
3940
* [License](#license)
4041

4142
## Usage
@@ -52,7 +53,7 @@ subcommand.
5253

5354
#### Step 1: Install rustup
5455

55-
You can install [rustup](http://rustup.rs/) on supported platforms. This will help
56+
You can install [rustup](https://rustup.rs/) on supported platforms. This will help
5657
us install Clippy and its dependencies.
5758

5859
If you already have rustup installed, update to ensure you have the latest
@@ -79,6 +80,15 @@ Now you can run Clippy by invoking the following command:
7980
cargo clippy
8081
```
8182

83+
#### Automatically applying Clippy suggestions
84+
85+
Some Clippy lint suggestions can be automatically applied by `cargo fix`.
86+
Note that this is still experimental and only supported on the nightly channel:
87+
88+
```terminal
89+
cargo fix -Z unstable-options --clippy
90+
```
91+
8292
### Running Clippy from the command line without installing it
8393

8494
To have cargo compile your crate with Clippy without Clippy installation
@@ -88,8 +98,7 @@ in your code, you can use:
8898
cargo run --bin cargo-clippy --manifest-path=path_to_clippys_Cargo.toml
8999
```
90100

91-
*[Note](https://github.com/rust-lang/rust-clippy/wiki#a-word-of-warning):*
92-
Be sure that Clippy was compiled with the same version of rustc that cargo invokes here!
101+
*Note:* Be sure that Clippy was compiled with the same version of rustc that cargo invokes here!
93102

94103
### Travis CI
95104

@@ -113,20 +122,20 @@ script:
113122
```
114123

115124
If you are on nightly, It might happen that Clippy is not available for a certain nightly release.
116-
In this case you can try to conditionally install Clippy from the git repo.
125+
In this case you can try to conditionally install Clippy from the Git repo.
117126

118127
```yaml
119128
language: rust
120129
rust:
121130
- nightly
122131
before_script:
123132
- rustup component add clippy --toolchain=nightly || cargo install --git https://github.com/rust-lang/rust-clippy/ --force clippy
124-
# etc
133+
# etc.
125134
```
126135

127136
Note that adding `-D warnings` will cause your build to fail if **any** warnings are found in your code.
128137
That includes warnings found by rustc (e.g. `dead_code`, etc.). If you want to avoid this and only cause
129-
an error for clippy warnings, use `#![deny(clippy::all)]` in your code or `-D clippy::all` on the command
138+
an error for Clippy warnings, use `#![deny(clippy::all)]` in your code or `-D clippy::all` on the command
130139
line. (You can swap `clippy::all` with the specific lint category you are targeting.)
131140

132141
## Configuration
@@ -154,9 +163,9 @@ You can add options to your code to `allow`/`warn`/`deny` Clippy lints:
154163
`#![deny(clippy::pedantic)]`). Note that `clippy::pedantic` contains some very aggressive
155164
lints prone to false positives.
156165

157-
* only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc)
166+
* only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc.)
158167

159-
* `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc
168+
* `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc.
160169

161170
Note: `deny` produces errors instead of warnings.
162171

@@ -171,7 +180,7 @@ If you want to contribute to Clippy, you can find more information in [CONTRIBUT
171180
Copyright 2014-2019 The Rust Project Developers
172181

173182
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
174-
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)> or the MIT license
175-
<LICENSE-MIT or [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT)>, at your
183+
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)> or the MIT license
184+
<LICENSE-MIT or [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT)>, at your
176185
option. All files in the project carrying such notice may not be
177186
copied, modified, or distributed except according to those terms.

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ environment:
88
- TARGET: x86_64-pc-windows-msvc
99

1010
branches:
11-
# Only build AppVeyor on r+, try and the master branch
11+
# Only build AppVeyor on r+ and try branch
1212
only:
1313
- auto
1414
- try
15-
- master
1615

1716
install:
1817
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
@@ -23,6 +22,7 @@ install:
2322
- del rust-toolchain
2423
- cargo install rustup-toolchain-install-master --debug || echo "rustup-toolchain-install-master already installed"
2524
- rustup-toolchain-install-master %RUSTC_HASH% -f -n master
25+
- rustup component add rustfmt --toolchain nightly & exit 0 # Format test handles missing rustfmt
2626
- rustup default master
2727
- set PATH=%PATH%;C:\Users\appveyor\.rustup\toolchains\master\bin
2828
- rustc -V

ci/base-tests.sh

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ if [ "$TRAVIS_OS_NAME" == "linux" ]; then
77
remark -f *.md -f doc/*.md > /dev/null
88
fi
99
# build clippy in debug mode and run tests
10-
cargo build --features debugging
11-
cargo test --features debugging
10+
cargo build --features "debugging deny-warnings"
11+
cargo test --features "debugging deny-warnings"
1212
# for faster build, share target dir between subcrates
1313
export CARGO_TARGET_DIR=`pwd`/target/
1414
(cd clippy_lints && cargo test)
@@ -24,21 +24,23 @@ export CARGO_TARGET_DIR=`pwd`/target/
2424
# Perform various checks for lint registration
2525
./util/dev update_lints --check
2626
./util/dev --limit-stderr-length
27-
cargo +nightly fmt --all -- --check
2827

2928
# Check running clippy-driver without cargo
3029
(
31-
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
32-
3330
# Check sysroot handling
3431
sysroot=$(./target/debug/clippy-driver --print sysroot)
3532
test $sysroot = $(rustc --print sysroot)
3633

37-
sysroot=$(./target/debug/clippy-driver --sysroot /tmp --print sysroot)
38-
test $sysroot = /tmp
34+
if [ -z $OS_WINDOWS ]; then
35+
desired_sysroot=/tmp
36+
else
37+
desired_sysroot=C:/tmp
38+
fi
39+
sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
40+
test $sysroot = $desired_sysroot
3941

40-
sysroot=$(SYSROOT=/tmp ./target/debug/clippy-driver --print sysroot)
41-
test $sysroot = /tmp
42+
sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
43+
test $sysroot = $desired_sysroot
4244

4345
# Make sure this isn't set - clippy-driver should cope without it
4446
unset CARGO_MANIFEST_DIR
@@ -50,32 +52,3 @@ cargo +nightly fmt --all -- --check
5052

5153
# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
5254
)
53-
54-
# make sure tests are formatted
55-
56-
# some lints are sensitive to formatting, exclude some files
57-
tests_need_reformatting="false"
58-
# switch to nightly
59-
rustup override set nightly
60-
# avoid loop spam and allow cmds with exit status != 0
61-
set +ex
62-
63-
# Excluding `ice-3891.rs` because the code triggers a rustc parse error which
64-
# makes rustfmt fail.
65-
for file in `find tests -not -path "tests/ui/crashes/ice-3891.rs" | grep "\.rs$"` ; do
66-
rustfmt ${file} --check
67-
if [ $? -ne 0 ]; then
68-
echo "${file} needs reformatting!"
69-
tests_need_reformatting="true"
70-
fi
71-
done
72-
73-
set -ex # reset
74-
75-
if [ "${tests_need_reformatting}" == "true" ] ; then
76-
echo "Tests need reformatting!"
77-
exit 2
78-
fi
79-
80-
# switch back to master
81-
rustup override set master

clippy_dev/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ clap = "2.33"
99
itertools = "0.8"
1010
regex = "1"
1111
lazy_static = "1.0"
12+
shell-escape = "0.1"
1213
walkdir = "2"

0 commit comments

Comments
 (0)