Commit graph

16385 commits

Author SHA1 Message Date
Samuel "Sam" Tardieu
b138bb587b Do not propose to simplify a not expression coming from a macro 2023-03-22 01:12:52 +01:00
bors
6cebe58dfe Auto merge of #10526 - samueltardieu:dogfood-clippy, r=flip1995
Really dogfood clippy

The dogfood success condition was inverted in `tests/dogfood.rs`:

```rust
  assert!(!failed_packages.is_empty(), …);
```

while instead the `failed_packages` collection must be empty:

```rust
  assert!(failed_packages.is_empty(), …);
```

And indeed, several clippy lint source files were not clean and had to be fixed in the process.

changelog: none
2023-03-21 21:04:37 +00:00
Samuel "Sam" Tardieu
728ee6f8cd Really dogfood clippy
The dogfood success condition was inverted in `tests/dogfood.rs`:

```rust
  assert!(!failed_packages.is_empty(), …);
```

while instead the `failed_packages` collection must be empty:

```rust
  assert!(failed_packages.is_empty(), …);
```

And indeed, several clippy lint source files were not clean and had to be
fixed in the process.
2023-03-21 22:00:58 +01:00
bors
7b3c4aa771 Auto merge of #10520 - Nilstrieb:uninit, r=Alexendoo
Use uninit checking from rustc

rustc has proper heuristics for actually checking whether a type allows being left uninitialized (by asking CTFE). We can now use this for our helper instead of rolling our own bad version with false positives.

I added this in rustc in rust-lang/rust#108669

Fix #10407

changelog: [`uninit_vec`]: fix false positives
changelog: [`uninit_assumed_init`]: fix false positives
2023-03-21 18:59:03 +00:00
Nilstrieb
84b6049eb9 Use uninit checking from rustc
rustc has proper heuristics for actually checking whether a type allows
being left uninitialized (by asking CTFE). We can now use this for our
helper instead of rolling our own bad version with false positives.
2023-03-21 18:28:06 +01:00
bors
0a77f4c5b1 Auto merge of #10522 - xFrednet:10521-docs-and-triage, r=Manishearth
Correct active members link in `CONTRIBUTING.md`

This corrects the link, where to find which members are currently active and can be pinged. It also adds me as the code owner of `gh-pages`. In most cases, I'm asked to review those PRs anyways :)

Otherwise, not much more to day, have a great day!

---

Closes: #10521

changelog: none
<!-- changelog_checked -->
2023-03-19 19:30:00 +00:00
xFrednet
dec6ef8a74
Correct active members link in CONTRIBUTING.md 2023-03-19 13:42:12 +01:00
bors
e64c5961dc Auto merge of #10456 - samueltardieu:issue-10450, r=Manishearth
Issue function modifiers in the right order in manual_async_fn lint

Fixes #10450

changelog: [`manual_async_fn`] output function modifiers in correct order
2023-03-18 15:19:27 +00:00
bors
d3c8442d4d Auto merge of #10483 - samueltardieu:issue-10480, r=llogiq
New lint to detect `&std::path::MAIN_SEPARATOR.to_string()`

Fixes #10480

changelog: [`manual_main_separator_str`] new lint
2023-03-17 13:49:53 +00:00
bors
5c4040e9bb Auto merge of #10502 - blyxyas:fix-almost_swapped, r=giraffate
fix `almost_swapped`: Ignore external macros

Fixes #10421 ; Related to #10499 (Fixing points *1* and *3* from #10421)
changelog: [`almost_swapped`]: Add a check to ignore external macros
2023-03-17 00:03:45 +00:00
Samuel "Sam" Tardieu
ffabdab8cf New lint to detect &std::path::MAIN_SEPARATOR.to_string() 2023-03-16 21:42:04 +01:00
blyxyas
9546517a84
Add external macro test + Now it works 2023-03-16 20:22:39 +01:00
Samuel Tardieu
afe27ba1a2 Issue function modifiers in the right order in manual_async_fn lint 2023-03-16 18:59:14 +01:00
bors
5afa93bd8e Auto merge of #10481 - blyxyas:allow_attribute, r=xFrednet
Add `allow_attribute` lint

Fixes #10468

