Skip to content

Commit

Permalink
Auto merge of rust-lang#135297 - flip1995:clippy-subtree-update, r=ma…
Browse files Browse the repository at this point in the history
…tthiaskrgr

Clippy subtree update

r? `@Manishearth`
  • Loading branch information
bors committed Jan 9, 2025
2 parents 8247594 + 43c3b30 commit af01afb
Show file tree
Hide file tree
Showing 147 changed files with 2,004 additions and 436 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"

[[package]]
name = "clippy"
version = "0.1.85"
version = "0.1.86"
dependencies = [
"anstream",
"cargo_metadata 0.18.1",
Expand Down Expand Up @@ -572,7 +572,7 @@ dependencies = [

[[package]]
name = "clippy_config"
version = "0.1.85"
version = "0.1.86"
dependencies = [
"clippy_utils",
"itertools",
Expand All @@ -597,7 +597,7 @@ dependencies = [

[[package]]
name = "clippy_lints"
version = "0.1.85"
version = "0.1.86"
dependencies = [
"arrayvec",
"cargo_metadata 0.18.1",
Expand All @@ -620,7 +620,7 @@ dependencies = [

[[package]]
name = "clippy_utils"
version = "0.1.85"
version = "0.1.86"
dependencies = [
"arrayvec",
"itertools",
Expand Down
3 changes: 3 additions & 0 deletions src/tools/clippy/.github/workflows/clippy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
# Setup
- name: Checkout
uses: actions/checkout@v4
with:
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false

# Run
- name: Build
Expand Down
27 changes: 22 additions & 5 deletions src/tools/clippy/.github/workflows/clippy_mq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false

# Run
- name: Check Changelog
Expand Down Expand Up @@ -63,6 +65,8 @@ jobs:
# Setup
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install i686 dependencies
if: matrix.host == 'i686-unknown-linux-gnu'
Expand All @@ -74,7 +78,8 @@ jobs:
- name: Install toolchain
run: |
rustup set default-host ${{ matrix.host }}
rustup show active-toolchain
# Use a way compatible with Rustup pre-1.28.0 and Rustup 1.28.0
rustup show active-toolchain || rustup toolchain install
# Run
- name: Build
Expand Down Expand Up @@ -121,9 +126,13 @@ jobs:
# Setup
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install toolchain
run: rustup show active-toolchain
run: |
# Use a way compatible with Rustup pre-1.28.0 and Rustup 1.28.0
rustup show active-toolchain || rustup toolchain install
- name: Test metadata collection
run: cargo collect-metadata
Expand All @@ -136,9 +145,13 @@ jobs:
# Setup
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install toolchain
run: rustup show active-toolchain
run: |
# Use a way compatible with Rustup pre-1.28.0 and Rustup 1.28.0
rustup show active-toolchain || rustup toolchain install
# Run
- name: Build Integration Test
Expand Down Expand Up @@ -188,9 +201,13 @@ jobs:
# Setup
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install toolchain
run: rustup show active-toolchain
run: |
# Use a way compatible with Rustup pre-1.28.0 and Rustup 1.28.0
rustup show active-toolchain || rustup toolchain install
# Download
- name: Download target dir
Expand All @@ -205,7 +222,7 @@ jobs:
# Run
- name: Test ${{ matrix.integration }}
run: |
TOOLCHAIN=$(rustup show active-toolchain | cut -f1 -d' ')
TOOLCHAIN=$(rustup show active-toolchain | head -n 1 | cut -f1 -d' ')
rustup run $TOOLCHAIN $CARGO_TARGET_DIR/debug/integration --show-output
env:
INTEGRATION: ${{ matrix.integration }}
Expand Down
7 changes: 6 additions & 1 deletion src/tools/clippy/.github/workflows/clippy_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ jobs:
# Setup
- name: Checkout
uses: actions/checkout@v4
with:
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false

- name: Install toolchain
run: rustup show active-toolchain
run: |
# Use a way compatible with Rustup pre-1.28.0 and Rustup 1.28.0
rustup show active-toolchain || rustup toolchain install
# Run
- name: Build
Expand Down
10 changes: 9 additions & 1 deletion src/tools/clippy/.github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,27 @@ jobs:
# Setup
- name: Checkout
uses: actions/checkout@v4
with:
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.TARGET_BRANCH }}
path: 'out'
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false

# Run
- name: Set tag name
if: startswith(github.ref, 'refs/tags/')
run: |
TAG=$(basename ${{ github.ref }})
TAG=$(basename "${TAGNAME}")
echo "TAG_NAME=$TAG" >> $GITHUB_ENV
env:
# Make sure that the reference gets expanded before injecting it
TAGNAME: ${{ github.ref }}
- name: Set beta to true
if: github.ref == 'refs/heads/beta'
run: echo "BETA=true" >> $GITHUB_ENV
Expand Down
8 changes: 8 additions & 0 deletions src/tools/clippy/.github/workflows/lintcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 2
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false

# HEAD is the generated merge commit `refs/pull/N/merge` between the PR and `master`, `HEAD^`
# being the commit from `master` that is the base of the merge
Expand Down Expand Up @@ -73,6 +75,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false

- name: Cache lintcheck bin
id: cache-lintcheck-bin
Expand Down Expand Up @@ -103,6 +108,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false

- name: Restore lintcheck bin
uses: actions/cache/restore@v4
Expand Down
3 changes: 3 additions & 0 deletions src/tools/clippy/.github/workflows/remark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
# Setup
- name: Checkout
uses: actions/checkout@v4
with:
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v4
Expand Down
47 changes: 45 additions & 2 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,52 @@ document.

## Unreleased / Beta / In Rust Nightly

[aa0d5513...master](https://github.com/rust-lang/rust-clippy/compare/aa0d5513...master)
[786fbd6d...master](https://github.com/rust-lang/rust-clippy/compare/786fbd6d...master)

## Rust 1.84

Current stable, released 2025-01-09

[View all 84 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2024-10-03T21%3A23%3A58Z..2024-11-14T17%3A41%3A37Z+base%3Amaster)

### New Lints

* Added [`unnecessary_map_or`] to `style`
[#11796](https://github.com/rust-lang/rust-clippy/pull/11796)
* Added [`arbitrary_source_item_ordering`] to `restriction`
[#13376](https://github.com/rust-lang/rust-clippy/pull/13376)
* Added [`map_with_unused_argument_over_ranges`] to `restriction`
[#13034](https://github.com/rust-lang/rust-clippy/pull/13034)
* Added [`map_all_any_identity`] to `complexity`
[#13499](https://github.com/rust-lang/rust-clippy/pull/13499)
* Added [`needless_as_bytes`] to `complexity`
[#13437](https://github.com/rust-lang/rust-clippy/pull/13437)
* Added [`unnecessary_literal_bound`] to `pedantic`
[#13395](https://github.com/rust-lang/rust-clippy/pull/13395)
* Added [`manual_ignore_case_cmp`] to `perf`
[#13334](https://github.com/rust-lang/rust-clippy/pull/13334)
* Added [`regex_creation_in_loops`] to `perf`
[#13412](https://github.com/rust-lang/rust-clippy/pull/13412)

### Moves and Deprecations

* Moved [`manual_is_power_of_two`] to `pedantic` (From `complexity`, now allow-by-default)
[#13553](https://github.com/rust-lang/rust-clippy/pull/13553)
* Move [`module_name_repetitions`] to `restriction` (from `pedantic`)
[#13541](https://github.com/rust-lang/rust-clippy/pull/13541)

### Enhancements

* [`doc_markdown`]: Added the following identifiers to [`doc-valid-idents`]:
CoAP, MHz, GHz, and THz
[#13633](https://github.com/rust-lang/rust-clippy/pull/13633)
[#13460](https://github.com/rust-lang/rust-clippy/pull/13460)
* [`large_const_arrays`]: Changed the default of [`array-size-threshold`] to `16kb` (from `512kb`)
[#13485](https://github.com/rust-lang/rust-clippy/pull/13485)

## Rust 1.83

Current stable, released 2024-11-28
Released 2024-11-28

[View all 64 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2024-08-25T09%3A59%3A01Z..2024-10-03T13%3A42%3A56Z+base%3Amaster)

Expand Down Expand Up @@ -5493,6 +5534,7 @@ Released 2018-09-13
[`doc_markdown`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
[`doc_nested_refdefs`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_nested_refdefs
[`double_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_comparisons
[`double_ended_iterator_last`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_ended_iterator_last
[`double_must_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use
[`double_neg`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_neg
[`double_parens`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_parens
Expand Down Expand Up @@ -6252,6 +6294,7 @@ Released 2018-09-13
[`future-size-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#future-size-threshold
[`ignore-interior-mutability`]: https://doc.rust-lang.org/clippy/lint_configuration.html#ignore-interior-mutability
[`large-error-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#large-error-threshold
[`lint-inconsistent-struct-field-initializers`]: https://doc.rust-lang.org/clippy/lint_configuration.html#lint-inconsistent-struct-field-initializers
[`literal-representation-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#literal-representation-threshold
[`matches-for-let-else`]: https://doc.rust-lang.org/clippy/lint_configuration.html#matches-for-let-else
[`max-fn-params-bools`]: https://doc.rust-lang.org/clippy/lint_configuration.html#max-fn-params-bools
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "clippy"
# begin autogenerated version
version = "0.1.85"
version = "0.1.86"
# end autogenerated version
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ As section headers, we use:

```
### New Lints
* Added [`LINT`] to `GROUP`
### Moves and Deprecations
* Moved [`LINT`] to `GROUP` (From `GROUP`, now LEVEL-by-default)
* Renamed `LINT` to [`LINT`]
### Enhancements
### False Positive Fixes
### Suggestion Fixes/Improvements
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/book/src/development/method_checking.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use clippy_utils::is_trait_method;
impl<'tcx> LateLintPass<'tcx> for OurFancyMethodLint {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
// Check our expr is calling a method with pattern matching
if let hir::ExprKind::MethodCall(path, _, [self_arg, ..]) = &expr.kind
if let hir::ExprKind::MethodCall(path, _, [self_arg, ..], _) = &expr.kind
// Check if the name of this method is `our_fancy_method`
&& path.ident.name.as_str() == "our_fancy_method"
// We can check the type of the self argument whenever necessary.
Expand Down
27 changes: 27 additions & 0 deletions src/tools/clippy/book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,33 @@ The maximum size of the `Err`-variant in a `Result` returned from a function
* [`result_large_err`](https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err)


## `lint-inconsistent-struct-field-initializers`
Whether to suggest reordering constructor fields when initializers are present.

Warnings produced by this configuration aren't necessarily fixed by just reordering the fields. Even if the
suggested code would compile, it can change semantics if the initializer expressions have side effects. The
following example [from rust-clippy#11846] shows how the suggestion can run into borrow check errors:

```rust
struct MyStruct {
vector: Vec<u32>,
length: usize
}
fn main() {
let vector = vec![1,2,3];
MyStruct { length: vector.len(), vector};
}
```

[from rust-clippy#11846]: https://github.com/rust-lang/rust-clippy/issues/11846#issuecomment-1820747924

**Default Value:** `false`

---
**Affected lints:**
* [`inconsistent_struct_constructor`](https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_struct_constructor)


## `literal-representation-threshold`
The lower bound for linting decimal literals

Expand Down
2 changes: 2 additions & 0 deletions src/tools/clippy/clippy.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
avoid-breaking-exported-api = false

lint-inconsistent-struct-field-initializers = true

[[disallowed-methods]]
path = "rustc_lint::context::LintContext::lint"
reason = "this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint*` functions instead"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "clippy_config"
# begin autogenerated version
version = "0.1.85"
version = "0.1.86"
# end autogenerated version
edition = "2021"
publish = false
Expand Down
20 changes: 20 additions & 0 deletions src/tools/clippy/clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,26 @@ define_Conf! {
/// The maximum size of the `Err`-variant in a `Result` returned from a function
#[lints(result_large_err)]
large_error_threshold: u64 = 128,
/// Whether to suggest reordering constructor fields when initializers are present.
///
/// Warnings produced by this configuration aren't necessarily fixed by just reordering the fields. Even if the
/// suggested code would compile, it can change semantics if the initializer expressions have side effects. The
/// following example [from rust-clippy#11846] shows how the suggestion can run into borrow check errors:
///
/// ```rust
/// struct MyStruct {
/// vector: Vec<u32>,
/// length: usize
/// }
/// fn main() {
/// let vector = vec![1,2,3];
/// MyStruct { length: vector.len(), vector};
/// }
/// ```
///
/// [from rust-clippy#11846]: https://github.com/rust-lang/rust-clippy/issues/11846#issuecomment-1820747924
#[lints(inconsistent_struct_constructor)]
lint_inconsistent_struct_field_initializers: bool = false,
/// The lower bound for linting decimal literals
#[lints(decimal_literal_representation)]
literal_representation_threshold: u64 = 16384,
Expand Down
Loading

0 comments on commit af01afb

Please sign in to comment.