Commit graph

15657 commits

Author SHA1 Message Date
Jason Newcomb
c1b8bc66e9 Fix ICE in unused_rounding 2022-11-30 12:46:06 -05:00
bors
78589ffad2 Auto merge of #9989 - xFrednet:9986-move-safety-thingy, r=flip1995
Move `unnecessary_unsafety_doc` to `pedantic`

This lint was added in #9822. I like the idea, but also agree with #9986 as well. I think it should at least not be warn-by-default. This is one of these cases, where I'd like a group between pedantic and restriction. But I believe that users using `#![warn(clippy::pedantic)]` will know how to enable the lint if they disagree with it.

---

Since the lint is new:

changelog: none

r? `@flip1995` since I'd suggest back porting this, the original PR was merged 16 days ago.

Closes: #9986 (While it doesn't address everything, I believe that this is the best compromise)
2022-11-30 12:44:45 +00:00
xFrednet
cc43c3d25d
Move unnecessary_unsafety_doc to pedantic 2022-11-30 12:59:50 +01:00
bors
3cf2c17e53 Auto merge of #9985 - ehuss:triagebot-autolabel, r=xFrednet
Add S-waiting-on-review autolabel.

This adds the S-waiting-on-review autolabel feature for new PRs.  This was previously handled by highfive, but I neglected to include it in #9963.

changelog: none
2022-11-29 13:30:15 +00:00
Eric Huss
8759f33bb3 Add S-waiting-on-review autolabel. 2022-11-29 05:18:43 -08:00
bors
bfb973f1c7 Auto merge of #9975 - xFrednet:0000-refutable-slice-pedantic, r=llogiq
Move `index_refutable_slice` to `pedantic`

During the creation, I out this lint into the nursery group to let it run in the wild before moving it to a commonly used group. This move never happened until now, though. It should be safe, as Clippy and I have been using it for months and there are no open issues for is :)

---

