Commit graph

6770 commits

Author SHA1 Message Date
bors
53059792e9 Auto merge of #8071 - GuillaumeGomez:method-must-use, r=xFrednet
Add new lint to warn when #[must_use] attribute should be used on a method

This lint is somewhat similar to https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate but also different: it emits a warning by default and only targets methods (so not functions nor associated functions).

Someone suggested it to me after this tweet: https://twitter.com/m_ou_se/status/1466439813230477312

I think it would reduce the number of cases of API misuses quite a lot.

What do you think?

---

changelog: Added new [`return_self_not_must_use`] lint
2021-12-08 19:09:25 +00:00
bors
3c8f90bd5a Auto merge of #8030 - WaffleLapkin:ignore_trait_assoc_types_type_complexity, r=llogiq
Ignore associated types in traits when considering type complexity

changelog: Ignore associated types in traits when checking ``[`type_complexity`]`` lint.

fixes #1013
2021-12-08 11:54:03 +00:00
Maybe Waffle
c176568abd Ignore associated items in trait *implementations* when considering type complexity 2021-12-08 14:38:59 +03:00
Guillaume Gomez
8dfb3ec8a4 Add new lint to warn when #[must_use] attribute should be used on a method 2021-12-08 11:16:14 +01:00
bors
86cea73449 Auto merge of #8086 - dswij:7991, r=giraffate
Fix bad suggestion on `option_if_let_else` when there is complex subpat

closes #7991

Prefer not warning any complex subpat in `option_if_let_else` rather than suggesting obscure suggestions.

changelog: [`option_if_let_else`] does not warn when complex subpat is present
2021-12-07 23:45:58 +00:00
Yechan Bae
5d63a28638 Move non_send_fields_in_send_ty back to nursery 2021-12-07 10:45:59 -05:00
Yechan Bae
c0fd250c62 Fix grammar issues 2021-12-07 10:08:22 -05:00
Yechan Bae
ee0d71e103 Clarify the purpose of the lint 2021-12-07 10:06:34 -05:00
dswij
b5fa5b37cc option_if_let_else Do not warn when complex subpat is present 2021-12-07 15:47:28 +08:00
bors
1c7df44e2d Auto merge of #8085 - jqnatividad:8084-needless_lifetimes_typo, r=giraffate
`needless_lifetimes` Known problems typo

fixes #8084

[needless_lifetimes]

changelog: none
2021-12-07 00:45:59 +00:00
Joel Natividad
d91b91ae57 needless_lifetimes Known problems typo
fixes #8084
2021-12-06 19:11:19 -05:00
bors
f615ea474b Auto merge of #8080 - dswij:8019, r=giraffate
Fix FP on `question_mark` if returned object is not local

Closes #8019

changelog: [`question_mark`] Fix FP when returned object is not local
2021-12-07 00:07:46 +00:00
Cameron Steffen
16bbd243f9 Simplify needless_bool 2021-12-06 12:33:02 -06:00
Cameron Steffen
f690ef6f5c Refactors with peel_blocks 2021-12-06 12:33:02 -06:00
Cameron Steffen
284b63a687 Rename remove_blocks to peel_blocks 2021-12-06 12:33:02 -06:00
bors
9e0852705e Auto merge of #8066 - rust-lang:needless_bool_parenthesize, r=camsteffen
Parenthesize blocks in `needless_bool` suggestion

Because the `if .. {}` statement already puts the condition in expression scope, contained blocks would be parsed as complete
statements, so any `&` binary expression whose left operand ended in a block would lead to a non-compiling suggestion.

We identify such expressions and add parentheses. Note that we don't make a difference between normal and unsafe blocks because the parsing problems are the same for both.

This fixes #8052.

---

changelog: none
2021-12-06 15:15:26 +00:00
Andre Bogus
4a39707795 Parenthesize blocks in needless_bool suggestion
Because the `if .. {}` statement already puts the condition in
expression scope, contained blocks would be parsed as complete
statements, so any `&` binary expression whose left operand ended in a
block would lead to a non-compiling suggestion.

This adds a visitor to identify such expressions and add parentheses.

This fixes #8052.
2021-12-06 13:15:31 +01:00
dswij
01ca66cbd7 Fix FP on question_mark if returned object is not local 2021-12-06 17:51:00 +08:00
nixx quality
01e302b2f7
Fix dogfood 2021-12-05 23:04:56 +01:00
nixx quality
e3c60444ce
fix some false negatives for single_char_pattern 2021-12-05 17:33:52 +01:00
bors
907f6d9294 Auto merge of #8074 - Qwaz:send_nonnull, r=xFrednet
Consider NonNull as a pointer type

PR 1/2 for issue #8045. Add `NonNull` as a pointer class to suppress false positives like `UnsafeCell<NonNull<()>>`. However, this change is not sufficient to handle the cases shared in gtk-rs and Rug in the issue.

changelog: none

r? `@xFrednet`
2021-12-04 17:19:07 +00:00
bors
9eabec9f07 Auto merge of #8054 - camsteffen:map-flatten-style, r=giraffate
Upgrade map_flatten to complexity

changelog: upgrade [`map_flatten`] to complexity

