Commit Graph

18545 Commits

Author SHA1 Message Date
bors
1839b79e51 Auto merge of #11956 - intgr:doc_markdown-include-function-parenthesis, r=Alexendoo
[`doc_markdown`] Recognize words followed by empty parentheses `()` for quoting

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

changelog: [`doc_markdown`] Recognize words followed by empty parentheses for quoting, e.g. `func()`.

---

Developers often write function/method names with trailing `()`, but `doc_markdown` lint did not consider that.

Old clippy suggestion was not very good:

```patch
-/// There is no try (do() or do_not()).
+/// There is no try (do() or `do_not`()).
```

New behavior recognizes function names such as `do()` even they contain no `_`/`::`; and backticks are suggested outside of the `()`:

```patch
-/// There is no try (do() or do_not()).
+/// There is no try (`do()` or `do_not()`).
```
2023-12-13 17:53:59 +00:00
Marti Raudsepp
1f2ca8127c [doc_markdown] Recognize words followed by empty parenthesis () for quoting 2023-12-13 01:16:12 +02:00
bors
c19508b356 Auto merge of #11895 - ericwu2003:useless_vec-FP, r=blyxyas
Useless vec false positive

changelog: [`useless_vec`]: fix false positive in macros.

fixes #11861

We delay the emission of `useless_vec` lints to the check_crate_post stage, which allows us to effectively undo lints if we find that a `vec![]` expression is being used multiple times after macro expansion.
2023-12-12 22:57:24 +00:00
bors
2e96c74dce Auto merge of #11829 - J-ZhengLi:issue11438, r=matthiaskrgr
new lint to detect infinite loop

closes: #11438

changelog: add new lint to detect infinite loop

~*I'll change the lint name*~. Should I name it  `infinite_loop` or `infinite_loops` is fine? Ahhhh, English is hard...
2023-12-12 17:53:51 +00:00
Eric
884bec3d85 emit lints in check_crate_post for useless_vec
this fixes issue #11861 by adding an extra map to
keep track of which spans are ok to lint
2023-12-12 08:47:22 -08:00
bors
52deee2592 Auto merge of #11902 - GuillaumeGomez:write-and-append, r=llogiq
Add `ineffective_open_options` lint

Fixes https://github.com/rust-lang/rust-clippy/issues/9628.

For `OpenOptions`, in case you call both `write(true)` and `append(true)` on `OpenOptions`, then `write(true)` is actually useless since `append(true)` does it.

r? `@flip1995`

changelog: Add `ineffective_open_options` lint
2023-12-12 14:02:57 +00:00
Guillaume Gomez
ded94ecf65 Update CHANGELOG to add write_and_append lint 2023-12-12 14:56:35 +01:00
Guillaume Gomez
5accd517ee Add ui test for write_and_append lint 2023-12-12 14:56:35 +01:00
Guillaume Gomez
19f5b85330 Add write_and_append lint 2023-12-12 14:56:34 +01:00
bors
2a1645d009 Auto merge of #11878 - samueltardieu:uninhabited_reference, r=flip1995
uninhabited_reference: new lint

Close #11851

The lint is implemented on function parameters and return types, as this is the place where the risk of exchanging references to uninhabited types is the highest. Other constructs, such as in a local variable,
would require the use of `unsafe` and will clearly be done on purpose.

changelog: [`uninhabited_reference`]: new lint
2023-12-11 09:28:54 +00:00
bors
3813a7b27e Auto merge of #11538 - Jarcho:proc_mac, r=dswij
Fix `is_from_proc_macro` patterns

fixes #11533

changelog: none
2023-12-11 07:49:53 +00:00
Jason Newcomb
f3f2f17478 Delay several is_from_proc_macro checks 2023-12-10 15:36:35 -05:00
Jason Newcomb
184845fb0c Fix is_from_proc_macro patterns 2023-12-10 15:36:31 -05:00
bors
252103b522 Auto merge of #11949 - blyxyas:on-vacation, r=Jarcho
Add `blyxyas` to `users_on_vacation`

