Commit Graph

3245 Commits

Author SHA1 Message Date
Krishna Veera Reddy
460d5a3b5a Prevent cmp_nan when inside constants
`std::{f32,f64}::is_nan` isn't a const fn so prevent `cmp_nan`
lint from running within constant comparisons.
2019-12-17 19:18:42 -08:00
Krishna Veera Reddy
eb0408ea65 Detect comparisons with NAN constants
Currently `cmp_nan` lint doesn't detect comparisons with NaN's
if the operands are consts variables so to fix this we evaluate
the const variables first before testing for NaN.
2019-12-17 18:51:30 -08:00
Krishna Veera Reddy
728a2418cb Fix clippy build failure
Clippy build fails because the feature `result_map_or` has been
stabilized in v1.41.0 but we still have an explicit feature
attribute for it.
2019-12-16 22:29:05 -08:00
bors
d82debbd01 Auto merge of #4883 - krishna-veerareddy:issue-4818-cast-sign-loss-false-positive, r=flip1995
Fix false positive with cast_sign_loss lint

`cast_sign_loss` lint incorrectly suggests that the result of `checked_abs`, `rem_euclid` and `checked_rem_euclid` cannot be casted to an unsigned integer without loss.

Fixes #4818 #4764 #4743

changelog: Fix false positives in `cast_sign_loss` lint
2019-12-12 00:34:59 +00:00
bors
221bf650f6 Auto merge of #4886 - rust-lang:must-use-pub-only, r=phansch
Lint only exported must_use_candidates

As promised on #4779, here's the check for publicly visible items for `must_use_candidate`

changelog: none
2019-12-11 12:01:10 +00:00
Krishna Veera Reddy
c77fc06d52 Add lint to detect transmutes from float to integer
Add lint that detects transmutation from a float to an integer
and suggests usage of `{f32, f64}.to_bits()` instead.
2019-12-07 16:33:49 -08:00
Andre Bogus
a60177cc1e Lint only exported must_use_candidates 2019-12-06 20:10:14 +01:00
RobbieClarken
f5d0a452ba Add lint for pub fns returning a Result without documenting errors
The Rust Book recommends that functions that return a `Result` type have
a doc comment with an `# Errors` section describing the kind of errors
that can be returned
(https://doc.rust-lang.org/book/ch14-02-publishing-to-crates-io.html#commonly-used-sections).
This change adds a lint to enforce this. The lint is allow by default;
it can be enabled with `#![warn(clippy::missing_errors_doc)]`.

Closes #4854.
2019-12-06 17:19:05 +10:30
Krishna Veera Reddy
7002a9ee83 Fix false positive with cast_sign_loss lint
`cast_sign_loss` lint incorrectly suggests that the result of
`checked_abs`, `rem_euclid` and `checked_rem_euclid` cannot
be casted to an unsigned integer without loss.
2019-12-05 15:47:15 -08:00
daxpedda
946961d19e
Change to only detect in external macros. 2019-12-05 11:06:13 +01:00
daxpedda
d11b958faf
Fix false positive in string_add. 2019-12-04 21:51:02 +01:00
Matthias Krüger
98e433d70d
Rustup to rust-lang/rust#66878 2019-12-04 01:34:01 +01:00
bors
c66cca44c8 Auto merge of #4877 - flip1995:manual_swap_4853, r=llogiq
Fix FP in manual_swap lint with slice-like types

Fixes #4853

changelog: Fix FP in [`manual_swap`] lint with slice-like types and make it auto applicable
2019-12-03 18:36:19 +00:00
flip1995
c56f72da35
Make OP_REF lint suggestion MaybeIncorrect
cc #2597
2019-12-03 18:37:07 +01:00
Christopher Durham
718558064d
Fire clippy::op_ref on PartialOrd but !Ord types 2019-12-03 18:37:07 +01:00
flip1995
f6a75f17f6
Rustup to rust-lang/rust#66935 2019-12-03 18:37:06 +01:00
flip1995
aa2381d9d0
Fix rustdoc examples 2019-12-03 16:29:05 +01:00
flip1995
1e3b24de43
Make manual_swap autofixable 2019-12-03 13:42:05 +01:00
flip1995
bd39a608a8
Formatting 2019-12-03 13:25:41 +01:00
flip1995
d1d5f790f5
Fix FP in manual_swap lint with slice-like types 2019-12-03 13:25:41 +01:00
flip1995
286b39d2e5
Rustup to rust-lang/rust#64736 2019-12-02 20:39:40 +01:00
Philipp Hansch
474e9a131d
Use assert_crate_local for a more explicit error
`assert_crate_local` does the same as the previous `if let` but with a
more explicit error message if it's not a `ClearCrossCrate::Set`.
2019-12-02 12:09:38 +01:00
Philipp Hansch
6669c2c6ce
Rustup to https://github.com/rust-lang/rust/pull/66789 2019-12-02 09:51:35 +01:00
bors
45196cee02 Auto merge of #4690 - lzutao:fix-test-on-non-amd64, r=flip1995
generate stderr file on 32bit pointer system

changelog: none
2019-12-01 18:39:21 +00:00
Lzu Tao
5488672d1f account for external macro in MISSING_INLINE_IN_PUBLIC_ITEMS lint 2019-12-01 19:38:01 +07:00
Lzu Tao
142b289a51 chore: fix and split some ui tests on 32bit system 2019-12-01 19:07:02 +07:00
Andre Bogus
ef7587d957 Less needless_doctest_main false positives
This checks if a) the `fn main() {}` function is empty or if the doctest contains a `static`. In both cases don't lint.
2019-11-29 21:47:26 +01:00
Philipp Hansch
c1ccba005f
fmt 2019-11-29 20:47:50 +01:00
Philipp Hansch
ad6d8a4700
Make triggering this lint less likely 📎 2019-11-29 20:47:50 +01:00
Philipp Hansch
676f14baa0
Add custom ICE message that points to Clippy repo
This utilizes https://github.com/rust-lang/rust/pull/60584 by setting
our own `panic_hook` and pointing to our own issue tracker instead of
the rustc issue tracker.