Resolves #7999
2021-12-04 13:30:09 +00:00
Yechan Bae
844996b42e Consider NonNull as a pointer type 2021-12-03 19:11:40 -05:00
Cameron Steffen
de9de4fef1 Upgrade map_flatten to complexity 2021-12-03 13:21:48 -06:00
xFrednet
11ad5a26a9
Add note about crate lint level attributes to pre-expansion lints 2021-12-03 19:29:57 +01:00
bors
be1a73b894 Auto merge of #8061 - vallentin:fix-same-name-method-desc, r=flip1995
Fixed same_name_method description

Noticed some odd phrasing, while checking out the new release.

changelog: none
2021-12-03 00:37:52 +00:00
frobiac
5cc451bc6c Escape backslash for singe_char_pattern.rs 2021-12-02 23:47:23 +01:00
bors
d5d830a50f Auto merge of #7463 - ThibsG:find_any_7392, r=xFrednet
Fix `any()` not taking reference in `search_is_some` lint

`find` gives reference to the item, but `any` does not, so suggestion is broken in some specific cases.

Fixes: #7392

changelog: [`search_is_some`] Fix suggestion for `any()` not taking item by reference
2021-12-02 17:27:54 +00:00
vallentin
f26821c969
Fixed same_name_method description 2021-12-02 18:25:09 +01:00
flip1995
ec57cc1455
Bump Clippy Version -> 0.1.59 2021-12-02 09:32:47 +00:00
flip1995
abddd6c491
Merge remote-tracking branch 'upstream/master' into rustup 2021-12-02 09:32:09 +00:00
bors
908815ce98 Auto merge of #8001 - Jarcho:unprefixed_strlen, r=giraffate
Improve `strlen_on_c_string`

fixes: #7436

changelog: lint `strlen_on_c_string` when used without a fully-qualified path
changelog: suggest removing the surrounding unsafe block for `strlen_on_c_string` when possible
2021-11-29 01:03:48 +00:00
bors
4e84dd121f Auto merge of #8006 - togami2864:generalize-copied, r=camsteffen
apply iter_cloned_collect to collect() using copied()

fix: #6703

changelog: apply `iter_cloned_collect` to `collect()` using`copied()`
2021-11-28 20:59:20 +00:00
Camille GILLOT
56533d9e87 Take a LocalDefId in expect_*item. 2021-11-28 21:09:45 +01:00
togami2864
f51bbc7db9 apply iter_cloned_collect to copied() 2021-11-28 23:59:31 +09:00
bors
3720735f9a Auto merge of #7995 - Alexendoo:needless_late_init, r=giraffate
Add `needless_late_init` lint

examples:

```rust
let a;
a = 1;
// to
let a = 1;
```
```rust
let b;
match 3 {
    0 => b = "zero",
    1 => b = "one",
    _ => b = "many",
}
// to
let b = match 3 {
    0 => "zero",
    1 => "one",
    _ => "many",
};
```
```rust
let c;
if true {
    c = 1;
} else {
    c = -1;
}
// to
let c = if true {
    1
} else {
    -1
};
```

changelog: Add [`needless_late_init`]
2021-11-27 14:24:02 +00:00
Alex Macleod
d346ec94fe Add async/const fn tests for needless-late-init
+nits
2021-11-26 14:27:53 +00:00
togami2864
cd8b72443d fix small nit 2021-11-26 19:27:14 +09:00
togami2864
e6a6ed44b2 fix doc 2021-11-26 18:52:27 +09:00
togami2864
e8ef6ca5e3 fix stderr 2021-11-26 18:49:14 +09:00
togami2864
a745cc55f3 make non_ascii_literal to catch char 2021-11-26 18:42:41 +09:00
Maybe Waffle
063f8aa094 Ignore associated types in traits when considering type complexity 2021-11-25 12:08:18 +03:00
Dharma Saputra Wijaya
c0bad8bcab Add more descriptive help info for needless_question_mark 2021-11-25 14:01:14 +08:00
Alex Macleod
3957244120 Add needless_late_init lint 2021-11-23 15:08:49 +00:00
flip1995
5740230ec7
Merge remote-tracking branch 'upstream/master' into rustup 2021-11-23 11:22:34 +01:00
dswij
ec3d1c8ca3 Fix FP on if_then_some_else_none when there is early return 2021-11-23 10:11:30 +08:00
bors
57a8804ef9 Auto merge of #8007 - birkenfeld:octal_escapes, r=xFrednet
Add new lint `octal_escapes`

This checks for sequences in strings that would be octal character
escapes in C, but are not supported in Rust.  It suggests either
to use the `\x00` escape, or an equivalent hex escape if the octal
was intended.

Fixes #7981

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: Add new lint [`octal_escapes`], which checks for literals like `"\033[0m"`.
2021-11-22 20:29:53 +00:00
Georg Brandl
1210bb40d3 octal_escapes: note on print!() format strings 2021-11-22 21:02:03 +01:00
Georg Brandl
0bc25d04c6 octal_escapes: emit only one lint for all cases found each literal 2021-11-22 21:00:19 +01:00
Georg Brandl
850e7f533e octal_escapes: updates from review, fix byte string prefix 2021-11-22 18:02:17 +01:00