I have a surgery this Wednesday, so I won't be able to review anything from that day up to (at least) Dec. 22, I'll open another PR by then.

I'm not sure if `users_on_vacation` will work here, if it doesn't work, I'll just remove myself from the reviewer rotation

changelog:none
2023-12-10 19:35:33 +00:00
blyxyas
d347d6f3ba
Add blyxyas to users_on_vacation 2023-12-10 18:48:22 +01:00
bors
87aed038da Auto merge of #11944 - workingjubilee:env-lookup-for-cargo, r=Jarcho
Check $CARGO before $PATH

Currently, clippy will ignore $CARGO when spawning cargo commands, which can be problematic for `cargo clippy` and interop with other tools. This commit induces clippy to respect $CARGO in every case it seems likely to matter.

Fixes:
- #11943

changelog: clippy now respects setting the `CARGO` environment variable
2023-12-10 00:51:09 +00:00
Jubilee Young
9083b52122 Check $CARGO before $PATH 2023-12-09 14:08:03 -08:00
Samuel Tardieu
cdfa38a9d1 new lint: uninhabited_reference 2023-12-08 17:21:30 +01:00
bors
1c8cbe79ab Auto merge of #11907 - cocodery:issue11885, r=y21,xFrednet
Add a function to check whether binary oprands are nontrivial

fixes [#issue11885](https://github.com/rust-lang/rust-clippy/issues/11885)

It's hard to check whether operator is overrided through context of lint.
So, assume non-trivial structure like tuple, array or sturt, using a overrided binary operator in this lint, which might cause a side effict.
This is not detected before.
Althrough this might weaken the ability of this lint, it may more useful than before. Maybe this lint will cause an error, but now, it not. And assuming side effect of non-trivial structure with operator  is not a bad thing, right?

changelog: Fix: [`no_effect`] check if binary operands are nontrivial
2023-12-08 13:39:47 +00:00
cocodery
56d20c2b53 Fix nits and add test for unnecessary_operation 2023-12-08 21:33:28 +08:00
bors
2793e8d103 Auto merge of #11913 - KisaragiEffective:fix/ptr-as-ptr-with-null, r=llogiq
fix(ptr_as_ptr): handle `std::ptr::null{_mut}`

close rust-lang#11066
close rust-lang#11665
close rust-lang#11911

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

changelog: [`ptr_as_ptr`]: handle `std::ptr::null` and `std::ptr::null_mut`
2023-12-06 13:53:07 +00:00
cocodery
ee2354badf Add check for unary-operator
Fix typo and add test for unary-opeator
2023-12-06 12:17:48 +08:00
bors
4a56563154 Auto merge of #11900 - Enselic:needless-borrow-drop, r=Manishearth
needless_borrows_for_generic_args: Handle when field operand impl Drop

Before this fix, the lint had a false positive, namely when a reference was taken to a field when the field operand implements a custom Drop. The compiler will refuse to partially move a type that implements Drop, because that would put the type in a weird state.

## False Positive Example (Fixed)

```rs
struct CustomDrop(String);

impl Drop for CustomDrop {
    fn drop(&mut self) {}
}

fn check_str<P: AsRef<str>>(_to: P) {}

fn test() {
    let owner = CustomDrop(String::default());
    check_str(&owner.0); // Don't lint. `owner` can't be partially moved because it impl Drop
}
```

changelog: [`needless_borrows_for_generic_args`]: Handle when field operand impl Drop
2023-12-05 19:10:09 +00:00
bors
42b017d625 Auto merge of #11920 - KisaragiEffective:patch-2, r=xFrednet
docs(explicit_write): add missing backtick to complete code snippet

close #11918

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

changelog: [`explicit_write`]: add missing backtick to document to complete code snippet
2023-12-05 18:45:35 +00:00
bors
8fc8aa98d6 Auto merge of #11904 - pgerber:regex, r=xFrednet
Update regex-syntax to support new word boundry assertions

From the regex v1.10.0 release notes [1]:

    This is a new minor release of regex that adds support for start
    and end word boundary assertions. [...]

    The new word boundary assertions are:

        • \< or \b{start}: a Unicode start-of-word boundary (\W|\A
          on the left, \w on the right).
        • \> or \b{end}: a Unicode end-of-word boundary (\w on the
          left, \W|\z on the right)).
        • \b{start-half}: half of a Unicode start-of-word boundary
          (\W|\A on the left).
        • \b{end-half}: half of a Unicode end-of-word boundary
          (\W|\z on the right).

