Commit Graph

18511 Commits

Author SHA1 Message Date
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
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
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
y21
504941591f new lint: repeat_vec_with_capacity 2023-12-01 16:52:34 +01:00
bors
3a760909fa Auto merge of #117472 - jmillikin:stable-c-str-literals, r=Nilstrieb
Stabilize C string literals

RFC: https://rust-lang.github.io/rfcs/3348-c-str-literal.html

Tracking issue: https://github.com/rust-lang/rust/issues/105723

Documentation PR (reference manual): https://github.com/rust-lang/reference/pull/1423

# Stabilization report

Stabilizes C string and raw C string literals (`c"..."` and `cr#"..."#`), which are expressions of type [`&CStr`](https://doc.rust-lang.org/stable/core/ffi/struct.CStr.html). Both new literals require Rust edition 2021 or later.

```rust
const HELLO: &core::ffi::CStr = c"Hello, world!";
```

C strings may contain any byte other than `NUL` (`b'\x00'`), and their in-memory representation is guaranteed to end with `NUL`.

## Implementation

Originally implemented by PR https://github.com/rust-lang/rust/pull/108801, which was reverted due to unintentional changes to lexer behavior in Rust editions < 2021.

The current implementation landed in PR https://github.com/rust-lang/rust/pull/113476, which restricts C string literals to Rust edition >= 2021.

## Resolutions to open questions from the RFC

* Adding C character literals (`c'.'`) of type `c_char` is not part of this feature.
  * Support for `c"..."` literals does not prevent `c'.'` literals from being added in the future.
* C string literals should not be blocked on making `&CStr` a thin pointer.
  * It's possible to declare constant expressions of type `&'static CStr` in stable Rust (as of v1.59), so C string literals are not adding additional coupling on the internal representation of `CStr`.
* The unstable `concat_bytes!` macro should not accept `c"..."` literals.
  * C strings have two equally valid `&[u8]` representations (with or without terminal `NUL`), so allowing them to be used in `concat_bytes!` would be ambiguous.
* Adding a type to represent C strings containing valid UTF-8 is not part of this feature.
  * Support for a hypothetical `&Utf8CStr` may be explored in the future, should such a type be added to Rust.
2023-12-01 13:33:55 +00:00
bors
d166fab544 Auto merge of #11898 - clubby789:upper_case_acronyms_variants, r=Manishearth
Allow `allow`ing `upper_case_acronyms` on enum variants

Fixes #7708

changelog: [`upper_case_acronyms`]: allow `allow`ing on enum variants
2023-12-01 05:29:52 +00:00
Samuel Tardieu
6275e77e6a Do not check twice whether qpath is a QPath::TypeRelative variant 2023-11-30 18:07:43 +01:00
clubby789
2cda044f8c Allow allowing upper_case_acronyms on enum variants 2023-11-30 16:00:40 +00:00
bors
646b28f5f6 Auto merge of #11896 - samueltardieu:issue-11893, r=Alexendoo
`option_if_let_else`: do not trigger on expressions returning `()`

Fix #11893

Trigerring on expressions returning `()` uses the arguments of the `map_or_else()` rewrite only for their side effects. This does lead to code which is harder to read than the original.

changelog: [`option_if_let_else`]: do not trigger on unit expressions
2023-11-30 15:17:29 +00:00
bors
665fd5219a Auto merge of #11872 - llogiq:test-attr-in-doctest, r=xFrednet
add lint against unit tests in doctests

During RustLab, Alice Ryhl brought to my attention that the Andoid team stumbled over the fact that if one attempts to write a unit test within a doctest, it will be summarily ignored. So this lint should help people wondering why their tests won't run.

---

changelog: New lint: [`test_attr_in_doctest`]
[#11872](https://github.com/rust-lang/rust-clippy/pull/11872)
2023-11-30 10:24:16 +00:00
J-ZhengLi
40b558af76 rename [blocks_in_if_conditions] to [blocks_in_conditions];
add more test cases with `match`;
minor fixes in message output regarding review feedback
2023-11-30 15:41:54 +08:00
J-ZhengLi
fff7aa0e18 expending lint [blocks_in_if_conditions] to check match expr as well 2023-11-30 14:44:27 +08:00
Samuel Tardieu
e3c73f17ec option_if_let_else: do not trigger on expressions returning ()
Fix #11893

Trigerring on expressions returning `()` uses the arguments of the
`map_or_else()` rewrite only for their side effects. This does lead
to code which is harder to read than the original.
2023-11-29 19:38:02 +01:00
bors
8b0bf6423d Auto merge of #11818 - y21:more_redundant_guards, r=llogiq
[`redundant_guards`]: catch `is_empty`, `starts_with` and `ends_with` on slices and `str`s

Fixes #11807

Few things worth mentioning:
- Taking `snippet`s is now done at callsite, instead of passing a span and doing it in `emit_redundant_guards`. This is because we now need custom suggestion strings in certain places, like `""` for `str::is_empty`.
- This now uses `snippet` instead of `snippet_with_applicability`. I don't think this really makes any difference for `MaybeIncorrect`, though?
- This could also lint byte strings, as they're of type `&[u8; N]`, but that can be ugly so I decided to leave it out for now

changelog: [`redundant_guards`]: catch `str::is_empty`, `slice::is_empty`, `slice::starts_with` and `slice::ends_with`
2023-11-29 13:20:59 +00:00
Matthias Krüger
071f8f610d Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors
Add `never_patterns` feature gate

This PR adds the feature gate and most basic parsing for the experimental `never_patterns` feature. See the tracking issue (https://github.com/rust-lang/rust/issues/118155) for details on the experiment.

`@scottmcm` has agreed to be my lang-team liaison for this experiment.
2023-11-29 12:34:47 +01:00
Nadrieril
02e50f03bf Add never_patterns feature gate 2023-11-29 03:58:29 +01:00
Andre Bogus
0ba9bf9f9a add lint against unit tests in doctests 2023-11-28 21:29:08 +01:00
bors
57397a5190 Auto merge of #11363 - KisaragiEffective:fix_redundant_closure_call_on_closure_returns_async_block, r=llogiq
[`redundant_closure_call`]: avoid duplicated `async` keyword when triggering on closure that returns `async` block

close #11357

----

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

changelog: [`redundant_closure_call`]: avoid duplicated `async` keyword when triggering on closure that returns `async` block
2023-11-28 20:27:48 +00:00
bors
91c5653a47 Auto merge of #11892 - y21:actually_rename_doc_for_real_this_time, r=Manishearth
rename `DocMarkdown` pass to `Documentation`

Followup of #11801

This was discussed in todays meeting: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Meeting.202023-11-28/near/404667082

Decided to go with `Documentation`, because this would also make it consistent with how `Attributes` is named in `attrs.rs` (and it also sounds good).

changelog: none
2023-11-28 18:59:25 +00:00
y21
0565267f37 rename DocMarkdown to Documentation 2023-11-28 19:14:37 +01:00
Nicholas Nethercote
684c4bfef1 Rework ast::BinOpKind::to_string and ast::UnOp::to_string.
- Rename them both `as_str`, which is the typical name for a function
  that returns a `&str`. (`to_string` is appropriate for functions
  returning `String` or maybe `Cow<'a, str>`.)
- Change `UnOp::as_str` from an associated function (weird!) to a
  method.
- Avoid needless `self` dereferences.
2023-11-28 09:42:07 +11:00
bors
e6f33905e8 Auto merge of #11836 - lukaslueg:issue11831, r=Alexendoo
Don't suggest `a.mul_add(b, c)` if parameters are not float

clippy::suboptimal_flops used to not check if the second parameter to f32/f64.mul_add() was float. Since the method is only defined to take `Self` as parameters, the suggestion was wrong.

Fixes #11831

changelog: [`suboptimal_float`]: Don't suggest `a.mul_add(b, c)` if parameters are not f32/f64
2023-11-27 20:37:34 +00:00
bors
003e910760 Auto merge of #11817 - y21:ptr_arg_mut_ref, r=Alexendoo
[`ptr_arg`]: recognize methods that also exist on slices

Fixes #11816

Not a new lint, just a very small improvement to the existing `ptr_arg` lint which would have caught the linked issue.

The problem was that the lint checks if a `Vec`-specific method was called, that is, if the receiver is `Vec<_>`.
This is the case for `len` and `is_empty`, however these methods also exist on slices so we can still lint there.
This logic exists in a different lint, so we can just reuse that here.

Interestingly, there was even a comment up top that explained what it should have been doing, but the logic for it just wasn't there?

changelog: [`ptr_arg`]: recognize methods that also exist on slices

<sub>Also, this is my 100th PR to clippy 🎉 </sub>
2023-11-27 20:26:31 +00:00
bors
caa73941f8 Auto merge of #11879 - samueltardieu:issue-11876, r=Alexendoo
`manual_try_fold`: check that `fold` is really `Iterator::fold`

Fix #11876

changelog: [`manual_try_fold`]: suggest using `try_fold` only for `Iterator::fold` uses
2023-11-27 20:18:40 +00:00
Kisaragi Marine
0426913ca9
fix dogfood 2023-11-28 00:40:13 +09:00
Kisaragi Marine
33182495ac
don't add paren on occurrences that is in call args 2023-11-28 00:27:51 +09:00
Kisaragi Marine
40b6aa0e86
cargo uibless 2023-11-27 23:53:07 +09:00
Kisaragi Marine
1acd8068bd
remove double-paren on test case 2023-11-27 23:50:08 +09:00
Kisaragi Marine
1661e7ee76
re-implement fix for rust-lang#11357 2023-11-27 23:43:39 +09:00
bors
5ba6480f02 Auto merge of #11877 - samueltardieu:doc-fix, r=flip1995
`TypeckResults::node_type()` can be used inside of bodies

Doc fix.

changelog: none
2023-11-27 09:09:17 +00:00
bors
f30a859ae3 Auto merge of #11867 - y21:implied_bounds_in_impls_complexity, r=Jarcho
Move `implied_bounds_in_impls` back to complexity

This lint was originally in the complexity category when I PR'd it. It was then moved to nursery by me due to a number of issues (a false positive, an invalid suggestion and an ICE), but that was probably an overreaction and all of the issues were fixed quickly after.
This is a useful lint imo and there hasn't been any issues with it in a few months, so I say we should give it another try and move it back to complexity.

I did a lintcheck run on the top 400 crates and all of them are legitimate, with 18 warnings. Most of them are from anstyle having a `impl Display + Copy + Clone` return type, or the bitvec crate with a return type like `impl Iterator + DoubleEndedIterator`.

changelog: Move [`implied_bounds_in_impls`] to `complexity` (Now warn-by-default)
[#11867](https://github.com/rust-lang/rust-clippy/pull/11867)
2023-11-26 22:28:13 +00:00
bors
2c56b4f800 Auto merge of #11875 - samueltardieu:fix-11868, r=Jarcho
Fix `box_default` behaviour with empty `vec![]` coming from macro arg

Fix #11868

changelog: [`box_default`]: do not warn on `Box::new(vec![])` if the `vec![]` comes from a macro argument
2023-11-26 22:00:02 +00:00