Skip to content

Commit b6dc257

Browse files
committed
Update Clippy to rust-lang/rust-clippy@32ee30
1 parent b09c9eb commit b6dc257

File tree

94 files changed

+1598
-949
lines changed

Some content is hidden

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

94 files changed

+1598
-949
lines changed

.cargo/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[alias]
2+
uitest = "test --test compile-test"

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ matrix:
9090
script:
9191
- |
9292
rm rust-toolchain
93-
cargo install rustup-toolchain-install-master --debug || echo "rustup-toolchain-install-master already installed"
94-
RUSTC_HASH=$(git ls-remote https://github.com/rust-lang/rust.git master | awk '{print $1}')
95-
travis_retry rustup-toolchain-install-master -f -n master $RUSTC_HASH
96-
rustup default master
93+
./setup-toolchain.sh
9794
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
9895
- |
9996
if [ -z ${INTEGRATION} ]; then

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ All notable changes to this project will be documented in this file.
772772
[`copy_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#copy_iterator
773773
[`crosspointer_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#crosspointer_transmute
774774
[`cyclomatic_complexity`]: https://rust-lang.github.io/rust-clippy/master/index.html#cyclomatic_complexity
775+
[`dbg_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#dbg_macro
775776
[`decimal_literal_representation`]: https://rust-lang.github.io/rust-clippy/master/index.html#decimal_literal_representation
776777
[`declare_interior_mutable_const`]: https://rust-lang.github.io/rust-clippy/master/index.html#declare_interior_mutable_const
777778
[`default_trait_access`]: https://rust-lang.github.io/rust-clippy/master/index.html#default_trait_access

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ an AST expression). `match_def_path()` in Clippy's `utils` module can also be us
7373

7474
## Writing code
7575

76+
Clippy depends on the current git master version of rustc, which can change rapidly. Make sure you're
77+
working near rust-clippy's master, and use the `setup-toolchain.sh` script to configure the appropriate
78+
toolchain for this directory.
79+
7680
[Llogiq's blog post on lints](https://llogiq.github.io/2015/06/04/workflows.html) is a nice primer
7781
to lint-writing, though it does get into advanced stuff. Most lints consist of an implementation of
7882
`LintPass` with one or more of its default methods overridden. See the existing lints for examples
@@ -97,7 +101,7 @@ fn main() {
97101
}
98102
```
99103

100-
Now you run `TESTNAME=ui/my_lint cargo test --test compile-test` to produce
104+
Now you run `TESTNAME=ui/my_lint cargo uitest` to produce
101105
a `.stdout` file with the generated code:
102106

103107
```rust
@@ -147,7 +151,7 @@ Use `cargo test` to run the whole testsuite.
147151
If you don't want to wait for all tests to finish, you can also execute a single test file by using `TESTNAME` to specify the test to run:
148152

149153
```bash
150-
TESTNAME=ui/empty_line_after_outer_attr cargo test --test compile-test
154+
TESTNAME=ui/empty_line_after_outer_attr cargo uitest
151155
```
152156

153157
Clippy uses UI tests. UI tests check that the output of the compiler is exactly as expected.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ path = "src/main.rs"
3434

3535
[[bin]]
3636
name = "clippy-driver"
37-
test = false
3837
path = "src/driver.rs"
3938

4039
[dependencies]

README.md

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

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

10-
[There are 295 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
10+
[There are 296 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
1111

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

ci/base-tests.sh

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,51 @@ cargo build --features debugging
1111
cargo test --features debugging
1212
# for faster build, share target dir between subcrates
1313
export CARGO_TARGET_DIR=`pwd`/target/
14-
cd clippy_lints && cargo test && cd ..
15-
cd rustc_tools_util && cargo test && cd ..
16-
cd clippy_dev && cargo test && cd ..
14+
(cd clippy_lints && cargo test)
15+
(cd rustc_tools_util && cargo test)
16+
(cd clippy_dev && cargo test)
1717

1818
# make sure clippy can be called via ./path/to/cargo-clippy
19-
cd clippy_workspace_tests
20-
../target/debug/cargo-clippy
21-
cd ..
19+
(
20+
cd clippy_workspace_tests
21+
../target/debug/cargo-clippy
22+
)
2223

2324
# Perform various checks for lint registration
2425
./util/dev update_lints --check
2526
cargo +nightly fmt --all -- --check
2627

28+
# Check running clippy-driver without cargo
29+
(
30+
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
31+
32+
# Check sysroot handling
33+
sysroot=$(./target/debug/clippy-driver --print sysroot)
34+
test $sysroot = $(rustc --print sysroot)
35+
36+
sysroot=$(./target/debug/clippy-driver --sysroot /tmp --print sysroot)
37+
test $sysroot = /tmp
38+
39+
sysroot=$(SYSROOT=/tmp ./target/debug/clippy-driver --print sysroot)
40+
test $sysroot = /tmp
41+
42+
# Make sure this isn't set - clippy-driver should cope without it
43+
unset CARGO_MANIFEST_DIR
44+
45+
# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
46+
# XXX How to match the clippy invocation in compile-test.rs?
47+
! ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr
48+
diff <(sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr) tests/ui/cstring.stderr
49+
50+
# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
51+
)
52+
2753
# make sure tests are formatted
2854

2955
# some lints are sensitive to formatting, exclude some files
3056
tests_need_reformatting="false"
3157
# switch to nightly
32-
rustup default nightly
58+
rustup override set nightly
3359
# avoid loop spam and allow cmds with exit status != 0
3460
set +ex
3561

@@ -49,4 +75,4 @@ if [ "${tests_need_reformatting}" == "true" ] ; then
4975
fi
5076

5177
# switch back to master
52-
rustup default master
78+
rustup override set master

clippy_dev/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl Lint {
4747
name: name.to_lowercase(),
4848
group: group.to_string(),
4949
desc: NL_ESCAPE_RE.replace(&desc.replace("\\\"", "\""), "").to_string(),
50-
deprecation: deprecation.map(|d| d.to_string()),
50+
deprecation: deprecation.map(std::string::ToString::to_string),
5151
module: module.to_string(),
5252
}
5353
}
@@ -178,7 +178,7 @@ fn lint_files() -> impl Iterator<Item = walkdir::DirEntry> {
178178
// Otherwise we would not collect all the lints, for example in `clippy_lints/src/methods/`.
179179
WalkDir::new("../clippy_lints/src")
180180
.into_iter()
181-
.filter_map(|f| f.ok())
181+
.filter_map(std::result::Result::ok)
182182
.filter(|f| f.path().extension() == Some(OsStr::new("rs")))
183183
}
184184

clippy_lints/src/assertions_on_constants.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::rustc::hir::{Expr, ExprKind};
33
use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
44
use crate::rustc::{declare_tool_lint, lint_array};
55
use crate::syntax::ast::LitKind;
6-
use crate::utils::{is_direct_expn_of, span_help_and_lint};
6+
use crate::utils::{in_macro, is_direct_expn_of, span_help_and_lint};
77
use if_chain::if_chain;
88

99
/// **What it does:** Check to call assert!(true/false)
@@ -43,7 +43,9 @@ impl LintPass for AssertionsOnConstants {
4343
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
4444
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
4545
if_chain! {
46-
if is_direct_expn_of(e.span, "assert").is_some();
46+
if let Some(assert_span) = is_direct_expn_of(e.span, "assert");
47+
if !in_macro(assert_span)
48+
|| is_direct_expn_of(assert_span, "debug_assert").map_or(false, |span| !in_macro(span));
4749
if let ExprKind::Unary(_, ref lit) = e.node;
4850
then {
4951
if let ExprKind::Lit(ref inner) = lit.node {

clippy_lints/src/attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) {
326326
lint.span,
327327
&format!("unknown clippy lint: clippy::{}", name),
328328
|db| {
329-
if name.as_str().chars().any(|c| c.is_uppercase()) {
329+
if name.as_str().chars().any(char::is_uppercase) {
330330
let name_lower = name.as_str().to_lowercase();
331331
match lint_store.check_lint_name(
332332
&name_lower,

0 commit comments

Comments
 (0)