Skip to content

Commit 6c3f43d

Browse files
committed
Merge commit '0f8eabd6231366bfc1bb1464601297c2d48f8f68' into clippyup
2 parents edbc000 + 0f8eabd commit 6c3f43d

File tree

217 files changed

+3046
-2970
lines changed

Some content is hidden

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

217 files changed

+3046
-2970
lines changed

Diff for: Cargo.lock

+2-9
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ name = "clippy"
539539
version = "0.1.82"
540540
dependencies = [
541541
"anstream",
542+
"cargo_metadata 0.18.1",
542543
"clippy_config",
543544
"clippy_lints",
544545
"clippy_utils",
@@ -552,6 +553,7 @@ dependencies = [
552553
"regex",
553554
"rustc_tools_util",
554555
"serde",
556+
"serde_json",
555557
"syn 2.0.75",
556558
"tempfile",
557559
"termize",
@@ -566,7 +568,6 @@ name = "clippy_config"
566568
version = "0.1.82"
567569
dependencies = [
568570
"itertools",
569-
"rustc-semver",
570571
"serde",
571572
"toml 0.7.8",
572573
"walkdir",
@@ -598,7 +599,6 @@ dependencies = [
598599
"quine-mc_cluskey",
599600
"regex",
600601
"regex-syntax 0.8.4",
601-
"rustc-semver",
602602
"semver",
603603
"serde",
604604
"serde_json",
@@ -617,7 +617,6 @@ dependencies = [
617617
"arrayvec",
618618
"clippy_config",
619619
"itertools",
620-
"rustc-semver",
621620
"rustc_apfloat",
622621
]
623622

@@ -3202,12 +3201,6 @@ dependencies = [
32023201
"num_cpus",
32033202
]
32043203

3205-
[[package]]
3206-
name = "rustc-semver"
3207-
version = "1.1.0"
3208-
source = "registry+https://github.com/rust-lang/crates.io-index"
3209-
checksum = "5be1bdc7edf596692617627bbfeaba522131b18e06ca4df2b6b689e3c5d5ce84"
3210-
32113204
[[package]]
32123205
name = "rustc-stable-hash"
32133206
version = "0.1.0"

Diff for: src/tools/clippy/.cargo/config.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[alias]
2+
bless = "test --config env.RUSTC_BLESS='1'"
23
uitest = "test --test compile-test"
3-
uibless = "test --test compile-test -- -- --bless"
4-
bless = "test -- -- --bless"
4+
uibless = "bless --test compile-test"
55
dev = "run --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
66
lintcheck = "run --package lintcheck --bin lintcheck --manifest-path lintcheck/Cargo.toml -- "
7-
collect-metadata = "test --test dogfood --features internal -- collect_metadata"
7+
collect-metadata = "test --test compile-test --config env.COLLECT_METADATA='1'"
88

99
[build]
1010
# -Zbinary-dep-depinfo allows us to track which rlib files to use for compiling UI tests

Diff for: src/tools/clippy/.github/deploy.sh

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mkdir out/master/
1010
cp util/gh-pages/index.html out/master
1111
cp util/gh-pages/script.js out/master
1212
cp util/gh-pages/lints.json out/master
13+
cp util/gh-pages/style.css out/master
1314

1415
if [[ -n $TAG_NAME ]]; then
1516
echo "Save the doc for the current tag ($TAG_NAME) and point stable/ to it"

Diff for: src/tools/clippy/.github/workflows/clippy_bors.yml

-5
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,6 @@ jobs:
136136
- name: Test metadata collection
137137
run: cargo collect-metadata
138138

139-
- name: Test lint_configuration.md is up-to-date
140-
run: |
141-
echo "run \`cargo collect-metadata\` if this fails"
142-
git update-index --refresh
143-
144139
integration_build:
145140
needs: changelog
146141
runs-on: ubuntu-latest

Diff for: src/tools/clippy/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5914,6 +5914,7 @@ Released 2018-09-13
59145914
[`to_string_in_format_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args
59155915
[`to_string_trait_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_trait_impl
59165916
[`todo`]: https://rust-lang.github.io/rust-clippy/master/index.html#todo
5917+
[`too_long_first_doc_paragraph`]: https://rust-lang.github.io/rust-clippy/master/index.html#too_long_first_doc_paragraph
59175918
[`too_many_arguments`]: https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
59185919
[`too_many_lines`]: https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines
59195920
[`toplevel_ref_arg`]: https://rust-lang.github.io/rust-clippy/master/index.html#toplevel_ref_arg

Diff for: src/tools/clippy/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ color-print = "0.3.4"
3030
anstream = "0.6.0"
3131

3232
[dev-dependencies]
33+
cargo_metadata = "0.18.1"
3334
ui_test = "0.25"
3435
regex = "1.5.5"
36+
serde = { version = "1.0.145", features = ["derive"] }
37+
serde_json = "1.0.122"
3538
toml = "0.7.3"
3639
walkdir = "2.3"
3740
filetime = "0.2.9"
@@ -41,7 +44,6 @@ itertools = "0.12"
4144
clippy_utils = { path = "clippy_utils" }
4245
if_chain = "1.0"
4346
quote = "1.0.25"
44-
serde = { version = "1.0.145", features = ["derive"] }
4547
syn = { version = "2.0", features = ["full"] }
4648
futures = "0.3"
4749
parking_lot = "0.12"

Diff for: src/tools/clippy/book/src/development/adding_lints.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ for some users. Adding a configuration is done in the following steps:
739739

740740
5. Update [Lint Configuration](../lint_configuration.md)
741741

742-
Run `cargo collect-metadata` to generate documentation changes for the book.
742+
Run `cargo bless --test config-metadata` to generate documentation changes for the book.
743743

744744
[`clippy_config::conf`]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_config/src/conf.rs
745745
[`clippy_lints` lib file]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/lib.rs

Diff for: src/tools/clippy/book/src/lint_configuration.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
This file is generated by `cargo collect-metadata`.
2+
This file is generated by `cargo bless --test config-metadata`.
33
Please use that command to update the file and do not edit it by hand.
44
-->
55

@@ -199,7 +199,7 @@ Allowed names below the minimum allowed characters. The value `".."` can be used
199199
the list to indicate, that the configured values should be appended to the default
200200
configuration of Clippy. By default, any configuration will replace the default value.
201201

202-
**Default Value:** `["j", "z", "i", "y", "n", "x", "w"]`
202+
**Default Value:** `["i", "j", "x", "y", "z", "w", "n"]`
203203

204204
---
205205
**Affected lints:**
@@ -455,7 +455,7 @@ default configuration of Clippy. By default, any configuration will replace the
455455
* `doc-valid-idents = ["ClipPy"]` would replace the default list with `["ClipPy"]`.
456456
* `doc-valid-idents = ["ClipPy", ".."]` would append `ClipPy` to the default list.
457457

458-
**Default Value:** `["TiB", "CoreGraphics", "CoffeeScript", "TeX", "Direct2D", "PiB", "DirectX", "NetBSD", "OAuth", "NaN", "OpenType", "WebGL2", "WebTransport", "JavaScript", "OpenSSL", "OpenSSH", "EiB", "PureScript", "OpenAL", "MiB", "WebAssembly", "MinGW", "CoreFoundation", "WebGPU", "ClojureScript", "CamelCase", "OpenDNS", "NaNs", "OpenMP", "GitLab", "KiB", "sRGB", "CoreText", "macOS", "TypeScript", "GiB", "OpenExr", "YCbCr", "OpenTelemetry", "OpenBSD", "FreeBSD", "GPLv2", "PostScript", "WebP", "LaTeX", "TensorFlow", "AccessKit", "TrueType", "OpenStreetMap", "OpenGL", "DevOps", "OCaml", "WebRTC", "WebGL", "BibLaTeX", "GitHub", "GraphQL", "iOS", "Direct3D", "BibTeX", "DirectWrite", "GPLv3", "IPv6", "WebSocket", "IPv4", "ECMAScript"]`
458+
**Default Value:** `["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "AccessKit", "CoreFoundation", "CoreGraphics", "CoreText", "DevOps", "Direct2D", "Direct3D", "DirectWrite", "DirectX", "ECMAScript", "GPLv2", "GPLv3", "GitHub", "GitLab", "IPv4", "IPv6", "ClojureScript", "CoffeeScript", "JavaScript", "PostScript", "PureScript", "TypeScript", "WebAssembly", "NaN", "NaNs", "OAuth", "GraphQL", "OCaml", "OpenAL", "OpenDNS", "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenTelemetry", "OpenType", "WebGL", "WebGL2", "WebGPU", "WebRTC", "WebSocket", "WebTransport", "WebP", "OpenExr", "YCbCr", "sRGB", "TensorFlow", "TrueType", "iOS", "macOS", "FreeBSD", "NetBSD", "OpenBSD", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "CamelCase"]`
459459

460460
---
461461
**Affected lints:**
@@ -949,5 +949,3 @@ Whether to also emit warnings for unsafe blocks with metavariable expansions in
949949
---
950950
**Affected lints:**
951951
* [`macro_metavars_in_unsafe`](https://rust-lang.github.io/rust-clippy/master/index.html#macro_metavars_in_unsafe)
952-
953-

Diff for: src/tools/clippy/clippy_config/Cargo.toml

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

88
[dependencies]
99
itertools = "0.12"
10-
rustc-semver = "1.1"
1110
serde = { version = "1.0", features = ["derive"] }
1211
toml = "0.7.3"
1312

Diff for: src/tools/clippy/clippy_config/src/conf.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::msrvs::Msrv;
22
use crate::types::{DisallowedPath, MacroMatcher, MatchLintBehaviour, PubUnderscoreFieldsBehaviour, Rename};
33
use crate::ClippyConfiguration;
4-
use rustc_data_structures::fx::FxHashSet;
54
use rustc_errors::Applicability;
65
use rustc_session::Session;
76
use rustc_span::edit_distance::edit_distance;
@@ -218,7 +217,7 @@ macro_rules! define_Conf {
218217
define_Conf! {
219218
/// Which crates to allow absolute paths from
220219
#[lints(absolute_paths)]
221-
absolute_paths_allowed_crates: FxHashSet<String> = FxHashSet::default(),
220+
absolute_paths_allowed_crates: Vec<String> = Vec::new(),
222221
/// The maximum number of segments a path can have before being linted, anything above this will
223222
/// be linted.
224223
#[lints(absolute_paths)]
@@ -280,12 +279,12 @@ define_Conf! {
280279
allowed_dotfiles: Vec<String> = Vec::default(),
281280
/// A list of crate names to allow duplicates of
282281
#[lints(multiple_crate_versions)]
283-
allowed_duplicate_crates: FxHashSet<String> = FxHashSet::default(),
282+
allowed_duplicate_crates: Vec<String> = Vec::new(),
284283
/// Allowed names below the minimum allowed characters. The value `".."` can be used as part of
285284
/// the list to indicate, that the configured values should be appended to the default
286285
/// configuration of Clippy. By default, any configuration will replace the default value.
287286
#[lints(min_ident_chars)]
288-
allowed_idents_below_min_chars: FxHashSet<String> =
287+
allowed_idents_below_min_chars: Vec<String> =
289288
DEFAULT_ALLOWED_IDENTS_BELOW_MIN_CHARS.iter().map(ToString::to_string).collect(),
290289
/// List of prefixes to allow when determining whether an item's name ends with the module's name.
291290
/// If the rest of an item's name is an allowed prefix (e.g. item `ToFoo` or `to_foo` in module `foo`),
@@ -323,7 +322,7 @@ define_Conf! {
323322
/// 2. Paths with any segment that containing the word 'prelude'
324323
/// are already allowed by default.
325324
#[lints(wildcard_imports)]
326-
allowed_wildcard_imports: FxHashSet<String> = FxHashSet::default(),
325+
allowed_wildcard_imports: Vec<String> = Vec::new(),
327326
/// Suppress checking of the passed type names in all types of operations.
328327
///
329328
/// If a specific operation is desired, consider using `arithmetic_side_effects_allowed_binary` or `arithmetic_side_effects_allowed_unary` instead.
@@ -355,7 +354,7 @@ define_Conf! {
355354
/// arithmetic-side-effects-allowed-binary = [["SomeType" , "f32"], ["AnotherType", "*"]]
356355
/// ```
357356
#[lints(arithmetic_side_effects)]
358-
arithmetic_side_effects_allowed_binary: Vec<[String; 2]> = <_>::default(),
357+
arithmetic_side_effects_allowed_binary: Vec<(String, String)> = <_>::default(),
359358
/// Suppress checking of the passed type names in unary operations like "negation" (`-`).
360359
///
361360
/// #### Example
@@ -431,7 +430,7 @@ define_Conf! {
431430
/// * `doc-valid-idents = ["ClipPy"]` would replace the default list with `["ClipPy"]`.
432431
/// * `doc-valid-idents = ["ClipPy", ".."]` would append `ClipPy` to the default list.
433432
#[lints(doc_markdown)]
434-
doc_valid_idents: FxHashSet<String> = DEFAULT_DOC_VALID_IDENTS.iter().map(ToString::to_string).collect(),
433+
doc_valid_idents: Vec<String> = DEFAULT_DOC_VALID_IDENTS.iter().map(ToString::to_string).collect(),
435434
/// Whether to apply the raw pointer heuristic to determine if a type is `Send`.
436435
#[lints(non_send_fields_in_send_ty)]
437436
enable_raw_pointer_heuristic_for_send: bool = true,
@@ -706,12 +705,12 @@ fn deserialize(file: &SourceFile) -> TryConf {
706705
DEFAULT_ALLOWED_TRAITS_WITH_RENAMED_PARAMS,
707706
);
708707
// TODO: THIS SHOULD BE TESTED, this comment will be gone soon
709-
if conf.conf.allowed_idents_below_min_chars.contains("..") {
708+
if conf.conf.allowed_idents_below_min_chars.iter().any(|e| e == "..") {
710709
conf.conf
711710
.allowed_idents_below_min_chars
712711
.extend(DEFAULT_ALLOWED_IDENTS_BELOW_MIN_CHARS.iter().map(ToString::to_string));
713712
}
714-
if conf.conf.doc_valid_idents.contains("..") {
713+
if conf.conf.doc_valid_idents.iter().any(|e| e == "..") {
715714
conf.conf
716715
.doc_valid_idents
717716
.extend(DEFAULT_DOC_VALID_IDENTS.iter().map(ToString::to_string));
@@ -890,14 +889,14 @@ fn calculate_dimensions(fields: &[&str]) -> (usize, Vec<usize>) {
890889

891890
#[cfg(test)]
892891
mod tests {
893-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
894892
use serde::de::IgnoredAny;
893+
use std::collections::{HashMap, HashSet};
895894
use std::fs;
896895
use walkdir::WalkDir;
897896

898897
#[test]
899898
fn configs_are_tested() {
900-
let mut names: FxHashSet<String> = crate::get_configuration_metadata()
899+
let mut names: HashSet<String> = crate::get_configuration_metadata()
901900
.into_iter()
902901
.map(|meta| meta.name.replace('_', "-"))
903902
.collect();
@@ -910,7 +909,7 @@ mod tests {
910909
for entry in toml_files {
911910
let file = fs::read_to_string(entry.path()).unwrap();
912911
#[allow(clippy::zero_sized_map_values)]
913-
if let Ok(map) = toml::from_str::<FxHashMap<String, IgnoredAny>>(&file) {
912+
if let Ok(map) = toml::from_str::<HashMap<String, IgnoredAny>>(&file) {
914913
for name in map.keys() {
915914
names.remove(name.as_str());
916915
}

Diff for: src/tools/clippy/clippy_config/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
)]
1515

1616
extern crate rustc_ast;
17-
extern crate rustc_data_structures;
17+
extern crate rustc_attr;
1818
#[allow(unused_extern_crates)]
1919
extern crate rustc_driver;
2020
extern crate rustc_errors;

Diff for: src/tools/clippy/clippy_config/src/msrvs.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_ast::Attribute;
2-
use rustc_semver::RustcVersion;
3-
use rustc_session::Session;
2+
use rustc_attr::parse_version;
3+
use rustc_session::{RustcVersion, Session};
44
use rustc_span::{sym, Symbol};
55
use serde::Deserialize;
66
use std::fmt;
@@ -10,14 +10,15 @@ macro_rules! msrv_aliases {
1010
$($name:ident),* $(,)?
1111
})*) => {
1212
$($(
13-
pub const $name: RustcVersion = RustcVersion::new($major, $minor, $patch);
13+
pub const $name: RustcVersion = RustcVersion { major: $major, minor :$minor, patch: $patch };
1414
)*)*
1515
};
1616
}
1717

1818
// names may refer to stabilized feature flags or library items
1919
msrv_aliases! {
2020
1,81,0 { LINT_REASONS_STABILIZATION }
21+
1,80,0 { BOX_INTO_ITER}
2122
1,77,0 { C_STR_LITERALS }
2223
1,76,0 { PTR_FROM_REF, OPTION_RESULT_INSPECT }
2324
1,71,0 { TUPLE_ARRAY_CONVERSIONS, BUILD_HASHER_HASH_ONE }
@@ -81,9 +82,9 @@ impl<'de> Deserialize<'de> for Msrv {
8182
D: serde::Deserializer<'de>,
8283
{
8384
let v = String::deserialize(deserializer)?;
84-
RustcVersion::parse(&v)
85+
parse_version(Symbol::intern(&v))
8586
.map(|v| Msrv { stack: vec![v] })
86-
.map_err(|_| serde::de::Error::custom("not a valid Rust version"))
87+
.ok_or_else(|| serde::de::Error::custom("not a valid Rust version"))
8788
}
8889
}
8990

@@ -95,7 +96,7 @@ impl Msrv {
9596
pub fn read_cargo(&mut self, sess: &Session) {
9697
let cargo_msrv = std::env::var("CARGO_PKG_RUST_VERSION")
9798
.ok()
98-
.and_then(|v| RustcVersion::parse(&v).ok());
99+
.and_then(|v| parse_version(Symbol::intern(&v)));
99100

100101
match (self.current(), cargo_msrv) {
101102
(None, Some(cargo_msrv)) => self.stack = vec![cargo_msrv],
@@ -115,7 +116,7 @@ impl Msrv {
115116
}
116117

117118
pub fn meets(&self, required: RustcVersion) -> bool {
118-
self.current().map_or(true, |version| version.meets(required))
119+
self.current().map_or(true, |msrv| msrv >= required)
119120
}
120121

121122
fn parse_attr(sess: &Session, attrs: &[Attribute]) -> Option<RustcVersion> {
@@ -131,7 +132,7 @@ impl Msrv {
131132
}
132133

133134
if let Some(msrv) = msrv_attr.value_str() {
134-
if let Ok(version) = RustcVersion::parse(msrv.as_str()) {
135+
if let Some(version) = parse_version(msrv) {
135136
return Some(version);
136137
}
137138

Diff for: src/tools/clippy/clippy_dev/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(rustc_private)]
12
// warn on lints, that are included in `rust-lang/rust`s bootstrap
23
#![warn(rust_2018_idioms, unused_lifetimes)]
34

Diff for: src/tools/clippy/clippy_dev/src/update_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ fn gen_declared_lints<'a>(
604604
details.sort_unstable();
605605

606606
let mut output = GENERATED_FILE_COMMENT.to_string();
607-
output.push_str("pub(crate) static LINTS: &[&crate::LintInfo] = &[\n");
607+
output.push_str("pub static LINTS: &[&crate::LintInfo] = &[\n");
608608

609609
for (is_public, module_name, lint_name) in details {
610610
if !is_public {

Diff for: src/tools/clippy/clippy_lints/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ regex = { version = "1.5", optional = true }
2525
unicode-normalization = "0.1"
2626
unicode-script = { version = "0.5", default-features = false }
2727
semver = "1.0"
28-
rustc-semver = "1.1"
2928
url = "2.2"
3029

3130
[dev-dependencies]

0 commit comments

Comments
 (0)