Commit graph

1510 commits

Author SHA1 Message Date
Mateusz Mikuła
a6601f2d02 Enable rust_2018_idioms warning 2018-06-25 20:56:25 +02:00
Oliver Schneider
9f8624e5bf Version bump 2018-06-25 18:18:50 +02:00
flip1995
203ad28021
resolve merge of NameAndSpan and ExpnInfo rust-lang/rust#51726 2018-06-25 12:25:20 +02:00
flip1995
535c168791
Fix the tests that got broken by the fixes 2018-06-25 12:25:20 +02:00
flip1995
c83fd39e0e
Resolve conflicts produced by GenericArgs
Addresses the move/zip of Lifetimes and Types vectors from hir::PathParameters into the args vector of GenericArgs
2018-06-25 12:31:39 +02:00
flip1995
d9a80d2f84
Resolve field, struct and function renaming
Addresses the errors produced by (re)moving, merging or renaming
structs, fields and methods by rust-lang/rust#48149 and rust-lang/rust#51580
2018-06-25 12:25:20 +02:00
flip1995
6224e19b80
Check for arguments before accessing the first arg 2018-06-21 15:46:24 +02:00
Oliver Schneider
25510cfb13
Merge pull request #2790 from shnewto/vectors-to-indexing-slicing-lint
Extend `indexing_slicing` lint
2018-06-21 10:30:40 +02:00
Bruno Kirschner
fedd3ef711 Allows neg_cmp_op_on_partial_ord for external macros (fixes #2856).
The macro always negates the result of the given comparison in its
internal check which automatically triggered the lint. As its an
external macro there was no chance to do anything about it which lead
to a white listing of all external macros to prevent further issues.
2018-06-20 11:58:15 +02:00
Shea Newton
c479b3bc28
Removing lint for constant usize array indexing
This commit removes the logic in this PR that linted out-of-bounds constant `usize` indexing on arrays. That case is already handled by rustc's `const_err` lint. Beyond removing the linting logic, the test file and its associated stderr were updated to verify that const `usize` indexing operations on arrays are no longer handled by this `indexing_slicing` lint.
2018-06-19 21:30:43 +00:00
Shea Newton
4ec439bef0
Revisiting indexing_slicing test cases
This commit contains a few changes. In an attempt to clarify which test cases should and should not produce stderr it became clear that some cases were being handled incorrectly. In order to address these test cases, a minor re-factor was made to the linting logic itself.

The re-factor was driven by edge case handling including a need for additional match conditions for `ExprCall` (`&x[0..=4]`) and `ExprBinary` (`x[1 << 3]`). Rather than attempt to account for each potential `Expr*` the code was re-factored into simply "if ranged index" and an "otherwise" conditions.
2018-06-19 16:28:10 +00:00
Shea Newton
8b59542acc
Second pass at addressing changes requested
The changes reflected in this commit (requested in PR #2790) are as follows:

- Extended `INDEXING_SLICING` documentation to include the array type so that it is clearer when indexing operations are allowed.
- Variable `ty` defined identically in multiple scopes was moved to an outer scope so it's only defined once.
- Added a missing return statement to ensure only one lint is triggered by a scenario.
- Prettified match statement with a `let` clause. (I learned something new!)
- Added `&x[5..].iter().map(|x| 2 * x).collect::<Vec<i32>>()` and `&x[2..].iter().map(|x| 2 * x).collect::<Vec<i32>>()` to the test cases. The first _should trigger the lint/stderr_ and the second _should not_.
2018-06-19 16:28:10 +00:00
Shea Newton
a7c0ff3fa6
This commit represents an attempt to address changes requested in the process of reviewing PR #2790.
The changes reflected in this commit are as follows:

- Revised `IndexingSlicingPass` struct name to IndexingSlicing for consistency with the rest of the code base.
- Revised match arm condition to use `(..)` shorthand in favor of `(_, _, _)`.
- Restored a couple telling variable names.
- Calls to `cx.span_lint` were revised to use `utils::span_help_and_lint`.
- Took a stab at refactoring some generalizable calls to `utils::span_help_and_lint` to minimize duplicate code.
- Revised INDEXING_SLICING declaration to pedantic rather than restriction.
- Added `&x[0..].get(..3)` to the test cases.
2018-06-19 16:28:10 +00:00
Shea Newton
5b759efa4c
Rename instances of array_indexing
This commit renames instances of `array_indexing` to `indexing_slicing` and moves the `indexing_slicing` lint to the `clippy_pedantic` group. The justification for this commit's changes are detailed in the previous commit's message.
2018-06-19 16:27:39 +00:00
Shea Newton
7af0c67855
Extend indexing_slicing lint
Hey there clippy team! I've made some assumptions in this PR and I'm not at all certain they'll look like the right approach to you. I'm looking forward to any feedback or revision requests you have, thanks!

    Prior to this commit the `indexing_slicing` lint was limited to indexing/slicing operations on arrays. This meant that the scope of a really useful lint didn't include vectors. In order to include vectors in the `indexing_slicing` lint a few steps were taken.

    The `array_indexing.rs` source file in `clippy_lints` was renamed to `indexing_slicing.rs` to more accurately reflect the lint's new scope. The `OUT_OF_BOUNDS_INDEXING` lint persists through these changes so if we can know that a constant index or slice on an array is in bounds no lint is triggered.

    The `array_indexing` tests in the `tests/ui` directory were also extended and moved to `indexing_slicing.rs` and `indexing_slicing.stderr`.

    The `indexing_slicing` lint was moved to the `clippy_pedantic` lint group.

    A specific "Consider using" string was added to each of the `indexing_slicing` lint reports.

    At least one of the test scenarios might look peculiar and I'll leave it up to y'all to decide if it's palatable. It's the result of indexing the array `x` after `let x = [1, 2, 3, 4];`

    ```
    error: slicing may panic. Consider using `.get(..n)`or `.get_mut(..n)`instead
      --> $DIR/indexing_slicing.rs:23:6
       |
    23 |     &x[0..][..3];
       |      ^^^^^^^^^^^
    ```

    The error string reports only on the second half's range-to, because the range-from is in bounds!

    Again, thanks for taking a look.

    Closes #2536
2018-06-19 16:27:08 +00:00
uHOOCCOOHu
ce1800d599
Check lifetimes in Fn traits in generic bounds.
Add tests.
2018-06-19 21:25:38 +08:00
Oliver Schneider
d761ba78d8
Merge pull request #2837 from fanzier/panicking_unwrap
Implement lint checking for `unwrap`s that will always panic.
2018-06-19 13:30:38 +02:00
Oliver Schneider
4839c790ae
Merge pull request #2844 from illicitonion/default_trait_access
Add default_trait_access lint
2018-06-19 10:10:20 +02:00
Oliver Schneider
7d672888fe Version bump 2018-06-19 09:56:37 +02:00
Daniel Wagner-Hall
b24d75313e Exclude generated code 2018-06-18 10:29:25 +01:00
Mateusz Mikuła
8625cfb988 Version bump 2018-06-18 09:56:58 +02:00
Wim Looman
621fdcc3bc Dogfood new trivially_copy_pass_by_ref lint 2018-06-15 16:53:34 +02:00
Wim Looman
700ece5648 Allow configuring the trivial copy size limit 2018-06-15 16:53:34 +02:00
Wim Looman
7547a4ddef New Lint: Pass small trivially copyable objects by value
Fixes #1680

Hardcoded for 64-bit "trivial" size for now
2018-06-15 16:53:34 +02:00
Manish Goregaokar
0c23112846 More doc fixes 2018-06-15 00:20:46 -07:00
Manish Goregaokar
00a0efc566 Doc fix syntax 2018-06-15 00:19:19 -07:00
Daniel Wagner-Hall
4866309f9d Add default_trait_access lint 2018-06-14 09:11:46 +01:00
Oliver Schneider
26bc88d48c
Merge pull request #2839 from mikerite/duration_subsec_pr_2
Add duration_subsec lint
2018-06-12 06:30:20 -07:00
Fabian Zaiser
817da4c00a Fix documentation 2018-06-12 15:06:46 +02:00
Fabian Zaiser
35d1b19a03 Fix markdown. 2018-06-12 15:06:46 +02:00
Fabian Zaiser
8682858e2c Categorize the unwrap lints correctly. 2018-06-12 15:06:46 +02:00
Fabian Zaiser
0c6730d851 Update known problems. 2018-06-12 15:04:44 +02:00
Fabian Zaiser
23404287fc Implement lint checking for unwraps that will always panic. 2018-06-12 15:04:44 +02:00
Michael Wright
725e9621d0 duration_subsec: Add check for subsec_micros 2018-06-12 08:25:10 +02:00
Oliver Schneider
8f0edba6e9
Merge pull request #2815 from darArch/master
Warn if non-trivial work is done inside .expect
2018-06-11 06:33:26 -07:00
Donald Robertson
c6fb47331a Updating docs to reflect more recent changes to expect_fun_call lint 2018-06-11 14:17:40 +01:00
Michael Wright
2d427ea7ee Merge branch 'master' into duration_subsec_pr_2 2018-06-11 07:48:10 +02:00
Oliver Schneider
8fe90e41d0 Publish preparation 2018-06-10 06:22:07 +02:00
Michael Wright
b0d364cb3e duration_subsec: fix declaration; correctly classify 2018-06-09 11:04:21 +02:00
Michael Wright
7b2fa2077f Add duration_subsec lint
Closes #2543
2018-06-09 10:21:26 +02:00
Oliver Schneider
91986fa933
Merge pull request #2836 from mati865/upcoming_breakage
Upcoming breakage
2018-06-09 06:56:39 +02:00
Fabian Zaiser
54826cf72e Address review comments. 2018-06-08 06:02:25 +02:00
Fabian Zaiser
81821acd59 Implement lint that checks for unidiomatic unwrap() (fixes #1770)
This checks for things like

    if x.is_some() {
        x.unwrap()
    }

which should be written using `if let` or `match` instead.

In the process I moved some logic to determine which variables are
mutated in an expression to utils/usage.rs.
2018-06-08 05:29:25 +02:00
Mateusz Mikuła
3693a4ea53 Formatting 2018-06-07 22:01:46 +02:00
Oliver Schneider
2a2e602f2a
Merge pull request #2833 from phansch/cannot_relate_bound_region_without_ICE_cream
Fix cargo late bound region mismatch ICE
2018-06-07 11:52:32 +02:00
Philipp Hansch
17aff1d774
Fix cargo late bound region mismatch ICE 2018-06-07 07:42:45 +02:00
Donald Robertson
e70632215e Combining if statements per lint warnings on build 2018-06-06 20:38:13 +01:00
Donald Robertson
9c73f7ff18 Amending use of Some with discarded value to use is_some 2018-06-06 17:13:31 +01:00
Donald Robertson
e67d2b2663 Added check to ensure format macro only being handled, refactored extraction and checks to smaller functions. 2018-06-06 16:53:11 +01:00
Oliver Schneider
7563d8155b
Merge pull request #2804 from utaal/expr-call-author
Add support for ExprCall in clippy::author
2018-06-06 15:17:47 +02:00