Commit Graph

5742 Commits

Author SHA1 Message Date
bors
2139fbdbe1 Auto merge of #3783 - Enet4:patch-1, r=Manishearth
Update why transmute_int_to_float is bad

As suggested in #3550, this PR changes the reason why using `transmute` from an integer to a float is not recommended. Effectively, `from_bits` uses `transmute` underneath, but the former is preferred.
2019-02-18 20:05:54 +00:00
phil
3fa3bd8e94 Don't fail for raw string ending in \n
Pass tests for #3778, {print,write}_with_newline false positive

This change guards the lint from checking newlines with a sort of complicated
check to see if it's a raw string. Raw strings shouldn't be newline-checked,
since r"\n" is literally \-n, not a newline. I think it's ok not to check for
_literal_ newlines at the end of raw strings, but maybe that's debatable.

I... don't think this code is that great. I wanted to write the check after
`check_tts`, but that was too late -- raw string type info is lost (or I
couldn't find it). Putting it inside `check_tts` feels heavy-duty and the check
itself feels like a brittle reach possibly into places it shouldn't.

Maybe someone can fix this up :)
2019-02-18 11:39:40 -05:00
phil
cf5d4a1b45 Add failing test for #3778 write_with_newline
Literal `\n` characters (not a newline) in a `r"raw"` string should not
fail the lint.

This affects both write_with_newline and print_with_newline, so it is added in
both places.

I also copied a missing test case from write_with_newline over to
print_with_newline and added a note that one of those tests is supposed to
fail.
2019-02-18 11:39:40 -05:00
Eduardo Pinho
8994466bfe
Format transmute_from_int_to_float docs 2019-02-18 15:09:34 +00:00
Eduardo Pinho
74ac35bcab
Update why transmute_int_to_float is bad
Fix #3550
2019-02-18 14:14:54 +00:00
bors
1620e92dd6 Auto merge of #3777 - timotree3:patch-1, r=Manishearth
Fix typo in documentation for float_cmp_const lint
2019-02-18 11:40:29 +00:00
Michael Wright
9185c8d996 Format 2019-02-18 08:32:53 +02:00
Michael Howell
cb1c0b6849 Update README and CHANGELOG 2019-02-17 22:53:08 -07:00
Michael Howell
2df14c3701 Add a lint to warn on T: Drop bounds
**What it does:** Checks for generics with `std::ops::Drop` as bounds.

**Why is this bad?** `Drop` bounds do not really accomplish anything.
A type may have compiler-generated drop glue without implementing the
`Drop` trait itself. The `Drop` trait also only has one method,
`Drop::drop`, and that function is by fiat not callable in user code.
So there is really no use case for using `Drop` in trait bounds.

**Known problems:** None.

**Example:**
```rust
fn foo<T: Drop>() {}
```
2019-02-17 22:53:08 -07:00
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