Commit graph

10381 commits

Author SHA1 Message Date
Daniel Smith
02f99bea87 Explicitly document false positives 2021-01-13 16:08:15 -05:00
bors
00586dfdcd Auto merge of #6584 - giraffate:make_references_to_issues_links, r=llogiq
Make a reference a link in doc

I think it's incovenient that references in doc are just a text.

changelog: none
2021-01-13 08:16:43 +00:00
Takayuki Nakata
ea028497ed Make a reference a link in doc 2021-01-13 09:21:26 +09:00
bors
13ca5c88f1 Auto merge of #6462 - flip1995:roadmap, r=flip1995,llogiq,killercup,Manishearth,oli-obk,matthiaskrgr,phansch,mikerite,mcarton,yaahc,ebroto
Roadmap for 2021

[Rendered](https://github.com/flip1995/rust-clippy/blob/roadmap/doc/roadmap-2021.md)

This is the first time Clippy gets its own roadmap. The reason for this roadmap is, that with the Rust language growing, also Clippy is growing. With this keeping track of and implementing bigger projects gets quite hard. This roadmap should help in exactly this regard.

After having the approval of this roadmap by the Clippy team, we want to know from the community:

- What do you think in general about this roadmap?
- Are there any pain points in Clippy, that should be included here?
- What of the points listed here has the highest priority for you?

We're looking forward to getting your feedback!

changelog: Add roadmap for Clippy 2021

r? `@rust-lang/clippy`
2021-01-12 16:33:47 +00:00
bors
7f4599a848 Auto merge of #6557 - rail-rain:extending_cast_ptr_alignment, r=phansch
Catch `pointer::cast` too in `cast_ptr_alignment`

Fixes #4708

Although there were some discussion in the issue, this PR implements the original feature. I think `cast_ptr_alignment` should exist as it is, separated from `ptr_as_ptr`.

---

changelog: Extend `cast_ptr_alignment` lint for the `pointer::cast` method
2021-01-11 22:03:46 +00:00
rail
53f87310cd Simplify cast_ptr_alignment pointer::casr case 2021-01-12 10:06:41 +13:00
bors
1eed27f374 Auto merge of #6575 - flip1995:stop_linting_deps, r=Manishearth
Change env var used for testing Clippy

This changes the variable used for testing Clippy in the internal test
suite:

```
CLIPPY_TESTS -> __CLIPPY_INTERNAL_TESTS
```

`CLIPPY_TESTS` is understandably used in environments of Clippy users,
so we shouldn't use it in our test suite.

changelog: Fix oversight which caused Clippy to lint deps in some environments.

Once again fixes https://github.com/rust-lang/rust-clippy/issues/3874
2021-01-11 16:49:32 +00:00
bors
583715f583 Auto merge of #6565 - giraffate:small_fixes_of_doc_in_needless_question_mark, r=phansch
Small fixes of doc in `needless_question_mark`

changelog: none
2021-01-09 15:28:10 +00:00
bors
ee0598e254 Auto merge of #6571 - ThibsG:BoxedLocalTrait, r=phansch
Fix FP for `boxed_local` lint in default trait fn impl

Fix FP on default trait function implementation on `boxed_local` lint.

Maybe I checked too much when looking if `self` is carrying `Self` in its bound type.
I can't find a good test case for this, so it could be too much conservative.
Let me know if you think only detecting `self` parameter is enough.

Fixes: #4804

changelog: none
2021-01-09 13:42:28 +00:00
ThibsG
8a6fea4fb8 Fix FP for boxed_local lint in default trait fn impl 2021-01-09 12:26:24 +01:00
bors
68bcd202fe Auto merge of #6569 - camsteffen:symbol-comparison, r=Manishearth
Internal lint symbol comparisons

changelog: none

* Added awareness of `rustc_span::symbol::kw::*` symbols.
* Compare with const symbols: `symbol.as_str() == "self"` => `symbol == kw::SelfLower`
* Don't compare symbols by string: `a.as_str() == b.as_str()` => `a == b`
* Lint comparing with `to_ident_string` or `to_string` instead of `Symbol::as_str`.
2021-01-08 23:25:57 +00:00
Cameron Steffen
7871ebaab9 Fix symbol string comparison dogfood 2021-01-08 14:50:00 -06:00
Cameron Steffen
cc26919b4d Add unnecessary symbol string lint 2021-01-08 14:49:59 -06:00
Cameron Steffen
76ccfb4ae2 Fix unnecessary keyword intern dogfood 2021-01-08 14:32:32 -06:00
Cameron Steffen
121c65f0cf Add keywords to interning defined symbol lint 2021-01-08 12:13:06 -06:00
Cameron Steffen
24c700b5d7 Use DefId in interning defined symbol lint 2021-01-08 12:13:06 -06:00
bors
2950c8e1cb Auto merge of #6566 - giraffate:reduce_the_span_in_from_over_into, r=Manishearth
Reduce the span in `from_over_into` to impl header

A follow up of https://github.com/rust-lang/rust-clippy/pull/6476#discussion_r546271382
> That item might be quite large. We may want to reduce the span to the `impl` header.

changelog: none
2021-01-08 01:49:26 +00:00
rail
ee9b47dae6 Move is_hir_ty_cfg_dependant to util,
add stuff on pointer::cast` to the document for `cast_ptr_alignment`
and fix line numbers in the test.
2021-01-08 14:15:12 +13:00
Takayuki Nakata
0e14a75506 Reduce the span in from_over_into to impl header 2021-01-08 09:16:11 +09:00
Takayuki Nakata
aa9adbf244 Small fixes of doc in needless_question_mark 2021-01-08 08:45:15 +09:00
bors
e15bef9d3f Auto merge of #6558 - stanislav-tkach:patch-2, r=flip1995
Fix typo: `irrevelent` -> `irrelevant`

changelog: none
2021-01-07 13:38:32 +00:00
Stanislav Tkach
2b3c0ade6d
Fix typo: irrevelent -> irrelevant 2021-01-07 13:59:55 +02:00
flip1995
547ce0db27
Change env var used for testing Clippy
This changes the variable used for testing Clippy in the internal test
suite:

```
CLIPPY_TESTS -> __CLIPPY_INTERNAL_TESTS
```

`CLIPPY_TESTS` is understandably used in environments of Clippy users,
so we shouldn't use it in our test suite.
2021-01-07 12:38:10 +01:00
rail
f50ded0592 Catch pointer::cast too in cast_ptr_alignment 2021-01-07 16:56:19 +13:00
bors
8e5c5a64a5 Auto merge of #6554 - sozysozbot:master, r=flip1995
Fix typo: `which which can be` -> `which can be`

Fixed a typo in the explanation of https://rust-lang.github.io/rust-clippy/master/index.html#large_types_passed_by_value : `which which can be` -> `which can be`

changelog: none
2021-01-06 11:57:56 +00:00
jekto_vatimeliju
8a45ffa11d Fix typo: which which can be -> which can be 2021-01-06 20:02:50 +09:00
bors
efccfe80e4 Auto merge of #6553 - phansch:field-reassign-with-default-macros, r=flip1995
Fix derive and macro related false positives in `field_reassign_with_default`

Closes #6545

changelog: Fix derive and macro related false positives in [`field_reassign_with_default`]
2021-01-06 08:22:47 +00:00
Philipp Hansch
92f2bbbe06
Fix macro issues with field_reassign_with_default 2021-01-05 20:31:13 +01:00
Philipp Hansch
a8825e9af0
Use existing 'is_automatically_derived' helper 2021-01-05 16:31:08 +01:00
bors
42b9e92af7 Auto merge of #6551 - phansch:tiny-symbol-cleanup, r=flip1995
Tiny Symbol cleanup

* Renames `sym.rs` to `sym_helper.rs` so that the `sym as rustc_sym` is no longer needed.
* Removes one needless `symbol` from a path

changelog: none
2021-01-05 15:22:57 +00:00
Philipp Hansch
ea885d90ad
Tiny Symbol cleanup
* Renames `sym.rs` to `sym_helper.rs` so that the `sym as rustc_sym` is no longer needed.
* Removes one needless `symbol` from a path
2021-01-05 16:03:39 +01:00
bors
a6b72d378f Auto merge of #6542 - rail-rain:ptr_as_ptr, r=flip1995
Add a new lint `ptr_as_ptr`

This PR adds a new lint `ptr_as_ptr` which checks for `as` casts between raw pointers without changing its mutability and suggest replacing it with `pointer::cast`. Closes #5890.

Open question: should this lint be `pedantic` or `style`? I set it `pedantic` for now because the original post suggests using it, but I think the lint also fits well to `style`.

---

changelog: New lint `ptr_as_ptr`
2021-01-05 09:54:34 +00:00
bors
311186b9bb Auto merge of #6513 - nahuakang:fix/empty_enum_lint_never_type, r=flip1995
Fix: Empty enum never type suggested only if the feature is enabled

This PR addresses [Issue 6422](https://github.com/rust-lang/rust-clippy/issues/6422). Instead of always recommending `never type` for empty enums, Clippy would only recommend [the lint](https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum) if [LatePass.TyCtxt](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html) has `features().never_type` enabled.

- \[ ] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`
---

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: Only trigger [`empty_enum`] lint if `never_type` feature is enabled.
2021-01-05 09:37:19 +00:00
bors
dd52066f74 Auto merge of #6547 - camsteffen:curse-outdated, r=phansch
Curse outdated test output

changelog: internal

Change `cargo dev bless` to only include test output that was generated since the last build of clippy. This is especially useful when running tests with `TESTNAME=...`. The feature may be disabled by `cargo dev bless --ignore-timestamp`.
2021-01-05 08:00:50 +00:00
rail
dfa5d7e818 Fix the MSRV and add the tests for MSRV 2021-01-05 10:21:55 +13:00
rail
4b478a5731 Add a new lint ptr_as_ptr,
which checks for `as` casts between raw pointers
without changing its mutability
and suggest replacing it with `pointer::cast`.
2021-01-05 10:19:03 +13:00
bors
976850b69b Auto merge of #6538 - Jarcho:vec_init_then_push, r=llogiq
New lint: vec_init_then_push

fixes: #1483

This will trigger on `new`, `default`, and `with_capacity` when the given capacity is less than or equal to the number of push calls. Is there anything else this should trigger on?

changelog: Added lint: `vec_init_then_push`
2021-01-04 20:42:18 +00:00
nahuakang
a8d47b4b78 Run cargo dev fmt 2021-01-04 18:41:42 +01:00
nahuakang
bc97f5d215 Address flip1995's review comments 2021-01-04 18:34:05 +01:00
bors
445eb99f55 Auto merge of #6548 - camsteffen:bless-internal, r=flip1995
Add ui-internal to cargo dev bless

changelog: internal
2021-01-04 15:17:58 +00:00
Cameron Steffen
cbbb188ea9 Bless only updated since clippy build 2021-01-04 09:08:22 -06:00
Cameron Steffen
7acfa4433f Add ui-internal to cargo dev bless 2021-01-04 08:56:46 -06:00
bors
ae9ae9713c Auto merge of #6507 - bengsparks:lint/issue6410, r=flip1995
Needless Question Mark Lint

Fixes #6410, i.e the needless question mark lint

changelog: [`needless_question_mark`] New lint
2021-01-04 14:17:24 +00:00
Benjamin Sparks
ba87acb440
Implemented needless question mark lint 2021-01-04 14:51:48 +01:00
bors
dd1929e1f2 Auto merge of #6544 - matthiaskrgr:else_if, r=flip1995
collapsible_if: split collapsible_else_if into its own lint so we can enable/disable it particularly

This splits up clippy::collapsible_if into collapsible_if for
if x {
  if y { }
}
=>
if x && y { }

and collapsible_else_if for

if x {
} else {
 if y { }
}

=>
if x {

} else if y {

}

so that we can lint for only the latter but not the first if we desire.

changelog: collapsible_if: split up linting for if x {} else { if y {} } into collapsible_else_if lint
2021-01-04 12:45:51 +00:00
Matthias Krüger
6dcec6ae86 collapsible_if: split collapsible_else_if into its own lint so we can enable/disable it particularly
This splits up clippy::collapsible_if into collapsible_if for
if x {
  if y { }
}
=>
if x && y { }

and collapsible_else_if for

if x {
} else {
 if y { }
}

=>
if x {

} else if y {

}

so that we can lint for only the latter but not the first if we desire.

changelog: collapsible_if: split up linting for if x {} else { if y {} } into collapsible_else_if lint
2021-01-04 13:34:14 +01:00
flip1995
d141cdc947
Add prioritization chapter and remove unresolved questions 2021-01-04 11:39:14 +01:00
bors
895191628d Auto merge of #6525 - phansch:fix-bless-in-subdirs, r=flip1995
Fix blessing of test output in subdirectories

The core issue was the usage of `reference_file_path.file_name()`, which
provided a non-existent path if the file to be updated was in a
subdirectory.

Instead we have to provide the whole path after 'tests/ui/' as the
'filename'. This part of the path is called `test_name` in the code now.

changelog: none
2021-01-04 09:23:01 +00:00
Jason Newcomb
7b5f54954a
Fix docs: use type inference 2021-01-03 14:04:05 -05:00
bors
a02806e00d Auto merge of #6518 - ThibsG:CopyException, r=ebroto
Ensure `Copy` exception in trait definition for `wrong_self_conventio…

Add a test case to ensure `Copy` exception is preserved also in trait definition, when passing `self` by value.

Follow up of #6316

changelog: none
2021-01-02 23:51:49 +00:00