changelog: new lint: [`allow_attributes`]
[#10481](https://github.com/rust-lang/rust-clippy/pull/10481)
2023-03-16 10:18:19 +00:00
blyxyas
1cab0cbaf0
Fix formatting, remove commented code, etc... 2023-03-16 11:10:59 +01:00
blyxyas
4b9cb857f9
Rename lint 2023-03-15 23:18:25 +01:00
blyxyas
e2ba75d69d
Add macro test 2023-03-15 16:27:46 +01:00
blyxyas
3eea49446b
Ignore external macros 2023-03-14 20:59:39 +01:00
bors
c465bf7f67 Auto merge of #10499 - blyxyas:fix-almost_swapped, r=giraffate
Fix `almost_swapped` false positive (`let mut a = b; a = a`)

Fixes `2` in #10421
changelog: [`almost_swapped`]: Fix false positive when a variable is changed to itself. (`a = a`)
2023-03-14 13:30:21 +00:00
bors
5941616ddc Auto merge of #10500 - nagisa:docs-fix, r=Alexendoo
Fix documentation for `derived_hash_with_manual_eq`

changelog: fix documentation for `derived_hash_with_manual_eq`

The documentation retained "vice versa" from the previous incarnation of the lint but the lint itself no longer lints against manual `Hash` implementations with a derived `PartialEq`.

I also adjusted the documentation for `PartialOrd`-`Ord` lint as "vice versa" seemed a little confusing to me there (as to what it was refering to exactly.)
2023-03-14 11:18:49 +00:00
Simonas Kazlauskas
5924b46543 Fix documentation for derived_hash_with_manual_eq
The documentation retained "vice versa" from the previous incarnation of
the lint but the lint itself no longer lints against manual `Hash`
implementations with a derived `PartialEq`.

I also adjusted the documentation for `PartialOrd`-`Ord` lint as "vice
versa" seemed a little confusing to me there (as to what it was refering
to exactly.)
2023-03-14 12:48:06 +02:00
bors
ff843ac9ae Auto merge of #10350 - J-ZhengLi:issue_10272, r=xFrednet
enhance [`ifs_same_cond`] to warn same immutable method calls as well

fixes: #10272

---