changelog: Move `index_refutable_slice` to `pedantic` (Now warn-by-default)
[#9975](https://github.com/rust-lang/rust-clippy/pull/9975)
2022-11-29 11:16:01 +00:00
bors
4cda21dc42 Auto merge of #9981 - Jarcho:issue_9954, r=flip1995
Don't lint `unnecessary_operation` in mixed macro contexts

fixes #9954

changelog: `unnecessary_operation`: Don't lint in mixed macro contexts.
2022-11-29 09:49:46 +00:00
bors
e9a8b8c2f3 Auto merge of #9980 - Jarcho:issue_9960, r=xFrednet
Don't lint `unnecessary_cast` in mixed macro context

fixes #9960

Time to start making a dent in this onslaught.

changelog: `unnecessary_cast`: Don't lint when the identifiers context differs from its binding's context for locals
2022-11-29 09:10:14 +00:00
Jason Newcomb
f44b7aa81e Don't lint unnecessary_cast in mixed macro context 2022-11-28 23:58:02 -05:00
Jason Newcomb
0893322e54 Don't lint unnecessary_operation in mixed macro contexts 2022-11-28 23:56:02 -05:00
xFrednet
6bbf16660b
Move index_refutable_slice to pedantic 2022-11-28 20:23:09 +01:00
bors
12074808c7 Auto merge of #9865 - nyurik:allow-mixed, r=xFrednet
Add allow-mixed-uninlined-format-args config

Implement `allow-mixed-uninlined-format-args` config param to change the behavior of the `uninlined_format_args` lint. Now it is a part of `style` per [Zulip chat](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/.60uninlined_format_args.60.20category), and won't propose inlining in case of a mixed usage, e.g. `print!("{} {}", var, 1+2)`. If the user sets `allow-mixed-uninlined-format-args` config param to `false`, the lint would behave like it did before -- proposing to inline args even in the mixed case.

---

changelog: [`uninlined_format_args`]: Added a new config `allow-mixed-uninlined-format-args` to allow the lint, if only some arguments can be inlined
[#9865](https://github.com/rust-lang/rust-clippy/pull/9865)
changelog: Moved [`uninlined_format_args`] to `style` (Now warn-by-default)
[#9865](https://github.com/rust-lang/rust-clippy/pull/9865)
2022-11-28 17:22:36 +00:00
bors
c8eba8e4a1 Auto merge of #9967 - koka831:fix/9416, r=llogiq
Remove blank lines when needless_return returns no value

fix https://github.com/rust-lang/rust-clippy/issues/9416

changelog: [`needless_return`] improve result format

r? `@llogiq`
2022-11-27 19:03:06 +00:00
bors
ef8439780c Auto merge of #9963 - ehuss:highfive-triagebot, r=xFrednet
Migrate from highfive to triagebot

This migrates this repository from using the highfive bot to using triagebot (aka rustbot).

This should not be merged without coordinating the removal of the highfive webhook and/or merging https://github.com/rust-lang/highfive/pull/435.

changelog: none
2022-11-27 16:20:05 +00:00
Yuri Astrakhan
ab576afc18 addressed review feedback 2022-11-27 10:34:13 -05:00
Eric Huss
13dfbb2fa5 Migrate from highfive to triagebot 2022-11-27 07:24:46 -08:00
Yuri Astrakhan
7a2d92e1f2 Add allow-mixed-uninlined-format-args config
Implement `allow-mixed-uninlined-format-args` config param to change the behavior of the `uninlined_format_args` lint. Now it is a part of `style`, and won't propose inlining in case of a mixed usage, e.g. `print!("{} {}", var, 1+2)`. If the user sets allow-mixed-uninlined-format-args config param to `false`, then it would behave like before, proposing to inline args even in the mixed case.
2022-11-27 10:12:51 -05:00
bors
c55cadcfd9 Auto merge of #9919 - Alexendoo:configuration-link, r=xFrednet
Link to a list of configurable lints in documentation

changelog: none
2022-11-27 14:42:54 +00:00
koka
39d0477080
Refactor BytePos handling 2022-11-27 22:41:06 +09:00
koka
8c50dfb546
Remove blank lines when needless_return returns no value
fix https://github.com/rust-lang/rust-clippy/issues/9416
2022-11-27 22:01:21 +09:00
bors
ef99041f65 Auto merge of #9860 - Alexendoo:msrv-outer-attr, r=Jarcho
Allow using `clippy::msrv` as an outer attribute

changelog: Allow specifying `#[clippy::msrv]` as an outer attribute

Probably not too useful to clippy users, but it makes the MSRV tests slightly cleaner
2022-11-27 12:58:54 +00:00
Alex Macleod
461e219d1d Allow using clippy::msrv as an outer attribute 2022-11-27 12:43:17 +00:00
Alex Macleod
28976ce9c3 Link to a list of configurable lints in documentation 2022-11-27 12:38:33 +00:00
bors
030b4b7ad9 Auto merge of #9950 - xFrednet:0000-improve-exit-docs, r=llogiq
Improve `EXIT` lint docs

Super simple change, hopefully fast and fun to review. Have a great start to the weekend!

changelog: none
2022-11-27 08:47:20 +00:00
xFrednet
459621d31b
Improve EXIT lint docs 2022-11-26 11:55:25 +01:00
bors
6d0b4e3a09 Auto merge of #9945 - kraktus:uninlined_multiple_lines, r=llogiq
Re-enable `uninlined_format_args` on multiline `format!`

fix https://github.com/rust-lang/rust-clippy/issues/9719

There was an issue with the code suggestion which can be sometimes completely broken (fortunately when applied it's valid), so we do not show it.

changelog: [`uninlined_format_args`] re-enable for multiline format expression, but do not show the literal code suggestion in those cases
2022-11-25 18:36:50 +00:00
bors
08a80d3a8b Auto merge of #9944 - flip1995:move-syntax-tree-patterns, r=Manishearth
Move syntax tree patterns RFC to the book

r? `@Manishearth`

Follow up to #3875

changelog: none
2022-11-25 15:59:47 +00:00
kraktus
2fd10bc59b dogfood with expanded uninlined_format_args 2022-11-25 16:49:05 +01:00
kraktus
5610d22c8d Re-enable uninlined_format_args on multiline format!
But do not display the code suggestion which can be sometimes completely broken (fortunately when applied it's valid)
2022-11-25 16:36:22 +01:00
bors
efadb55733 Auto merge of #9851 - Veykril:unnecessary-safety-comment, r=giraffate
Lint unnecessary safety comments

changelog: [`unnecessary_safety_comment`]: Add unnecessary safety comment lint

Addresses https://github.com/rust-lang/rust-clippy/issues/7954

This does not necessarily catch all occurences, as doing so would require checking all expressions in the entire source which seems rather expensive. Instead what the lint does is it checks items, statements and the tail expression of blocks for safety comments, then checks if those comments are necessary or not, then linting for the unnecessary ones.

I kept the tests in one file to check that the lints do not clash with each other.
2022-11-25 12:55:24 +00:00
Philipp Krones
c6a1184e4d
Book: Format syntax tree pattern proposal 2022-11-25 11:39:36 +01:00
Philipp Krones
4faf11a102
Move syntax tree patterns RFC to the book 2022-11-25 11:39:04 +01:00
Lukas Wirth
f96dd38318 Address reviews 2022-11-25 10:09:35 +01:00
Lukas Wirth
9c69e1cc89 Simplify 2022-11-25 10:09:35 +01:00
Lukas Wirth
4fa5757530 Lint unnecessary safety comments on statements and block tail expressions 2022-11-25 10:09:34 +01:00
Lukas Wirth
b8c3f64cee Add some more test cases for undocumented_unsafe_blocks 2022-11-25 10:09:34 +01:00
Lukas Wirth
a116b9bdba Lint unnecessary safety comments on items 2022-11-25 10:09:34 +01:00
bors
1a9657139d Auto merge of #9941 - Alexendoo:syntax-tree-rfc-remark, r=Manishearth
Fix remark for `rfcs/0001-syntax-tree-patterns.md`

https://github.com/rust-lang/rust-clippy/actions/runs/3542472739/jobs/5948006255#step:6:37

Removes the unused definitions, for the line length I disabled the lint for now as I gather it's going to be moved into the book in the future

r? `@Manishearth`

changelog: none
2022-11-24 23:46:59 +00:00
Alex Macleod
4d0fb08921 Fix remark for rfcs/0001-syntax-tree-patterns.md 2022-11-24 21:56:54 +00:00
Manish Goregaokar
be172c52f7
Merge pull request #3875 from fkohlgrueber/syntax-tree-patterns
RFC: syntax tree patterns
2022-11-23 17:24:17 -05:00
bors
69c5128cda Auto merge of #9924 - Alexendoo:msrv-stack, r=Jarcho
Add `clippy_utils::msrv::Msrv` to keep track of the current MSRV

changelog: Fix the scoping of the `#![clippy::msrv]` attribute

Fixes #6920

r? `@Jarcho`
2022-11-22 20:09:58 +00:00
bors
f6f6d542d5 Auto merge of #9930 - smoelius:use-walk_generic_arg, r=Alexendoo
Use `walk_generic_arg`

This is a tiny followup to to #9743, now that https://github.com/rust-lang/rust/pull/103692 has landed.

r? `@Alexendoo`

changelog: none
2022-11-22 19:07:05 +00:00
Samuel Moelius
2cda73f617 Use walk_generic_arg 2022-11-22 13:47:38 -05:00
bors
5595d7f5d5 Auto merge of #9750 - kraktus:lazy_eval, r=xFrednet
Fix [`unnecessary_lazy_eval`] when type has significant drop

fix for https://github.com/rust-lang/rust-clippy/issues/9427#issuecomment-1295742590

However current implementation gives too many false positive, rending the lint almost useless.

I don't know what's the best way to check if a type has a "significant" drop (in the common meaning, not the internal rustc one, for example Option<(u8, u8)> should not be considered significant)

changelog: Fix [`unnecessary_lazy_eval`] when type has significant drop
2022-11-22 17:21:23 +00:00
bors
94ce4465e5 Auto merge of #9796 - smoelius:issue-9771, r=flip1995
Fix #9771 (`unnecessary_to_owned` false positive)

Fixes #9771

In that issue's example(s), the lint tried to add a `&` to a value, which implicitly changed the type of a field to a reference. The fix is to add the reference to `receiver_ty` (the type of the receiver of the `to_owned`-like method), before passing `receiver_ty` to `can_change_type`. `can_change_type` properly rejects the modified `receiver_ty`.

cc: `@mikerite` just because I think he was the author of `can_change_type`.

changelog: fix `unnecessary_to_owned` false positive which implicitly tried to change the type of a field to a reference
2022-11-22 12:50:08 +00:00
bors
f4083c5ae7 Auto merge of #9745 - matttpt:fix-redundant-closure-for-method-calls-suggestion, r=flip1995
Fix `redundant_closure_for_method_calls` suggestion

Fixes #7746. The issue turns out to be more general than raw pointers. The `redundant_closure_for_method_calls` lint produces incorrect suggestions when the method is associated with a type that must be enclosed in angle brackets or must be written with generic arguments substituted. For example:

```rust
fn main() {
    // Clippy's suggestion: [T; N]::as_slice
    // Correct suggestion:  <[u8; 3]>::as_slice
    let array_opt: Option<&[u8; 3]> = Some(&[4, 8, 7]);
    array_opt.map(|a| a.as_slice());

    // Clippy's suggestion: [T]::len
    // Correct suggestion:  <[u8]>::len
    let slice_opt: Option<&[u8]> = Some(b"slice");
    slice_opt.map(|s| s.len());

    // Clippy's suggestion: *const T::is_null
    // Correct suggestion:  <*const usize>::is_null
    let ptr_opt: Option<*const usize> = Some(&487);
    ptr_opt.map(|p| p.is_null());

    // Clippy's suggestion: dyn TestTrait::method_on_dyn
    // Correct suggestion:  <dyn TestTrait>::method_on_dyn
    let test_struct = TestStruct {};
    let dyn_opt: Option<&dyn TestTrait> = Some(&test_struct);
    dyn_opt.map(|d| d.method_on_dyn());
}

// For the trait object example:
trait TestTrait {}
struct TestStruct {}
impl TestTrait for TestStruct {}

impl dyn TestTrait + '_ {
    fn method_on_dyn(&self) -> bool {
        false
    }
}
```

The issue also affects references and tuples, though I had to patch the standard library with non-trait methods for those types to test that. Just in case, I also included handling for `!`, since it appeared to be possible to call methods on it with angle brackets. I just couldn't verify the resulting suggestion, since dead-code analysis eliminates the code first.

This is my first exposure to Rust compiler internals, so please let me know if I'm taking the wrong approach here!

changelog: [`redundant_closure_for_method_calls`]: add angle brackets and substitute generic arguments in suggestion when needed
2022-11-22 09:20:50 +00:00
bors
73efce9ee6 Auto merge of #9770 - sgued:missnamed-getters, r=llogiq
Add new lint  [`misnamed-getters`]

```
changelog: Add new lint  [`misnamed-getters`]
```

Closes #9769

The current lint matches all methods with a body of just one expression under the form `(&mut?)? <expr>.field` where field doesn't match the name of the method but there is a field of the same type in `<expr>` that matches the name. This allows matching nested structs, for example for newtype wrappers. This may cast the net a bit too wide and cause false positives. I'll run [clippy_lint_tester](https://github.com/mikerite/clippy_lint_tester) on the top crates to see how frequently false positives happen.

There also may be room for improvement by checking that the replacement field would work taking into account implementations of `Deref` and `DerefMut` even if the types don't exactly match but I don't know yet how this could be done.
2022-11-21 19:51:42 +00:00
bors
f4850f7292 Auto merge of #9881 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

It took >4 weeks, but I finally got to do the sync 🎉

changelog: none
2022-11-21 19:16:14 +00:00
Philipp Krones
05b914a92b
Fix custom ICE message test on windows 2022-11-21 20:15:50 +01:00
ozkanonur
5907e9155e
pass clippy sysroot env if given r=ozkanonur
Signed-off-by: ozkanonur <work@onurozkan.dev>
2022-11-21 20:02:20 +01:00