Skip to content

Commit d10a682

Browse files
committed
Auto merge of rust-lang#133588 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update r? `@Manishearth`
2 parents a45391f + 315b47e commit d10a682

File tree

196 files changed

+1965
-652
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+1965
-652
lines changed

Cargo.lock

+7-5
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
536536

537537
[[package]]
538538
name = "clippy"
539-
version = "0.1.84"
539+
version = "0.1.85"
540540
dependencies = [
541541
"anstream",
542542
"cargo_metadata",
@@ -567,8 +567,9 @@ dependencies = [
567567

568568
[[package]]
569569
name = "clippy_config"
570-
version = "0.1.84"
570+
version = "0.1.85"
571571
dependencies = [
572+
"clippy_utils",
572573
"itertools",
573574
"serde",
574575
"toml 0.7.8",
@@ -580,6 +581,7 @@ name = "clippy_dev"
580581
version = "0.0.1"
581582
dependencies = [
582583
"aho-corasick",
584+
"chrono",
583585
"clap",
584586
"indoc",
585587
"itertools",
@@ -590,7 +592,7 @@ dependencies = [
590592

591593
[[package]]
592594
name = "clippy_lints"
593-
version = "0.1.84"
595+
version = "0.1.85"
594596
dependencies = [
595597
"arrayvec",
596598
"cargo_metadata",
@@ -613,12 +615,12 @@ dependencies = [
613615

614616
[[package]]
615617
name = "clippy_utils"
616-
version = "0.1.84"
618+
version = "0.1.85"
617619
dependencies = [
618620
"arrayvec",
619-
"clippy_config",
620621
"itertools",
621622
"rustc_apfloat",
623+
"serde",
622624
]
623625

624626
[[package]]

src/tools/clippy/CHANGELOG.md

+48-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,56 @@ document.
66

77
## Unreleased / Beta / In Rust Nightly
88

9-
[0f8eabd6...master](https://github.com/rust-lang/rust-clippy/compare/0f8eabd6...master)
9+
[aa0d5513...master](https://github.com/rust-lang/rust-clippy/compare/aa0d5513...master)
10+
11+
## Rust 1.83
12+
13+
Current stable, released 2024-11-28
14+
15+
[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)
16+
17+
### Important Change
18+
19+
* Removed the implicit `cargo-clippy` feature set by Clippy as announced here:
20+
<https://blog.rust-lang.org/2024/02/28/Clippy-deprecating-feature-cargo-clippy.html>
21+
[#13246](https://github.com/rust-lang/rust-clippy/pull/13246)
22+
23+
### New Lints
24+
25+
* Added [`unused_trait_names`] to `restriction`
26+
[#13322](https://github.com/rust-lang/rust-clippy/pull/13322)
27+
* Added [`unnecessary_first_then_check`] to `complexity`
28+
[#13421](https://github.com/rust-lang/rust-clippy/pull/13421)
29+
* Added [`non_zero_suggestions`] to `restriction`
30+
[#13167](https://github.com/rust-lang/rust-clippy/pull/13167)
31+
* Added [`manual_is_power_of_two`] to `pedantic`
32+
[#13327](https://github.com/rust-lang/rust-clippy/pull/13327)
33+
* Added [`manual_div_ceil`] to `complexity`
34+
[#12987](https://github.com/rust-lang/rust-clippy/pull/12987)
35+
* Added [`zombie_processes`] to `suspicious`
36+
[#11476](https://github.com/rust-lang/rust-clippy/pull/11476)
37+
* Added [`used_underscore_items`] to `pedantic`
38+
[#13294](https://github.com/rust-lang/rust-clippy/pull/13294)
39+
40+
### Moves and Deprecations
41+
42+
* Moved [`ref_option`] to `pedantic` (From `nursery`)
43+
[#13469](https://github.com/rust-lang/rust-clippy/pull/13469)
44+
* Moved [`manual_c_str_literals`] to `complexity` (From `pedantic`, now warn-by-default)
45+
[#13263](https://github.com/rust-lang/rust-clippy/pull/13263)
46+
* Moved [`empty_line_after_doc_comments`] to `suspicious` (From `nursery`, now warn-by-default)
47+
[#13091](https://github.com/rust-lang/rust-clippy/pull/13091)
48+
* Moved [`empty_line_after_outer_attr`] to `suspicious` (From `nursery`, now warn-by-default)
49+
[#13091](https://github.com/rust-lang/rust-clippy/pull/13091)
50+
51+
### Enhancements
52+
53+
* [`missing_panics_doc`]: No longer lints in const environments
54+
[#13382](https://github.com/rust-lang/rust-clippy/pull/13382)
1055

1156
## Rust 1.82
1257

13-
Current stable, released 2024-10-17
58+
Released 2024-10-17
1459

1560
[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)
1661

@@ -5441,6 +5486,7 @@ Released 2018-09-13
54415486
[`disallowed_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_type
54425487
[`disallowed_types`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types
54435488
[`diverging_sub_expression`]: https://rust-lang.github.io/rust-clippy/master/index.html#diverging_sub_expression
5489+
[`doc_include_without_cfg`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_include_without_cfg
54445490
[`doc_lazy_continuation`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation
54455491
[`doc_link_with_quotes`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_link_with_quotes
54465492
[`doc_markdown`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown

src/tools/clippy/Cargo.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.84"
3+
# begin autogenerated version
4+
version = "0.1.85"
5+
# end autogenerated version
46
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
57
repository = "https://github.com/rust-lang/rust-clippy"
68
readme = "README.md"
@@ -27,7 +29,7 @@ rustc_tools_util = "0.4.0"
2729
tempfile = { version = "3.3", optional = true }
2830
termize = "0.1"
2931
color-print = "0.3.4"
30-
anstream = "0.6.0"
32+
anstream = "0.6.18"
3133

3234
[dev-dependencies]
3335
cargo_metadata = "0.18.1"

src/tools/clippy/book/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [Configuration](configuration.md)
88
- [Lint Configuration](lint_configuration.md)
99
- [Clippy's Lints](lints.md)
10+
- [Attributes for Crate Authors](attribs.md)
1011
- [Continuous Integration](continuous_integration/README.md)
1112
- [GitHub Actions](continuous_integration/github_actions.md)
1213
- [GitLab CI](continuous_integration/gitlab.md)

src/tools/clippy/book/src/attribs.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Attributes for Crate Authors
2+
3+
In some cases it is possible to extend Clippy coverage to 3rd party libraries.
4+
To do this, Clippy provides attributes that can be applied to items in the 3rd party crate.
5+
6+
## `#[clippy::format_args]`
7+
8+
_Available since Clippy v1.84_
9+
10+
This attribute can be added to a macro that supports `format!`, `println!`, or similar syntax.
11+
It tells Clippy that the macro is a formatting macro, and that the arguments to the macro
12+
should be linted as if they were arguments to `format!`. Any lint that would apply to a
13+
`format!` call will also apply to the macro call. The macro may have additional arguments
14+
before the format string, and these will be ignored.
15+
16+
### Example
17+
18+
```rust
19+
/// A macro that prints a message if a condition is true.
20+
#[macro_export]
21+
#[clippy::format_args]
22+
macro_rules! print_if {
23+
($condition:expr, $($args:tt)+) => {{
24+
if $condition {
25+
println!($($args)+)
26+
}
27+
}};
28+
}
29+
```
30+
31+
## `#[clippy::has_significant_drop]`
32+
33+
_Available since Clippy v1.60_
34+
35+
The `clippy::has_significant_drop` attribute can be added to types whose Drop impls have an important side effect,
36+
such as unlocking a mutex, making it important for users to be able to accurately understand their lifetimes.
37+
When a temporary is returned in a function call in a match scrutinee, its lifetime lasts until the end of the match
38+
block, which may be surprising.
39+
40+
### Example
41+
42+
```rust
43+
#[clippy::has_significant_drop]
44+
struct CounterWrapper<'a> {
45+
counter: &'a Counter,
46+
}
47+
48+
impl<'a> Drop for CounterWrapper<'a> {
49+
fn drop(&mut self) {
50+
self.counter.i.fetch_sub(1, Ordering::Relaxed);
51+
}
52+
}
53+
```

src/tools/clippy/book/src/development/adding_lints.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ need to ensure that the MSRV configured for the project is >= the MSRV of the
438438
required Rust feature. If multiple features are required, just use the one with
439439
a lower MSRV.
440440

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

444444
```rust
@@ -517,7 +517,7 @@ define_Conf! {
517517
}
518518
```
519519

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

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

src/tools/clippy/book/src/lint_configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ The order of associated items in traits.
895895

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

900900
**Default Value:** `target_pointer_width * 2`
901901

src/tools/clippy/clippy_config/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
[package]
22
name = "clippy_config"
3-
version = "0.1.84"
3+
# begin autogenerated version
4+
version = "0.1.85"
5+
# end autogenerated version
46
edition = "2021"
7+
publish = false
58

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

811
[dependencies]
12+
clippy_utils = { path = "../clippy_utils" }
913
itertools = "0.12"
1014
serde = { version = "1.0", features = ["derive"] }
1115
toml = "0.7.3"

src/tools/clippy/clippy_config/src/conf.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use crate::ClippyConfiguration;
2-
use crate::msrvs::Msrv;
32
use crate::types::{
43
DisallowedPath, MacroMatcher, MatchLintBehaviour, PubUnderscoreFieldsBehaviour, Rename, SourceItemOrdering,
54
SourceItemOrderingCategory, SourceItemOrderingModuleItemGroupings, SourceItemOrderingModuleItemKind,
65
SourceItemOrderingTraitAssocItemKind, SourceItemOrderingTraitAssocItemKinds,
76
};
7+
use clippy_utils::msrvs::Msrv;
88
use rustc_errors::Applicability;
99
use rustc_session::Session;
1010
use rustc_span::edit_distance::edit_distance;
@@ -181,7 +181,7 @@ macro_rules! define_Conf {
181181
)*) => {
182182
/// Clippy lint configuration
183183
pub struct Conf {
184-
$($(#[doc = $doc])+ pub $name: $ty,)*
184+
$($(#[cfg_attr(doc, doc = $doc)])+ pub $name: $ty,)*
185185
}
186186

187187
mod defaults {
@@ -678,7 +678,7 @@ define_Conf! {
678678
#[lints(arbitrary_source_item_ordering)]
679679
trait_assoc_item_kinds_order: SourceItemOrderingTraitAssocItemKinds = DEFAULT_TRAIT_ASSOC_ITEM_KINDS_ORDER.into(),
680680
/// The maximum size (in bytes) to consider a `Copy` type for passing by value instead of by
681-
/// reference. By default there is no limit
681+
/// reference.
682682
#[default_text = "target_pointer_width * 2"]
683683
#[lints(trivially_copy_pass_by_ref)]
684684
trivial_copy_size_limit: Option<u64> = None,

src/tools/clippy/clippy_config/src/lib.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,14 @@
1313
rustc::untranslatable_diagnostic
1414
)]
1515

16-
extern crate rustc_ast;
17-
extern crate rustc_attr;
18-
#[allow(unused_extern_crates)]
19-
extern crate rustc_driver;
2016
extern crate rustc_errors;
17+
extern crate rustc_hir;
18+
extern crate rustc_middle;
2119
extern crate rustc_session;
2220
extern crate rustc_span;
23-
extern crate smallvec;
2421

2522
mod conf;
2623
mod metadata;
27-
pub mod msrvs;
2824
pub mod types;
2925

3026
pub use conf::{Conf, get_configuration_metadata, lookup_conf_file, sanitize_explanation};

src/tools/clippy/clippy_config/src/types.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use clippy_utils::def_path_def_ids;
2+
use rustc_hir::def_id::DefIdMap;
3+
use rustc_middle::ty::TyCtxt;
14
use serde::de::{self, Deserializer, Visitor};
25
use serde::{Deserialize, Serialize, ser};
36
use std::collections::HashMap;
@@ -31,6 +34,18 @@ impl DisallowedPath {
3134
}
3235
}
3336

37+
/// Creates a map of disallowed items to the reason they were disallowed.
38+
pub fn create_disallowed_map(
39+
tcx: TyCtxt<'_>,
40+
disallowed: &'static [DisallowedPath],
41+
) -> DefIdMap<(&'static str, Option<&'static str>)> {
42+
disallowed
43+
.iter()
44+
.map(|x| (x.path(), x.path().split("::").collect::<Vec<_>>(), x.reason()))
45+
.flat_map(|(name, path, reason)| def_path_def_ids(tcx, &path).map(move |id| (id, (name, reason))))
46+
.collect()
47+
}
48+
3449
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
3550
pub enum MatchLintBehaviour {
3651
AllTypes,

src/tools/clippy/clippy_dev/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2021"
66

77
[dependencies]
88
aho-corasick = "1.0"
9+
chrono = { version = "0.4.38", default-features = false, features = ["clock"] }
910
clap = { version = "4.4", features = ["derive"] }
1011
indoc = "1.0"
1112
itertools = "0.12"

src/tools/clippy/clippy_dev/src/dogfood.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{clippy_project_root, exit_if_err};
1+
use crate::utils::{clippy_project_root, exit_if_err};
22
use std::process::Command;
33

44
/// # Panics

src/tools/clippy/clippy_dev/src/fmt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::clippy_project_root;
1+
use crate::utils::clippy_project_root;
22
use itertools::Itertools;
33
use rustc_lexer::{TokenKind, tokenize};
44
use shell_escape::escape;

0 commit comments

Comments
 (0)