changelog: Enhancement: [`ifs_same_cond`]: Now also detects immutable method calls.
[#10350](https://github.com/rust-lang/rust-clippy/pull/10350)
<!-- changelog_checked -->
2023-03-14 08:16:58 +00:00
J-ZhengLi
011bb46337 update lint configuration doc for [ifs_same_cond] 2023-03-14 10:24:28 +08:00
blyxyas
6631480a7b
Fix false positive with a = a 2023-03-13 19:13:56 +01:00
bors
945e42fc11 Auto merge of #10470 - Alexendoo:match-single-binding-semicolon, r=giraffate
Fix semicolon insertion in `match_single_binding`

changelog: [`match_single_binding`]: Fix missing semicolon after the suggestion

Fixes #10447

Also fixes an edge case for unit returning macros in expression contexts:

```rust
f(match 1 {
    _ => println!("foo"),
});
```

would suggest

```rust
f(println!("foo"););
```
2023-03-13 14:35:56 +00:00
Alex Macleod
555f56862e Fix semicolon insertion in match_single_binding 2023-03-13 14:17:35 +00:00
J-ZhengLi
f4ccb06d69 extract is_interior_mutable_type from [mut_key] to clippy_utils::ty;
fix configuration of [`ifs_same_cond`];

add some style improvement for [`ifs_same_cond`];
2023-03-13 20:17:30 +08:00
J-ZhengLi
f0ae2b71ca make [ifs_same_cond] use ignore_interior_mutablility configuration 2023-03-13 20:13:56 +08:00
J-ZhengLi
8a9492aa03 enhance [ifs_same_cond] to lint same immutable method calls as well 2023-03-13 20:13:56 +08:00
bors
e65ad6f5d0 Auto merge of #10453 - Jarcho:test_utils, r=dswij
Add utility macros to help with writing tests.

Adds two utility macros to help with testing:
* `external` expands to it's argument tokens, but makes them appear to come from an external macro. Helps make tests for `in_external_macro` much more readable.
* `inline_macros` is an attribute macro which allows the use of a pseudo `inline!` macro which expands to it's argument tokens, but makes them appear to be from a crate-local macro expansion. This removes the need to write `macro_rules` boilerplate when testing how lints interact with macros.

---

`external`'s usage is simple. `external!(struct Foo { x: u32});` will make the struct appear as though it came from an external macro. Individual tokens can be escaped if needed. `external!($x + 0 / 10)` will make everything except `x` appear as though it came from an external macro. Can also use `$literal` and `$(tokens...)` as well.

---

`inline_macros` is more complicated due to compiler constraints. Given:
```rust
#[inline_macros]
fn foo() {
    inline!(5 + 5 / 10);
}
```
`inline!(5 + 5 / 10)` will be replace with a call to a generated macro which expands to the contained tokens.

Tokens can be escaped by prefixing them with `$`:
```rust
#[inline_macros]
fn foo() {
    let x = 5;
    inline!($x + 5 / $10);
}
```
This will pass `x` as an `ident` argument and `10` as a `literal` argument.

Token sequences can also be passed with `$(...)`:
```rust
#[inline_macros]
fn foo() {
    let mut x = 5;
    inline!(if $(x >= 5) {
        $x = 5;
    });
}
```
This will pass `x >= 5` as `tt` arguments, and `x` as an `ident` argument.

---

Not 100% sure `inline_macros` is actually worth having. It does make the tests a little easier to read once you're used to it and it becomes more useful once there are multiple macro tests. The verbosity of declaring single use macros starts to hurt at that point.

changelog: None
2023-03-12 21:36:47 +00:00
Jason Newcomb
1c7048d785 Add utility macros to help with writing tests. 2023-03-12 17:24:36 -04:00
blyxyas
d65c9a5700
Extend tests + improve description + general improvement 2023-03-11 21:30:34 +01:00
bors
f19db28361 Auto merge of #10434 - Jarcho:snip_context, r=dswij
Remove `snippet_with_macro_callsite`

`snippet_with_context` is used instead to support nested macro calls.

changelog: None
2023-03-11 12:45:20 +00:00
bors
e426ba4e06 Auto merge of #10420 - Jarcho:no_mangle_diag, r=dswij
Improve diagnostic of `no_mangle_with_rust_abi`

fixes #10409

Pending rust-lang/rustfmt#5701

This rewords the message to focus on the error being an implicit ABI, rather than the `Rust` ABI. Also downgrades the suggestion to `MaybeIncorrect` and changes the suggestion span to better highlight the change.

---

changelog: None
<!-- changelog_checked -->
2023-03-11 12:14:48 +00:00
blyxyas
2d572d4a9c
Replace list indexing for .get (fail-safe) 2023-03-11 13:11:27 +01:00
blyxyas
1cf72183cf
Add ignore flag to code fragments 2023-03-11 01:08:03 +01:00
blyxyas
59568962ae
Fix code fragment 2023-03-11 00:48:50 +01:00
blyxyas
0f1474ea27
Add allow_attribute lint 2023-03-11 00:30:30 +01:00
bors
8e1dd06918 Auto merge of #10479 - Jarcho:issue_10474, r=flip1995
Don't lint `manual_clamp` in const contexts.

fixes #10474

Probably worth including in the sync.
r? `@flip1995`

changelog: [`manual_clamp`]: Don't lint in const contexts.
2023-03-10 16:57:57 +00:00
Jason Newcomb
797d8bff08 Don't lint manual_clamp in const contexts. 2023-03-10 11:07:28 -05:00
bors
b0e2e7bdb4 Auto merge of #10475 - flip1995:beta-changelog, r=xFrednet
Update changelog for beta-accepted labels

Roses are red
Violets are blue
r? `@xFrednet` is better at this
I can't rhyme.

https://github.com/rust-lang/rust-clippy/pull/10423
https://github.com/rust-lang/rust-clippy/pull/10265

changelog: none
2023-03-10 11:12:30 +00:00
Philipp Krones
c34d04a3dd
Update changelog for beta-accepted labels 2023-03-10 11:28:10 +01:00
bors
3c06e0b1ce Auto merge of #10275 - Alexendoo:format-args-ast, r=flip1995
Migrate `write.rs` to `rustc_ast::FormatArgs`

changelog: none

Part 1 of #10233

The additions to `clippy_utils` are the main novelty of this PR, there's no removals yet since other parts still rely on `FormatArgsExpn`

The changes to `write.rs` itself are relatively straightforward this time around, as there's no lints in it that rely on type checking format params

r? `@flip1995`
2023-03-10 09:38:18 +00:00
bors
991610a9ec Auto merge of #10473 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-03-10 09:23:09 +00:00
Philipp Krones
f3074c4b91
Bump nightly version -> 2023-03-10 2023-03-10 10:22:33 +01:00
Philipp Krones
ec9029d12c
Bump Clippy version -> 0.1.70 2023-03-10 10:22:27 +01:00
Philipp Krones
baa997caf6
Merge remote-tracking branch 'upstream/master' into rustup 2023-03-10 10:22:18 +01:00
bors
a7fae6e417 Auto merge of #10471 - xFrednet:00000-mark-version-as-released, r=flip1995
Mark Rust 1.68.0 as release in the changelog

Roses are red,
this poem is dead,
my creativity is lost,
outside there is frost?

Maybe I should really stop including a "roses are red" with every changelog PR. These are getting worse every time...

---

changelog: none
<!-- changelog_checked -->
2023-03-10 08:46:32 +00:00
xFrednet
7ce9ca0508
Mark Rust 1.68.0 as release in the changelog 2023-03-09 23:09:51 +01:00
bors
9074da0bd7 Auto merge of #10359 - mladedav:dm/private/is-empty, r=llogiq
Include async functions in the len_without_is_empty

fixes #7232

Changes done to the functionality:

Allowing different error types for the functions was disallowed. So the following was linted before but is not after this change
```
impl Foo {
    pub len(&self) -> Result<usize, Error1> { todo!(); }
    pub is_empty(&self) -> Result<bool, Error2> { todo!(); }
}
```

---

changelog: Enhancement: [`len_without_is_empty`]: Now also detects `async` functions
[#10359](https://github.com/rust-lang/rust-clippy/pull/10359)
<!-- changelog_checked -->
2023-03-09 17:15:23 +00:00