Commit graph

5933 commits

Author SHA1 Message Date
Michael Wright
6e7a813ed2 Improve iter_cloned_collect suggestions
Fixes #3704
2019-02-18 07:30:50 +02:00
phil
2d28d9f02a Add failing test for #3778 write_with_newline
Literal `\n` characters (not a newline) in a `r"raw"` string should not
fail the lint.
2019-02-17 22:32:58 -05:00
Timo
99eccaa120
Add a semicolon as suggested 2019-02-17 22:14:38 -05:00
Timo
508b41ecef
Fix typo in documentation for float_cmp_const lint 2019-02-17 21:06:29 -05:00
bors
a71acac1da Auto merge of #3775 - flip1995:ice-3717, r=phansch
Fix ICE #3717 in lint implicit_hasher

Fixes #3717

This fixes the ICE. We lose some information in a very specific case though. But less information if better than an ICE. For an example see the test file.

Does anyone know, if there's another way to get the `ty::Ty` of a `hir::Expr`?
2019-02-17 07:03:15 +00:00
flip1995
9148fc274a
Add test for ICE #3717 fix 2019-02-17 01:50:31 +01:00
flip1995
f204b7ec76
Fix ICE #3717
Restore the old `TypeckTables` in visit_body after walking the body
2019-02-17 01:50:13 +01:00
bors
f08e268d95 Auto merge of #3774 - notriddle:patch-1, r=flip1995
Use normal HTML label semantics for filter

The improvement is that you can click on the label and it'll select the form field.
2019-02-16 22:01:48 +00:00
Michael Howell
67f50661eb
Use normal HTML label semantics for filter
I legitimately don't understand why you did it with ARIA instead.
2019-02-16 13:16:50 -07:00
bors
32ee306acb Auto merge of #3762 - mikerite:fix-build-20190214, r=flip1995
Fix breakage due to rust-lang/rust#58167
2019-02-14 13:17:48 +00:00
flip1995
10811d5d89
Fix breakage from rust-lang/rust#58296 2019-02-14 14:01:43 +01:00
Michael Wright
533dd360d7 Fix breakage due to rust-lang/rust#58167 2019-02-14 08:55:50 +02:00
bors
d4755e1f14 Auto merge of #3760 - rust-lang:rustup, r=flip1995
Rustup

cc rust-lang/rust#58137
2019-02-13 21:10:06 +00:00
flip1995
5a3cd31c9e
Rustup
cc rust-lang/rust#58137
2019-02-13 22:08:17 +01:00
bors
db13e6fa34 Auto merge of #3756 - g-bartoszek:redundant-closure-for-methods, r=oli-obk
Redundant closure for methods

fixes  #3469
2019-02-12 13:31:44 +00:00
bors
ed3287605d Auto merge of #3757 - mikerite:fix-2542, r=oli-obk
Fix `needless_range_loop` bad suggestion

Detect if the index variable is used inside a closure.

Fixes #2542
2019-02-12 10:27:18 +00:00
bors
2066368583 Auto merge of #3758 - phansch:document_macro, r=flip1995
Document `declare_clippy_lint` macro

Split up from my work on updating CONTRIBUTING.md, which is slowly
making progress.

cc #2666
2019-02-11 23:52:52 +00:00
Philipp Hansch
a14247b500
Update comment regarding crate level cfg_attr 2019-02-11 22:32:54 +01:00
Philipp Hansch
7d3983216f
Document some more core functions 2019-02-11 08:34:37 +01:00
Philipp Hansch
a27022e0dc
Document declare_clippy_lint macro
Split up from my work on updating CONTRIBUTING.md, which is slowly
making progress.

cc #2666
2019-02-11 08:34:37 +01:00
Michael Wright
217965e855 Fix needless_range_loop bad suggestion
Detect if the index variable is used inside a closure.

Fixes #2542
2019-02-11 07:03:12 +02:00
Grzegorz
f7c0df9183 test formatting 2019-02-10 21:23:04 +01:00
bors
bd23cb89ec Auto merge of #3754 - phansch:uicleanup, r=oli-obk
UI test cleanup: Extract similar_names tests

cc #2038
2019-02-10 14:06:20 +00:00
bors
2755d12fa6 Auto merge of #3744 - phansch:fix3144, r=oli-obk
Fix ICE in needless_pass_by_value lint

If I understand it correctly, we were first creating a type with a
`RegionKind::ReErased` region and then deleted it again in
`util::implements_trait` with:

    cx.tcx.erase_regions(&ty);

causing the type query to fail.

It looks like using `ReEmpty` works around that deletion.

Fixes #3144
2019-02-10 13:39:46 +00:00
bors
af43950143 Auto merge of #3740 - flip1995:const_assert_macro, r=oli-obk
Macro check for assertion_on_constants lint

The `assertion_on_constants` lint currently has following output for this code [Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6f2c9df6fc50baf847212d3b5136ee97):
```rust
macro_rules! assert_const {
    ($len:expr) => {
        assert!($len > 0);
    }
}

fn main() {
    assert_const!(3);
    assert_const!(-1);
}
```
```
warning: assert!(const: true) will be optimized out by the compiler
 --> src/main.rs:3:9
  |
3 |         assert!($len > 0);
  |         ^^^^^^^^^^^^^^^^^^
...
8 |     assert_const!(3);
  |     ---------------- in this macro invocation
  |
  = note: #[warn(clippy::assertions_on_constants)] on by default
  = help: remove it
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants

warning: assert!(const: false) should probably be replaced
 --> src/main.rs:3:9
  |
3 |         assert!($len > 0);
  |         ^^^^^^^^^^^^^^^^^^
...
9 |     assert_const!(-1);
  |     ----------------- in this macro invocation
  |
  = help: use panic!() or unreachable!()
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
```

