Skip to content

Commit

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

Clippy subtree update

r? `@Manishearth`
  • Loading branch information
bors committed May 2, 2024
2 parents 9382ba4 + e395dc9 commit a8773d5
Show file tree
Hide file tree
Showing 125 changed files with 1,686 additions and 767 deletions.
34 changes: 22 additions & 12 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ dependencies = [
"unicode-width",
]

[[package]]
name = "annotate-snippets"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5a59f105fb9635e9eebdc1e29d53e764fa5795b9cf899a638a53e61567ef61"
dependencies = [
"anstyle",
"unicode-width",
]

[[package]]
name = "ansi_term"
version = "0.12.1"
Expand Down Expand Up @@ -574,7 +584,7 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"

[[package]]
name = "clippy"
version = "0.1.79"
version = "0.1.80"
dependencies = [
"anstream",
"clippy_config",
Expand All @@ -595,13 +605,13 @@ dependencies = [
"termize",
"tokio",
"toml 0.7.8",
"ui_test 0.22.3",
"ui_test 0.23.0",
"walkdir",
]

[[package]]
name = "clippy_config"
version = "0.1.79"
version = "0.1.80"
dependencies = [
"rustc-semver",
"serde",
Expand All @@ -624,7 +634,7 @@ dependencies = [

[[package]]
name = "clippy_lints"
version = "0.1.79"
version = "0.1.80"
dependencies = [
"arrayvec",
"cargo_metadata 0.18.1",
Expand All @@ -649,7 +659,7 @@ dependencies = [

[[package]]
name = "clippy_utils"
version = "0.1.79"
version = "0.1.80"
dependencies = [
"arrayvec",
"clippy_config",
Expand Down Expand Up @@ -968,7 +978,7 @@ checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"

[[package]]
name = "declare_clippy_lint"
version = "0.1.79"
version = "0.1.80"
dependencies = [
"itertools 0.12.1",
"quote",
Expand Down Expand Up @@ -5160,9 +5170,9 @@ dependencies = [

[[package]]
name = "spanned"
version = "0.1.6"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad48ded9f0734eca7058107cc170767b8758e41e4088fb0020e7ff7ec6b0d92d"
checksum = "ccdf4f5590b7e6fbd4f2e80d442789079a6fff7c12ef921a9de358b7b353098e"
dependencies = [
"bstr",
"color-eyre",
Expand Down Expand Up @@ -5900,11 +5910,11 @@ dependencies = [

[[package]]
name = "ui_test"
version = "0.22.3"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa577a42db0e211a73c069d7dbcae54bc7473a7c5535a564842cbd8a13c0441e"
checksum = "29e5f4ffcbab82453958fbf59990e981b8e8a177dcd60c2bd8f9b52c3036a6e1"
dependencies = [
"annotate-snippets 0.10.2",
"annotate-snippets 0.11.2",
"anyhow",
"bstr",
"cargo-platform",
Expand All @@ -5919,7 +5929,7 @@ dependencies = [
"prettydiff",
"regex",
"rustc_version",
"rustfix 0.6.1",
"rustfix 0.8.1",
"serde",
"serde_json",
"spanned",
Expand Down
56 changes: 54 additions & 2 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,62 @@ document.

## Unreleased / Beta / In Rust Nightly

[66c29b97...master](https://github.com/rust-lang/rust-clippy/compare/66c29b97...master)
[93f0a9a9...master](https://github.com/rust-lang/rust-clippy/compare/93f0a9a9...master)

## Rust 1.78

Current stable, released 2024-05-02

[View all 112 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2024-01-26T05%3A46%3A23Z..2024-03-07T16%3A25%3A52Z+base%3Amaster)

### New Lints

* [`assigning_clones`]
[#12077](https://github.com/rust-lang/rust-clippy/pull/12077)
* [`mixed_attributes_style`]
[#12354](https://github.com/rust-lang/rust-clippy/pull/12354)
* [`empty_docs`]
[#12342](https://github.com/rust-lang/rust-clippy/pull/12342)
* [`unnecessary_get_then_check`]
[#12339](https://github.com/rust-lang/rust-clippy/pull/12339)
* [`multiple_bound_locations`]
[#12259](https://github.com/rust-lang/rust-clippy/pull/12259)
* [`unnecessary_clippy_cfg`]
[#12303](https://github.com/rust-lang/rust-clippy/pull/12303)
* [`deprecated_clippy_cfg_attr`]
[#12292](https://github.com/rust-lang/rust-clippy/pull/12292)
* [`manual_c_str_literals`]
[#11919](https://github.com/rust-lang/rust-clippy/pull/11919)
* [`ref_as_ptr`]
[#12087](https://github.com/rust-lang/rust-clippy/pull/12087)
* [`lint_groups_priority`]
[#11832](https://github.com/rust-lang/rust-clippy/pull/11832)
* [`unnecessary_result_map_or_else`]
[#12169](https://github.com/rust-lang/rust-clippy/pull/12169)
* [`to_string_trait_impl`]
[#12122](https://github.com/rust-lang/rust-clippy/pull/12122)
* [`incompatible_msrv`]
[#12160](https://github.com/rust-lang/rust-clippy/pull/12160)

### Enhancements

* [`thread_local_initializer_can_be_made_const`]: Now checks the [`msrv`] configuration
[#12405](https://github.com/rust-lang/rust-clippy/pull/12405)
* [`disallowed_macros`]: Code generated by derive macros can no longer allow this lint
[#12267](https://github.com/rust-lang/rust-clippy/pull/12267)
* [`wildcard_imports`]: Add configuration [`allowed-wildcard-imports`] to allow preconfigured wildcards
[#11979](https://github.com/rust-lang/rust-clippy/pull/11979)

### ICE Fixes

* [`ptr_as_ptr`]: No longer ICEs when the cast source is a function call to a local variable
[#12617](https://github.com/rust-lang/rust-clippy/pull/12617)
* [`cast_sign_loss`]: Avoids an infinite loop when casting two chained `.unwrap()` calls
[#12508](https://github.com/rust-lang/rust-clippy/pull/12508)

## Rust 1.77

Current stable, released 2024-03-18
Released 2024-03-18

[View all 93 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2023-12-16T18%3A20%3A00Z..2024-01-25T18%3A15%3A56Z+base%3Amaster)

Expand Down Expand Up @@ -5891,6 +5942,7 @@ Released 2018-09-13
[`allow-print-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-print-in-tests
[`allow-private-module-inception`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-private-module-inception
[`allow-unwrap-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-unwrap-in-tests
[`allow-useless-vec-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-useless-vec-in-tests
[`allowed-dotfiles`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allowed-dotfiles
[`allowed-duplicate-crates`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allowed-duplicate-crates
[`allowed-idents-below-min-chars`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allowed-idents-below-min-chars
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.1.79"
version = "0.1.80"
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md"
Expand Down Expand Up @@ -30,7 +30,7 @@ color-print = "0.3.4"
anstream = "0.6.0"

[dev-dependencies]
ui_test = "0.22.2"
ui_test = "0.23"
regex = "1.5.5"
toml = "0.7.3"
walkdir = "2.3"
Expand Down
8 changes: 4 additions & 4 deletions src/tools/clippy/book/src/development/adding_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,10 @@ This is good, because it makes writing this particular lint less complicated.
We have to make this decision with every new Clippy lint. It boils down to using
either [`EarlyLintPass`][early_lint_pass] or [`LateLintPass`][late_lint_pass].

In short, the `LateLintPass` has access to type information while the
`EarlyLintPass` doesn't. If you don't need access to type information, use the
`EarlyLintPass`. The `EarlyLintPass` is also faster. However, linting speed
hasn't really been a concern with Clippy so far.
In short, the `EarlyLintPass` runs before type checking and
[HIR](https://rustc-dev-guide.rust-lang.org/hir.html) lowering and the `LateLintPass`
has access to type information. Consider using the `LateLintPass` unless you need
something specific from the `EarlyLintPass`.

Since we don't need type information for checking the function name, we used
`--pass=early` when running the new lint automation and all the imports were
Expand Down
15 changes: 13 additions & 2 deletions src/tools/clippy/book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ Whether `unwrap` should be allowed in test functions or `#[cfg(test)]`
* [`unwrap_used`](https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used)


## `allow-useless-vec-in-tests`
Whether `useless_vec` should ignore test functions or `#[cfg(test)]`

**Default Value:** `false`

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


## `allowed-dotfiles`
Additional dotfiles (files or directories starting with a dot) to allow

Expand Down Expand Up @@ -506,13 +516,14 @@ The maximum byte size a `Future` can have, before it triggers the `clippy::large


## `ignore-interior-mutability`
A list of paths to types that should be treated like `Arc`, i.e. ignored but
for the generic parameters for determining interior mutability
A list of paths to types that should be treated as if they do not contain interior mutability

**Default Value:** `["bytes::Bytes"]`

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

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,6 +1,6 @@
[package]
name = "clippy_config"
version = "0.1.79"
version = "0.1.80"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
9 changes: 6 additions & 3 deletions src/tools/clippy/clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,17 @@ define_Conf! {
///
/// Whether print macros (ex. `println!`) should be allowed in test functions or `#[cfg(test)]`
(allow_print_in_tests: bool = false),
/// Lint: USELESS_VEC.
///
/// Whether `useless_vec` should ignore test functions or `#[cfg(test)]`
(allow_useless_vec_in_tests: bool = false),
/// Lint: RESULT_LARGE_ERR.
///
/// The maximum size of the `Err`-variant in a `Result` returned from a function
(large_error_threshold: u64 = 128),
/// Lint: MUTABLE_KEY_TYPE, IFS_SAME_COND.
/// Lint: MUTABLE_KEY_TYPE, IFS_SAME_COND, BORROW_INTERIOR_MUTABLE_CONST, DECLARE_INTERIOR_MUTABLE_CONST.
///
/// A list of paths to types that should be treated like `Arc`, i.e. ignored but
/// for the generic parameters for determining interior mutability
/// A list of paths to types that should be treated as if they do not contain interior mutability
(ignore_interior_mutability: Vec<String> = Vec::from(["bytes::Bytes".into()])),
/// Lint: UNINLINED_FORMAT_ARGS.
///
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_config/src/msrvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ msrv_aliases! {
1,70,0 { OPTION_RESULT_IS_VARIANT_AND, BINARY_HEAP_RETAIN }
1,68,0 { PATH_MAIN_SEPARATOR_STR }
1,65,0 { LET_ELSE, POINTER_CAST_CONSTNESS }
1,63,0 { ASSIGNING_CLONES }
1,63,0 { CLONE_INTO }
1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE }
1,59,0 { THREAD_LOCAL_INITIALIZER_CAN_BE_MADE_CONST }
1,58,0 { FORMAT_ARGS_CAPTURE, PATTERN_TRAIT_CHAR_ARRAY }
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy_lints"
version = "0.1.79"
version = "0.1.80"
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_lints/src/assigning_clones.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ declare_clippy_lint! {
/// a.clone_from(&b);
/// }
/// ```
#[clippy::version = "1.77.0"]
#[clippy::version = "1.78.0"]
pub ASSIGNING_CLONES,
perf,
"assigning the result of cloning may be inefficient"
Expand Down Expand Up @@ -153,7 +153,7 @@ fn extract_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option<
fn is_ok_to_suggest<'tcx>(cx: &LateContext<'tcx>, lhs: &Expr<'tcx>, call: &CallCandidate<'tcx>, msrv: &Msrv) -> bool {
// For calls to .to_owned we suggest using .clone_into(), which was only stablilized in 1.63.
// If the current MSRV is below that, don't suggest the lint.
if !msrv.meets(msrvs::ASSIGNING_CLONES) && matches!(call.target, TargetTrait::ToOwned) {
if !msrv.meets(msrvs::CLONE_INTO) && matches!(call.target, TargetTrait::ToOwned) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_lints/src/box_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ fn given_type(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
if let Some(index) = args.iter().position(|arg| arg.hir_id == expr.hir_id)
&& let Some(sig) = expr_sig(cx, path)
&& let Some(input) = sig.input(index)
&& !cx.typeck_results().expr_ty_adjusted(expr).boxed_ty().is_trait()
&& let Some(input_ty) = input.no_bound_vars()
{
input.no_bound_vars().is_some()
input_ty == cx.typeck_results().expr_ty_adjusted(expr)
} else {
false
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/cargo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ declare_clippy_lint! {
/// pedantic = { level = "warn", priority = -1 }
/// similar_names = "allow"
/// ```
#[clippy::version = "1.76.0"]
#[clippy::version = "1.78.0"]
pub LINT_GROUPS_PRIORITY,
correctness,
"a lint group in `Cargo.toml` at the same priority as a lint"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ fn apply_reductions(cx: &LateContext<'_>, nbits: u64, expr: &Expr<'_>, signed: b
get_constant_bits(cx, right).map_or(0, |b| b.saturating_sub(1))
})
},
BinOpKind::Rem | BinOpKind::BitAnd => get_constant_bits(cx, right)
BinOpKind::Rem => get_constant_bits(cx, right)
.unwrap_or(u64::MAX)
.min(apply_reductions(cx, nbits, left, signed)),
BinOpKind::BitAnd => get_constant_bits(cx, right)
.unwrap_or(u64::MAX)
.min(get_constant_bits(cx, left).unwrap_or(u64::MAX))
.min(apply_reductions(cx, nbits, right, signed))
.min(apply_reductions(cx, nbits, left, signed)),
BinOpKind::Shr => apply_reductions(cx, nbits, left, signed)
.saturating_sub(constant_int(cx, right).map_or(0, |s| u64::try_from(s).unwrap_or_default())),
_ => nbits,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/casts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ declare_clippy_lint! {
/// let a_ref = &1;
/// let a_ptr = std::ptr::from_ref(a_ref);
/// ```
#[clippy::version = "1.77.0"]
#[clippy::version = "1.78.0"]
pub REF_AS_PTR,
pedantic,
"using `as` to cast a reference to pointer"
Expand Down
Loading

0 comments on commit a8773d5

Please sign in to comment.