[1]: https://github.com/rust-lang/regex/blob/master/CHANGELOG.md#1100-2023-10-09

changelog: [`regex`]: add support for start and end word boundary assertions ("\<", "\b{start}", etc.) introduced in regex v0.10
2023-12-05 18:34:58 +00:00
bors
8851621498 Auto merge of #11929 - flip1995:rustup, r=flip1995
Rustup

r? `@xFrednet`

changelog: none

out of cycle sync to fix integration test failure for the XFAIL integration test, as the `delayed_span_bug` attribute name was updated.
2023-12-05 18:16:52 +00:00
Philipp Krones
a7acfa263a
Run sanity check for integration tests first
If that test fails, running all other tests doesn't make sense. This test only
takes a few seconds to run. So running it right away will make the pipeline
fail faster.
2023-12-05 17:35:51 +01:00
Philipp Krones
9c3492c092
Bump nightly version -> 2023-12-05 2023-12-05 17:29:36 +01:00
Philipp Krones
ebb0ff6932
Merge remote-tracking branch 'upstream/master' into rustup 2023-12-05 17:29:25 +01:00
cocodery
2e3c031528 Rename has_nontrivial_oprand to is_operator_overrided
Simpfy code of `is_operator_overrided`, directly use `is_method_call` to
check
if operator is overrided, at least one oprand of binary-expr must be ADT-type
So no need to check type of lhs and rhs
2023-12-05 09:29:20 +08:00
cocodery
89774234be Rewrite logic of has_nontrivial_oprand.
Check whether operator is overrided with a `struct` operand.
The struct here refers to `struct`, `enum`, `union`.
Add and fix test for `no_effect` lint.
2023-12-04 15:57:27 +08:00
Kisaragi
a3ce379adc
docs(explicit_write): add missing backtick to complete code snippet 2023-12-04 08:03:39 +09:00
Kisaragi Marine
8eea8b1577
fix: handle std::ptr::null{_mut}
close rust-lang#11066
close rust-lang#11665
close rust-lang#11911
2023-12-03 10:38:46 +09:00
Peter Gerber
af1b58fa39
Update regex-syntax to support new word boundry assertions
From the regex v1.10.0 release notes [1]:

    This is a new minor release of regex that adds support for start
    and end word boundary assertions. [...]

    The new word boundary assertions are:

        • \< or \b{start}: a Unicode start-of-word boundary (\W|\A
          on the left, \w on the right).
        • \> or \b{end}: a Unicode end-of-word boundary (\w on the
          left, \W|\z on the right)).
        • \b{start-half}: half of a Unicode start-of-word boundary
          (\W|\A on the left).
        • \b{end-half}: half of a Unicode end-of-word boundary
          (\W|\z on the right).

[1]: https://github.com/rust-lang/regex/blob/master/CHANGELOG.md#1100-2023-10-09
2023-12-02 19:44:36 +00:00
cocodery
6d40b105ed Add a function to check whether binary oprands are nontrivial
It's hard to check whether oprator is overrided through context of lint
So assume nontrivial has overrided binary operator
2023-12-03 00:58:47 +08:00
bors
da27c979e2 Auto merge of #11905 - pgerber:tests, r=dswij
Tolerate hidden, binary files in tests/

Avoid scanning temporary files created by editors like this one created by Vim:

