Skip to content

Clippy subtree update #133588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 72 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
1309e8f
allow conditional `Send` futures in `future_not_send`
y21 Oct 23, 2024
1ceaa90
Merge commit '786fbd6d683933cd0e567fdcd25d449a69b4320c' into clippy-s…
flip1995 Nov 14, 2024
4460db0
Move MSRV implementation to clippy_utils
flip1995 Nov 15, 2024
81483d4
Move create_disallowed_map to clippy_config
flip1995 Nov 15, 2024
5c1811a
Rename all clippy_config::msrvs -> clippy_utils::msrvs
flip1995 Nov 15, 2024
83f7526
Allow conditional `Send` futures in `future_not_send` (#13590)
Alexendoo Nov 15, 2024
627363e
Reverse dependency between `clippy_utils` and `clippy_config` (#13691)
blyxyas Nov 15, 2024
81dceed
Support user format-like macros
nyurik Mar 28, 2023
d1688b5
`unnecessary_map_or`: add non-comparaison tests
samueltardieu Nov 4, 2024
ca963b6
Simplify instances of `Option::map_or(true, …)` in Clippy sources
samueltardieu Nov 4, 2024
de03a05
unnecessary_map_or: lint `.map_or(true, …)` as well
samueltardieu Nov 4, 2024
5f05ce4
Support user format-like macros (#9948)
Alexendoo Nov 16, 2024
8859847
`redundant_guards`: lint float literals, don't lint cstr literals
y21 Nov 17, 2024
8698c31
Don't lint CStr literals, do lint float literals in `redundant_guards…
Centri3 Nov 17, 2024
74b95f2
Prepare clippy_utils for publishing
flip1995 Nov 15, 2024
ef42a66
Do not trigger if_let_mutex strating from Edition 2024
alex-semenyuk Nov 16, 2024
97b9e4a
Do not trigger `if_let_mutex` starting from Edition 2024 (#13695)
y21 Nov 17, 2024
a2b6b6b
Inline ExprPrecedence::order into Expr::precedence
dtolnay Nov 17, 2024
0712689
Prepare `clippy_utils` README and Cargo.toml for publishing (#13693)
blyxyas Nov 17, 2024
9c8d950
Introduce `utils` mod in clippy_dev
flip1995 May 4, 2024
bb93c23
use `TypingEnv` when no `infcx` is available
lcnr Nov 15, 2024
d8423ca
`missing_safety_doc` accept capitalized "SAFETY"
overlookmotel Nov 18, 2024
90de44a
Remove extern vectorcall tests
Alexendoo Nov 18, 2024
d3edd05
Handle `Option::map_or(true, …)` in `unnecessary_map_or` lint (#13653)
Centri3 Nov 18, 2024
7a1e9f2
`missing_safety_doc` accept uppercase "SAFETY" (#13701)
Manishearth Nov 18, 2024
53994bd
Remove extern vectorcall tests (#13702)
Manishearth Nov 18, 2024
eaec0ca
Fix 13578 (#13583)
smoelius Oct 22, 2024
10677c3
Don't consider lifetimes in bounded types unused (fix `extra_unused_l…
Alexendoo Nov 19, 2024
6671553
Add `cargo dev sync` subcommand
flip1995 Nov 15, 2024
93d5ccd
Add `cargo dev release` subcommand
flip1995 Nov 15, 2024
809b420
move `fn is_item_raw` to `TypingEnv`
lcnr Nov 19, 2024
d8e5f7a
remove `TypingMode::from_param_env` in clippy
lcnr Nov 19, 2024
c783d1e
`InterpCx` store `TypingEnv` instead of a `ParamEnv`
lcnr Nov 19, 2024
425346a
Use a better message for unnecessary_map_or lint
samueltardieu Nov 19, 2024
cfd17d4
Use a better message for unnecessary_map_or lint (#13708)
y21 Nov 19, 2024
a19d69d
Sync and Release automation (#13694)
blyxyas Nov 19, 2024
ff6c4b7
reduce false positives of tail-expr-drop-order from consumed values
dingxiangfei2009 Sep 1, 2024
78d0a2a
Update version attributes for 1.83 lints
xFrednet Nov 21, 2024
404e47a
Add new lint `doc_include_without_cfg`
GuillaumeGomez Oct 29, 2024
8298da7
Add new lint `doc_include_without_cfg` (#13625)
blyxyas Nov 21, 2024
70d53bb
Changelog for Clippy 1.83 :robot:
xFrednet Nov 21, 2024
9f7fb41
fix: multipart suggestions for derivable_impls
scottgerring Nov 22, 2024
f0bb475
Remove incorrect "no default" text from trivial_copy_size_limit
Kampfkarren Nov 22, 2024
45e1a3a
Update CHANGELOG.md
xFrednet Nov 22, 2024
1931fb8
remove is_trivially_const_drop
RalfJung Nov 23, 2024
78fa111
no more Reveal :(
lcnr Nov 20, 2024
80df2c4
Use a better description of an internal function
samueltardieu Nov 23, 2024
9fd8e99
Prevent ICE in case of a bound constraint on generic argument
samueltardieu Nov 23, 2024
943c3bc
Add note about caveat for `cfg(doc)`
notriddle Nov 24, 2024
728826f
Rollup merge of #133371 - RalfJung:is_trivially_const_drop, r=compile…
matthiaskrgr Nov 24, 2024
418dfb2
Add Known problems section
notriddle Nov 24, 2024
479e1fc
Add note about caveat for `cfg(doc)` (#13724)
Alexendoo Nov 24, 2024
671183a
Bless
Kampfkarren Nov 25, 2024
945ccbd
Refactor `where` predicates, and reserve for attributes support
frank-king Nov 25, 2024
d070402
Remove incorrect "default there is no limit" documentation from trivi…
xFrednet Nov 25, 2024
3d881e1
Prevent ICE in case of a bound constraint on generic argument (#13722)
llogiq Nov 25, 2024
d49501c
Use a better description of an internal function (#13721)
llogiq Nov 25, 2024
2bf03f1
Handle repetition of associated constant constraint as well
samueltardieu Nov 23, 2024
6dcac6e
unnecessary_map_or: fix version for lint addition
samueltardieu Nov 26, 2024
17fb5ad
[] Fix FP on proc macros
blyxyas Nov 26, 2024
b73a71c
Rollup merge of #133140 - dtolnay:precedence, r=fmease
compiler-errors Nov 26, 2024
8bc1a9e
unnecessary_map_or: fix version for lint addition (#13733)
Centri3 Nov 26, 2024
9b0597d
Fix: Use multipart_suggestion for derivable_impls (#13717)
flip1995 Nov 27, 2024
67657da
Handle repetition of associated constant constraint as well (#13723)
y21 Nov 27, 2024
b4163f0
[`bad_bit_mask`] Fix FP on proc macros (#13736)
Jarcho Nov 27, 2024
5dc5842
Changelog for Clippy 1.83 🤖 (#13716)
xFrednet Nov 28, 2024
b24360a
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Nov 28, 2024
3c9daca
Bump nightly version -> 2024-11-28
flip1995 Nov 28, 2024
5fb924f
Bump Clippy version -> 0.1.85
flip1995 Nov 28, 2024
ff4a26d
Rustup (#13746)
flip1995 Nov 28, 2024
b01e901
Merge commit 'ff4a26d442bead94a4c96fb1de967374bc4fbd8e' into clippy-s…
flip1995 Nov 28, 2024
315b47e
Update Cargo.lock
flip1995 Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"

[[package]]
name = "clippy"
version = "0.1.84"
version = "0.1.85"
dependencies = [
"anstream",
"cargo_metadata",
Expand Down Expand Up @@ -567,8 +567,9 @@ dependencies = [

[[package]]
name = "clippy_config"
version = "0.1.84"
version = "0.1.85"
dependencies = [
"clippy_utils",
"itertools",
"serde",
"toml 0.7.8",
Expand All @@ -580,6 +581,7 @@ name = "clippy_dev"
version = "0.0.1"
dependencies = [
"aho-corasick",
"chrono",
"clap",
"indoc",
"itertools",
Expand All @@ -590,7 +592,7 @@ dependencies = [

[[package]]
name = "clippy_lints"
version = "0.1.84"
version = "0.1.85"
dependencies = [
"arrayvec",
"cargo_metadata",
Expand All @@ -613,12 +615,12 @@ dependencies = [

[[package]]
name = "clippy_utils"
version = "0.1.84"
version = "0.1.85"
dependencies = [
"arrayvec",
"clippy_config",
"itertools",
"rustc_apfloat",
"serde",
]

[[package]]
Expand Down
50 changes: 48 additions & 2 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,56 @@ document.

## Unreleased / Beta / In Rust Nightly

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

## Rust 1.83

Current stable, 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)

### Important Change

* Removed the implicit `cargo-clippy` feature set by Clippy as announced here:
<https://blog.rust-lang.org/2024/02/28/Clippy-deprecating-feature-cargo-clippy.html>
[#13246](https://github.com/rust-lang/rust-clippy/pull/13246)

### New Lints

* Added [`unused_trait_names`] to `restriction`
[#13322](https://github.com/rust-lang/rust-clippy/pull/13322)
* Added [`unnecessary_first_then_check`] to `complexity`
[#13421](https://github.com/rust-lang/rust-clippy/pull/13421)
* Added [`non_zero_suggestions`] to `restriction`
[#13167](https://github.com/rust-lang/rust-clippy/pull/13167)
* Added [`manual_is_power_of_two`] to `pedantic`
[#13327](https://github.com/rust-lang/rust-clippy/pull/13327)
* Added [`manual_div_ceil`] to `complexity`
[#12987](https://github.com/rust-lang/rust-clippy/pull/12987)
* Added [`zombie_processes`] to `suspicious`
[#11476](https://github.com/rust-lang/rust-clippy/pull/11476)
* Added [`used_underscore_items`] to `pedantic`
[#13294](https://github.com/rust-lang/rust-clippy/pull/13294)

### Moves and Deprecations

* Moved [`ref_option`] to `pedantic` (From `nursery`)
[#13469](https://github.com/rust-lang/rust-clippy/pull/13469)
* Moved [`manual_c_str_literals`] to `complexity` (From `pedantic`, now warn-by-default)
[#13263](https://github.com/rust-lang/rust-clippy/pull/13263)
* Moved [`empty_line_after_doc_comments`] to `suspicious` (From `nursery`, now warn-by-default)
[#13091](https://github.com/rust-lang/rust-clippy/pull/13091)
* Moved [`empty_line_after_outer_attr`] to `suspicious` (From `nursery`, now warn-by-default)
[#13091](https://github.com/rust-lang/rust-clippy/pull/13091)

### Enhancements

* [`missing_panics_doc`]: No longer lints in const environments
[#13382](https://github.com/rust-lang/rust-clippy/pull/13382)

## Rust 1.82

Current stable, released 2024-10-17
Released 2024-10-17

[View all 108 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2024-07-11T20%3A12%3A07Z..2024-08-24T20%3A55%3A35Z+base%3Amaster)

Expand Down Expand Up @@ -5441,6 +5486,7 @@ Released 2018-09-13
[`disallowed_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_type
[`disallowed_types`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types
[`diverging_sub_expression`]: https://rust-lang.github.io/rust-clippy/master/index.html#diverging_sub_expression
[`doc_include_without_cfg`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_include_without_cfg
[`doc_lazy_continuation`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation
[`doc_link_with_quotes`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_link_with_quotes
[`doc_markdown`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
Expand Down
6 changes: 4 additions & 2 deletions src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[package]
name = "clippy"
version = "0.1.84"
# begin autogenerated version
version = "0.1.85"
# end autogenerated version
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md"
Expand All @@ -27,7 +29,7 @@ rustc_tools_util = "0.4.0"
tempfile = { version = "3.3", optional = true }
termize = "0.1"
color-print = "0.3.4"
anstream = "0.6.0"
anstream = "0.6.18"

[dev-dependencies]
cargo_metadata = "0.18.1"
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [Configuration](configuration.md)
- [Lint Configuration](lint_configuration.md)
- [Clippy's Lints](lints.md)
- [Attributes for Crate Authors](attribs.md)
- [Continuous Integration](continuous_integration/README.md)
- [GitHub Actions](continuous_integration/github_actions.md)
- [GitLab CI](continuous_integration/gitlab.md)
Expand Down
53 changes: 53 additions & 0 deletions src/tools/clippy/book/src/attribs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Attributes for Crate Authors

In some cases it is possible to extend Clippy coverage to 3rd party libraries.
To do this, Clippy provides attributes that can be applied to items in the 3rd party crate.

## `#[clippy::format_args]`

_Available since Clippy v1.84_

This attribute can be added to a macro that supports `format!`, `println!`, or similar syntax.
It tells Clippy that the macro is a formatting macro, and that the arguments to the macro
should be linted as if they were arguments to `format!`. Any lint that would apply to a
`format!` call will also apply to the macro call. The macro may have additional arguments
before the format string, and these will be ignored.

### Example

```rust
/// A macro that prints a message if a condition is true.
#[macro_export]
#[clippy::format_args]
macro_rules! print_if {
($condition:expr, $($args:tt)+) => {{
if $condition {
println!($($args)+)
}
}};
}
```

## `#[clippy::has_significant_drop]`

_Available since Clippy v1.60_

The `clippy::has_significant_drop` attribute can be added to types whose Drop impls have an important side effect,
such as unlocking a mutex, making it important for users to be able to accurately understand their lifetimes.
When a temporary is returned in a function call in a match scrutinee, its lifetime lasts until the end of the match
block, which may be surprising.

### Example

```rust
#[clippy::has_significant_drop]
struct CounterWrapper<'a> {
counter: &'a Counter,
}

impl<'a> Drop for CounterWrapper<'a> {
fn drop(&mut self) {
self.counter.i.fetch_sub(1, Ordering::Relaxed);
}
}
```
4 changes: 2 additions & 2 deletions src/tools/clippy/book/src/development/adding_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ need to ensure that the MSRV configured for the project is >= the MSRV of the
required Rust feature. If multiple features are required, just use the one with
a lower MSRV.

First, add an MSRV alias for the required feature in [`clippy_config::msrvs`].
First, add an MSRV alias for the required feature in [`clippy_utils::msrvs`].
This can be accessed later as `msrvs::STR_STRIP_PREFIX`, for example.

```rust
Expand Down Expand Up @@ -517,7 +517,7 @@ define_Conf! {
}
```

[`clippy_config::msrvs`]: https://doc.rust-lang.org/nightly/nightly-rustc/clippy_config/msrvs/index.html
[`clippy_utils::msrvs`]: https://doc.rust-lang.org/nightly/nightly-rustc/clippy_config/msrvs/index.html

Afterwards update the documentation for the book as described in [Adding configuration to a lint](#adding-configuration-to-a-lint).

Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ The order of associated items in traits.

## `trivial-copy-size-limit`
The maximum size (in bytes) to consider a `Copy` type for passing by value instead of by
reference. By default there is no limit
reference.

**Default Value:** `target_pointer_width * 2`

Expand Down
6 changes: 5 additions & 1 deletion src/tools/clippy/clippy_config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[package]
name = "clippy_config"
version = "0.1.84"
# begin autogenerated version
version = "0.1.85"
# end autogenerated version
edition = "2021"
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clippy_utils = { path = "../clippy_utils" }
itertools = "0.12"
serde = { version = "1.0", features = ["derive"] }
toml = "0.7.3"
Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::ClippyConfiguration;
use crate::msrvs::Msrv;
use crate::types::{
DisallowedPath, MacroMatcher, MatchLintBehaviour, PubUnderscoreFieldsBehaviour, Rename, SourceItemOrdering,
SourceItemOrderingCategory, SourceItemOrderingModuleItemGroupings, SourceItemOrderingModuleItemKind,
SourceItemOrderingTraitAssocItemKind, SourceItemOrderingTraitAssocItemKinds,
};
use clippy_utils::msrvs::Msrv;
use rustc_errors::Applicability;
use rustc_session::Session;
use rustc_span::edit_distance::edit_distance;
Expand Down Expand Up @@ -181,7 +181,7 @@ macro_rules! define_Conf {
)*) => {
/// Clippy lint configuration
pub struct Conf {
$($(#[doc = $doc])+ pub $name: $ty,)*
$($(#[cfg_attr(doc, doc = $doc)])+ pub $name: $ty,)*
}

mod defaults {
Expand Down Expand Up @@ -678,7 +678,7 @@ define_Conf! {
#[lints(arbitrary_source_item_ordering)]
trait_assoc_item_kinds_order: SourceItemOrderingTraitAssocItemKinds = DEFAULT_TRAIT_ASSOC_ITEM_KINDS_ORDER.into(),
/// The maximum size (in bytes) to consider a `Copy` type for passing by value instead of by
/// reference. By default there is no limit
/// reference.
#[default_text = "target_pointer_width * 2"]
#[lints(trivially_copy_pass_by_ref)]
trivial_copy_size_limit: Option<u64> = None,
Expand Down
8 changes: 2 additions & 6 deletions src/tools/clippy/clippy_config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@
rustc::untranslatable_diagnostic
)]

extern crate rustc_ast;
extern crate rustc_attr;
#[allow(unused_extern_crates)]
extern crate rustc_driver;
extern crate rustc_errors;
extern crate rustc_hir;
extern crate rustc_middle;
extern crate rustc_session;
extern crate rustc_span;
extern crate smallvec;

mod conf;
mod metadata;
pub mod msrvs;
pub mod types;

pub use conf::{Conf, get_configuration_metadata, lookup_conf_file, sanitize_explanation};
Expand Down
15 changes: 15 additions & 0 deletions src/tools/clippy/clippy_config/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use clippy_utils::def_path_def_ids;
use rustc_hir::def_id::DefIdMap;
use rustc_middle::ty::TyCtxt;
use serde::de::{self, Deserializer, Visitor};
use serde::{Deserialize, Serialize, ser};
use std::collections::HashMap;
Expand Down Expand Up @@ -31,6 +34,18 @@ impl DisallowedPath {
}
}

/// Creates a map of disallowed items to the reason they were disallowed.
pub fn create_disallowed_map(
tcx: TyCtxt<'_>,
disallowed: &'static [DisallowedPath],
) -> DefIdMap<(&'static str, Option<&'static str>)> {
disallowed
.iter()
.map(|x| (x.path(), x.path().split("::").collect::<Vec<_>>(), x.reason()))
.flat_map(|(name, path, reason)| def_path_def_ids(tcx, &path).map(move |id| (id, (name, reason))))
.collect()
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub enum MatchLintBehaviour {
AllTypes,
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"

[dependencies]
aho-corasick = "1.0"
chrono = { version = "0.4.38", default-features = false, features = ["clock"] }
clap = { version = "4.4", features = ["derive"] }
indoc = "1.0"
itertools = "0.12"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_dev/src/dogfood.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{clippy_project_root, exit_if_err};
use crate::utils::{clippy_project_root, exit_if_err};
use std::process::Command;

/// # Panics
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_dev/src/fmt.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::clippy_project_root;
use crate::utils::clippy_project_root;
use itertools::Itertools;
use rustc_lexer::{TokenKind, tokenize};
use shell_escape::escape;
Expand Down
Loading
Loading