Skip to content

Commit

Permalink
Auto merge of rust-lang#133588 - 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 Nov 29, 2024
2 parents a45391f + 315b47e commit d10a682
Show file tree
Hide file tree
Showing 196 changed files with 1,965 additions and 652 deletions.
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

0 comments on commit d10a682

Please sign in to comment.