Commit Graph

16376 Commits

Author SHA1 Message Date
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
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
bors
a45f71265c Auto merge of #10458 - samueltardieu:multithreading-lintcheck, r=llogiq
lintcheck: use multithreading unless --fix or --recursive is used

Use multithreading unless there is a reason not to.

changelog: none
2023-03-09 17:01:20 +00:00
bors
5f9873497f Auto merge of #10467 - blyxyas:underscore_typed, r=Jarcho
Add `let_with_type_underscore` lint

Fixes #10463
changelog: [`let_with_type_underscore`]: Add the lint.
2023-03-09 16:35:30 +00:00
blyxyas
ca3bf94c43
Add let_with_type_underscore lint 2023-03-09 17:18:03 +01:00
bors
ea4ebed2ed Auto merge of #10309 - c410-f3r:arith, r=giraffate
[arithmetic_side_effects] Fix #10252

Fix #10252

At least for integers, shifts are already handled by the compiler.

----

changelog: [`arithmetic_side_effects`]: No longer lints on right or left shifts with constant integers, as the compiler warns about them.
[#10309](https://github.com/rust-lang/rust-clippy/pull/10309)
<!-- changelog_checked-->
2023-03-09 13:30:11 +00:00
bors
eceedd9c8b Auto merge of #108920 - matthiaskrgr:rollup-qrr9a0u, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #108754 (Retry `pred_known_to_hold_modulo_regions` with fulfillment if ambiguous)
 - #108759 (1.41.1 supported 32-bit Apple targets)
 - #108839 (Canonicalize root var when making response from new solver)
 - #108856 (Remove DropAndReplace terminator)
 - #108882 (Tweak E0740)
 - #108898 (Set `LIBC_CHECK_CFG=1` when building Rust code in bootstrap)
 - #108911 (Improve rustdoc-gui/tester.js code a bit)
 - #108916 (Remove an unused return value in `rustc_hir_typeck`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-09 08:21:17 +00:00
Samuel Tardieu
a701af45cb lintcheck: use multithreading unless --fix or --recursive is used 2023-03-08 22:29:57 +01:00
Matthias Krüger
d9fdac52b2 Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiasko
Remove DropAndReplace terminator

#107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-08 21:26:51 +01:00
Pietro Albini
aff9b72375 move clippy tests back to their intended directory 2023-03-08 14:17:16 +01:00
bors
56fbfe56c1 Auto merge of #10448 - samueltardieu:issue-10444, r=llogiq
Add new `redundant_async_block` lint

Fixes #10444

changelog: [`redundant_async_block`]: new lint to detect `async { future.await }`
2023-03-08 10:15:29 +00:00