This also adds a new internal lint to test the ICE message.

**Potential downsides**

* This essentially copies rustc's `report_ice` function as
  `report_clippy_ice`. I think that's how it's meant to be implemented, but
  maybe @jonas-schievink could have a look as well =)

  The downside of more-or-less copying this function is that we have to
  maintain it as well now.
  The original function can be found [here][original].
* `driver` now depends directly on `rustc` and `rustc_errors`

Closes #2734

[original]: 59367b074f/src/librustc_driver/lib.rs (L1185)
2019-11-29 20:47:47 +01:00
bors
04036877ef Auto merge of #4863 - phansch:use_self, r=flip1995
Move use_self to nursery

Closes #4859

We have a lot of false positives in this lint, so I think it makes sense
to move this to the nursery until they are resolved.

changelog: Move `use_self` lint to nursery, due to many false positives
2019-11-29 18:17:41 +00:00
flip1995
fd7eca2baf
Run update_lints 2019-11-29 14:50:19 +01:00
flip1995
604e6ba0e2
Add projections check to EUV for escape analysis 2019-11-29 12:57:10 +01:00
flip1995
b2523afae4
Use infer_ctxt 2019-11-29 11:12:19 +01:00
Philipp Hansch
70a2a29453
Move use_self to nursery
Closes #4859

We have a lot of false positives in this lint, so I think it makes sense
to move this to the nursery until they are resolved.

changelog: Move `use_self` lint to nursery, due to many false positives
2019-11-29 07:51:49 +01:00
Manish Goregaokar
45842e5131 Fix categorizations 2019-11-28 07:33:12 -08:00
Manish Goregaokar
c1c5c3522d Fix arguments on ExprUseVisitor::new 2019-11-28 07:20:37 -08:00
Manish Goregaokar
dc9d839410 euv moved from middle to typeck 2019-11-28 07:17:56 -08:00
Manish Goregaokar
85bb66480c cmt_ -> Place 2019-11-28 07:09:02 -08:00
bors
b5a6714155 Auto merge of #4849 - flip1995:deny_warnings, r=phansch
Deny warnings in CI

Removes the `debugging` feature, that wasn't used anymore and adds/enables the `deny-warnings` feature for every sub-crate of Clippy.

changelog: none
2019-11-28 10:27:46 +00:00
bors
dbdd75ab52 Auto merge of #4855 - phansch:rollup-x7yail7, r=phansch
Rollup of 3 pull requests

Successful merges:

 - #4832 (Add some positive examples to lint docs)
 - #4842 ([comparison_chain] #4827 Check `core::cmp::Ord` is implemented)
 - #4847 (fixing a typo)

Failed merges:

changelog: none

r? @ghost
2019-11-28 09:30:16 +00:00
Phil Hansch
a05f3cb9a1
Rollup merge of #4847 - rust-lang:offest, r=phansch
fixing a typo

changelog: none
2019-11-28 10:19:06 +01:00
Phil Hansch
1165176840
Rollup merge of #4842 - timbodeit:comparison-chain-false-positive-4827, r=flip1995
[comparison_chain] #4827 Check `core::cmp::Ord` is implemented

Only emit `comparison_chain` lint, if `cmp` is actually available on the type being compared. Don't emit lint in cases where only `PartialOrd` is implemented.

I haven't yet fully understood [Adjustments](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/adjustment/struct.Adjustment.html). I would appreciate, if someone could double check whether my usage of [expr_ty](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TypeckTables.html#method.expr_ty) in `clippy_lints/src/comparison_chain.rs:91` is correct or if there are cases where using [expr_ty_adjusted](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TypeckTables.html#method.expr_ty_adjusted) would lead to a different result when used with `utils::implements_trait`.

---

fixes #4827
changelog: [comparison_chain] Check `core::cmp::Ord` is implemented
2019-11-28 10:19:05 +01:00
Phil Hansch
6686892cbf
Rollup merge of #4832 - dario23:i4829, r=phansch
Add some positive examples to lint docs

fixes #4829
changelog: Add some positive examples to lint docs
2019-11-28 10:19:04 +01:00
bors
f3288eb48d Auto merge of #4851 - daxpedda:float-arithmetic, r=flip1995
Remove negative float literal checks.

Fixes #4850.

changelog: Remove negative float literal checks.
2019-11-28 09:11:45 +00:00
bors
d377486561 Auto merge of #4821 - Areredify:as_conversions, r=flip1995
Add `as_conversions` lint

changelog: closes #4771, adding a new pedantic allow-by-default lint that lints against any usage of `as`.
2019-11-28 08:53:36 +00:00
bors
d6accfcc82 Auto merge of #4808 - euclio:string-lit-as-bytes, r=phansch
trigger string_lit_as_bytes when literal has escapes

---

changelog: fix string_lit_as_bytes false negative

Depends on rust-lang/rust#66349.

Fixes #4796.
2019-11-28 07:26:04 +00:00
Lzu Tao
d0e0ffa99f make use of Result::map_or 2019-11-28 10:52:20 +07:00
Manish Goregaokar
40c91ec758 config.usize_ty -> config.ptr_width
From http://github.com/rust-lang/rust/pull/66719
2019-11-27 15:09:48 -08:00
Manish Goregaokar
e381143a6b More borrowkind fixes 2019-11-27 15:09:48 -08:00