Commit graph

4063 commits

Author SHA1 Message Date
gnzlbg 7c4ec40346 add missing_inline lint
When turned on, the lint warns on all exported functions, methods,
trait methods (default impls, impls), that are not `#[inline]`.

Closes #1503.
2018-07-04 13:50:39 +02:00
llogiq 30a9879c46
Merge pull request #2888 from mikerite/refactor_lifetimename_static
Use slightly neater check for static lifetimes
2018-07-01 12:54:06 +02:00
Michael Wright dfd9e10a2a Use slightly neater check for static lifetimes 2018-07-01 11:58:29 +02:00
Oliver Schneider b4b6e6558e Version bump 2018-06-29 10:22:01 +02:00
Oliver Schneider 3aee654dd1
Merge pull request #2880 from mati865/rustup_hir
Rustup
2018-06-29 10:20:19 +02:00
Mateusz Mikuła a24f77f65a Bump the version 2018-06-29 09:55:20 +02:00
Mateusz Mikuła 48cb6e273e Rustup 2018-06-29 09:49:05 +02:00
Mateusz Mikuła b7d95f486b Fix warnings 2018-06-28 13:33:11 +02:00
Oliver Schneider 656b26ea4f
Merge pull request #2832 from kennytm/non-copy-const
Lint against const items which are interior mutable.
2018-06-28 08:39:54 +02:00
Oliver Schneider 296b15e908
Merge pull request #2876 from AVerm/patch-1
Removed placeholder doc-comments
2018-06-27 10:02:14 +02:00
Alex Vermillion 536e7c8f38
Removed placeholder doc-comments
There were comments instructing someone to insert an example, but an example was already present
2018-06-26 20:22:36 -05:00
Manish Goregaokar 73a80c5950
Merge pull request #2872 from rust-lang-nursery/pedantic-default
Move default_trait_access to pedantic
2018-06-26 13:03:31 -07:00
Oliver Schneider 052427e87a
Merge pull request #2873 from mati865/edition2018_next_step
Next step towards Rust 2018...
2018-06-26 11:11:53 +02:00
Oliver Schneider 0de3f36a02
Merge pull request #2849 from mikerite/issue_2741
Fix #2741
2018-06-26 11:08:19 +02:00
Michael Wright 4827bdcc1c Merge branch 'master' into issue_2741 2018-06-26 07:46:56 +02:00
Philipp Krones 3626d86eef
Merge pull request #2867 from flip1995/ice-2865
Use utils::opt_def_id() instead of def_id() to prevent ICE
2018-06-25 23:00:58 +02:00
flip1995 b2fb01f23b
Use utils::opt_def_id() instead of def_id() to prevent ICE 2018-06-25 22:25:15 +02:00
Mateusz Mikuła df3b9cc350 Format the code 2018-06-25 21:41:24 +02:00
Mateusz Mikuła 1036df5699 Fix clippy_lints doc-tests 2018-06-25 21:22:53 +02:00
Mateusz Mikuła a6601f2d02 Enable rust_2018_idioms warning 2018-06-25 20:56:25 +02:00
Manish Goregaokar 9f24b9d4b3 Move default_trait_access to pedantic 2018-06-25 11:39:48 -07:00
Oliver Schneider 9f8624e5bf Version bump 2018-06-25 18:18:50 +02:00
Oliver Schneider d4618e0879
Merge pull request #2871 from flip1995/gen_gen_nightly
The Great Generics Generalisation: Clippy edition
2018-06-25 18:14:48 +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
kennytm 88b7603b16
Lint against const items which are interior mutable. Fix #1560. 2018-06-23 03:35:36 +08:00
Oliver Schneider 5f5fa084ec
Merge pull request #2864 from flip1995/issue-2862
Fix panic on map_clone lint
2018-06-21 16:14:40 +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
Oliver Schneider dbc9e3674f
Merge pull request #2863 from Fraser999/exit_code
Ensure a non-zero value is returned by clippy if compilation fails
2018-06-21 10:26:32 +02:00
Philipp Hansch a66bab1b39
Merge pull request #2592 from phansch/link_to_correct_appveyor_build
Link to correct AppVeyor project in Readme
2018-06-21 06:57:24 +01:00
Philipp Hansch 50027405c3
Link to correct AppVeyor project in Readme 2018-06-21 07:40:29 +02:00
Fraser Hutchison 5be00bcd18 Ensure a non-zero value is returned by clippy if compilation fails 2018-06-21 05:20:14 +01:00
Manish Goregaokar cd90441a73
Merge pull request #2861 from rust-lang-nursery/oli-obk-patch-1
Mention the RFC on top of the README
2018-06-20 11:48:14 -07:00
Oliver Schneider 0f848576e9
Update README.md 2018-06-20 20:37:22 +02:00
Oliver Schneider a73d552f3a
Merge pull request #2859 from 0ndorio/fix/false_positive_on_assert_in_neg_cmp_partial
Allows neg_cmp_op_on_partial_ord for external macros (fixes #2856).
2018-06-20 13:03:37 +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
Philipp Hansch e4d31ab86c
Merge pull request #2858 from phansch/update_allowed_failures
No more allowed failures in integration tests
2018-06-20 06:35:24 +01:00
Philipp Hansch 0b7dcdf6e7
No more allowed failures in integration tests
They have all been working for some time now.
2018-06-20 07:12:50 +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 e63f5dfedb
Add tests that index with a const value.
In this commit tests were added to ensure that tests with a `const` index behaved as expected.
In order to minimize the changes to the test's corresponding `stderr`, the tests were appended to
the end of the file.
2018-06-19 16:28:10 +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
Oliver Schneider c573186245
Merge pull request #2855 from uHOOCCOOHu/impl-fn-lifetime
Fix false positive `unused_lifetime` when referenced in generic bounds.
2018-06-19 18:00:21 +02:00
uHOOCCOOHu 5b57b5fc61
Add notes for test examples. 2018-06-19 23:18:53 +08:00