This is contradictory. This lint should not trigger if the `assert!` is in a macro itself.
2019-02-10 12:47:16 +00:00
Grzegorz
16881390e1 removing redundant closures in the whole project 2019-02-10 13:35:44 +01:00
bors
83edb647f2 Auto merge of #3755 - phansch:uicleanup2, r=oli-obk
UI test cleanup: Extract match_same_arms tests

cc #2038
2019-02-10 12:25:44 +00:00
Grzegorz
b38c587b98 redundant closure implemented for closures containing method calls 2019-02-10 12:58:51 +01:00
Philipp Hansch
1eeda35118
rustfmt 2019-02-10 10:48:24 +01:00
Philipp Hansch
8abdfb6567
UI test cleanup: Rename copies.rs to match_same_arms.rs 2019-02-10 10:20:28 +01:00
Philipp Hansch
83a87fb7b6
UI test cleanup: Extract match_same_arms tests 2019-02-10 10:19:24 +01:00
Philipp Hansch
9dbabffe60
UI test cleanup: Extract similar_names tests 2019-02-10 09:48:31 +01:00
bors
5725726345 Auto merge of #3751 - h-michael:opt-def-id, r=phansch
Use Hir::Def opt_def_id

related with: https://github.com/rust-lang/rust-clippy/pull/3750#issuecomment-462010225

Using `def.opt_def_id` in `opt_def_id` before replacing all all at once.
2019-02-09 12:01:45 +00:00
Hirokazu Hata
71dfbe2072 Use Hir::Def opt_def_id 2019-02-09 13:28:21 +09:00
bors
77435f9938 Auto merge of #3748 - phansch:uitest, r=oli-obk
Add a uitest subcommand to simplify UI test invocation

This makes running single tests a lot easier.

It's now

`TESTNAME=xxx cargo uitest`

instead of

`TESTNAME=xxx cargo test --test compile-test`
2019-02-09 04:09:25 +00:00
bors
35e2e1bb75 Auto merge of #3750 - h-michael:const-params, r=phansch
Fix failing build  (adding new Hir::Def type ConstParam)

solves: #3749

related with:
- https://travis-ci.com/rust-lang/rust-clippy/jobs/176480646
- https://github.com/rust-lang/rust/pull/58191
- 29f7206366 (diff-c1e317a81486d937bbfc6edca1dee92aR55)
2019-02-09 03:41:50 +00:00
Hirokazu Hata
66f8fa320b Add new Def type ConstParam 2019-02-09 11:42:13 +09:00
Philipp Hansch
f934f98111
Add a uitest subcommand to simplify UI test invocation
This allows to run

`TESTNAME=xxx cargo uitest`

instead of

`TESTNAME=xxx cargo test --test-compile-test`
2019-02-08 08:09:37 +01:00
bors
e176324fc5 Auto merge of #3665 - jsgf:master, r=oli-obk
Start making clippy easier to invoke in non-cargo contexts

Clippy (clippy-driver) currently has a couple of strong but unnecessary couplings with cargo. This series:
1. makes detection of check builds more robust, and
2. make clippy-driver use the --sysroot specified on the command line as its internal sysroot.
2019-02-06 15:43:07 +00:00
bors
450cacc5f4 Auto merge of #3743 - phansch:you_shall_not_pass, r=flip1995
Move run-pass tests to UI tests

This should give us more UI coverage for free.
It also removes the `run-pass` suite, so we now only have the `ui` suite.
2019-02-06 08:59:55 +00:00
Philipp Hansch
f3cd81980d
Fix ICE in needless_pass_by_value lint
If I understand it correctly, we were first creating a type with a
`RegionKind::ReErased` region and then deleted it again in
`util::implements_trait` with:

    cx.tcx.erase_regions(&ty);

causing the type query to fail.

It looks like using `ReEmpty` works around that deletion.
2019-02-06 09:18:35 +01:00
Philipp Hansch
a586f52a0f
Move run-pass tests to UI tests
This should give us more UI coverage for free.
It also removes the `run-pass` suite, so we now only have the `ui` suite.
2019-02-06 08:17:39 +01:00
flip1995
cb2d987ed4
Add tests for assertion_on_constants macro check 2019-02-05 19:37:54 +01:00
flip1995
446e2ecfb7
Don't warn about const assertions when assert is in a macro itself 2019-02-05 19:37:50 +01:00
bors
4259377ea6 Auto merge of #3725 - mikerite:fix-2728, r=phansch
Fix `cast_sign_loss` false positive

This checks if the value is a non-negative constant before linting about
losing the sign.

Because the `constant` function doesn't handle const functions, we check if
the value is from a call to a `max_value` function directly. A utility method
called `get_def_path` was added to make checking for the function paths
easier.

Fixes #2728
2019-02-04 05:52:44 +00:00
Michael Wright
f3ee53d225 Document get_def_path 2019-02-04 07:30:24 +02:00
Manish Goregaokar
7bea43614c
Merge pull request #3735 from jsgf/setup-toolchain
Add setup-toolchain.sh script to configure the master version of rustc,
2019-02-03 21:14:07 -08:00
Jeremy Fitzhardinge
47563a13eb Add setup-toolchain.sh script to configure the master version of rustc,
and update CONTRIBUTING.md accordingly.
2019-02-03 14:41:46 -08:00
bors
69a7f03185 Auto merge of #3737 - phansch:2018, r=phansch
Transition leftover test libs to Rust 2018

To tick off some checkboxes in https://github.com/rust-lang/rust/issues/58099 =)
2019-02-03 15:24:54 +00:00
Philipp Hansch
64ff65990f
Transition leftover test libs to Rust 2018 2019-02-03 14:47:03 +01:00