---- old_test_headers stdout ----
thread 'old_test_headers' panicked at tests/headers.rs:19:74: tests/ui/.regex.rs.swp: stream did not contain valid UTF-8 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

changelog: none
2023-12-02 16:07:07 +00:00
bors
31aa0b2bbe Auto merge of #11899 - samueltardieu:redundant-if, r=llogiq
Do not check twice whether `qpath` is a `QPath::TypeRelative` variant

This is a style fix: the outer `if` check was useless.

changelog: none
2023-12-02 14:33:24 +00:00
bors
75bdbfcea5 Auto merge of #11853 - J-ZhengLi:issue11814, r=llogiq
expending lint [`blocks_in_if_conditions`] to check match expr as well

closes: #11814

changelog: rename lint `blocks_in_if_conditions` to [`blocks_in_conditions`] and expand it to check blocks in match scrutinees
2023-12-02 14:03:46 +00:00
Peter Gerber
1e67f6c0fb Tolerate hidden, binary files in tests/
Avoid scanning temporary files created by editors like
this one created by Vim:

---- old_test_headers stdout ----
thread 'old_test_headers' panicked at tests/headers.rs:19:74:
tests/ui/.regex.rs.swp: stream did not contain valid UTF-8
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2023-12-02 13:32:21 +00:00
bors
c586717cfb Auto merge of #118507 - flip1995:clippy-subtree-sync, r=matthiaskrgr
Clippy subtree sync

r? `@Manishearth`
2023-12-02 11:41:55 +00:00
bors
30f8e871a3 Auto merge of #118470 - nnethercote:cleanup-error-handlers, r=compiler-errors
Cleanup error handlers

Mostly by making function naming more consistent. More to do after this, but this is enough for one PR.

r? compiler-errors
2023-12-02 02:48:34 +00:00
Nicholas Nethercote
8dab7387f2 Rename HandlerInner::delay_span_bug as HandlerInner::span_delayed_bug.
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug`
follows the pattern used everywhere else: `span_err`, `span_warning`,
etc.
2023-12-02 09:01:19 +11:00
Nicholas Nethercote
dc702e358d Rename *note_without_error as *note.
Because the variant name in `Level` is `Note`, and the `without_error`
suffix is omitted in similar cases like `struct_allow` and
`struct_help`.
2023-12-02 08:58:25 +11:00
bors
ee8376075d Auto merge of #11837 - y21:issue11835, r=dswij
[`missing_asserts_for_indexing`]: accept length equality checks

Fixes #11835

The lint now allows indexing with indices 0 and 1 when an `assert!(x.len() == 2);` is found.
(Also fixed a typo in the doc example)

changelog: [`missing_asserts_for_indexing`]: accept len equality checks as a valid assertion
2023-12-01 19:02:59 +00:00
bors
5ac76ac54f Auto merge of #11597 - y21:repeat_vec_with_capacity, r=dswij
new lint: `repeat_vec_with_capacity`

Closes #11537

[Lint description](https://github.com/y21/rust-clippy/blob/repeat_vec_with_capacity/clippy_lints/src/repeat_vec_with_capacity.rs#L14) should explain this PR :)

changelog: new lint: `repeat_vec_with_capacity`
2023-12-01 18:00:50 +00:00
Philipp Krones
c9a43b18f1 Merge commit 'f0cdee4a3f094416189261481eae374b76792af1' into clippy-subtree-sync 2023-12-01 18:21:58 +01:00
bors
f0cdee4a3f Auto merge of #11903 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-12-01 17:09:21 +00:00
Philipp Krones
9d36c18198
Bump nightly version -> 2023-12-01 2023-12-01 18:06:16 +01:00
Philipp Krones
a9867e1847
Merge remote-tracking branch 'upstream/master' into rustup 2023-12-01 18:06:03 +01:00
y21
76eb781336 use iter::repeat_with in suggestion and add examples 2023-12-01 17:24:34 +01:00