Skip to content

Commit 849a19f

Browse files
committed
Merge commit 'a109190d7060236e655fc75533373fa274ec5343' into clippy-subtree-update
2 parents acfdb8d + a109190 commit 849a19f

File tree

179 files changed

+4025
-1745
lines changed

Some content is hidden

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

179 files changed

+4025
-1745
lines changed

src/tools/clippy/.github/deploy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ rm -rf out/master/ || exit 0
88
echo "Making the docs for master"
99
mkdir out/master/
1010
cp util/gh-pages/index.html out/master
11+
cp util/gh-pages/theme.js out/master
1112
cp util/gh-pages/script.js out/master
12-
cp util/gh-pages/lints.json out/master
1313
cp util/gh-pages/style.css out/master
1414

1515
if [[ -n $TAG_NAME ]]; then

src/tools/clippy/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ out
3434

3535
# gh pages docs
3636
util/gh-pages/lints.json
37+
util/gh-pages/index.html
3738

3839
# rustfmt backups
3940
*.rs.bk

src/tools/clippy/CHANGELOG.md

+40-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,46 @@ document.
66

77
## Unreleased / Beta / In Rust Nightly
88

9-
[b794b8e0...master](https://github.com/rust-lang/rust-clippy/compare/b794b8e0...master)
9+
[0f8eabd6...master](https://github.com/rust-lang/rust-clippy/compare/0f8eabd6...master)
10+
11+
## Rust 1.82
12+
13+
Current stable, released 2024-10-17
14+
15+
[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)
16+
17+
### New Lints
18+
19+
* Added [`too_long_first_doc_paragraph`] to `nursery`
20+
[#12993](https://github.com/rust-lang/rust-clippy/pull/12993)
21+
* Added [`unused_result_ok`] to `restriction`
22+
[#12150](https://github.com/rust-lang/rust-clippy/pull/12150)
23+
* Added [`pathbuf_init_then_push`] to `restriction`
24+
[#11700](https://github.com/rust-lang/rust-clippy/pull/11700)
25+
26+
### Enhancements
27+
28+
* [`explicit_iter_loop`]: Now respects the `msrv` configuration
29+
[#13288](https://github.com/rust-lang/rust-clippy/pull/13288)
30+
* [`assigning_clones`]: No longer lints in test code
31+
[#13273](https://github.com/rust-lang/rust-clippy/pull/13273)
32+
* [`inconsistent_struct_constructor`]: Lint attributes now work on the struct definition
33+
[#13211](https://github.com/rust-lang/rust-clippy/pull/13211)
34+
* [`set_contains_or_insert`]: Now also checks for `BTreeSet`
35+
[#13053](https://github.com/rust-lang/rust-clippy/pull/13053)
36+
* [`doc_markdown`]: Added the following identifiers to [`doc-valid-idents`]: AccessKit,
37+
CoreFoundation, CoreGraphics, CoreText, Direct2D, Direct3D, DirectWrite, PostScript,
38+
OpenAL, OpenType, WebRTC, WebSocket, WebTransport, NetBSD, and OpenBSD
39+
[#13093](https://github.com/rust-lang/rust-clippy/pull/13093)
40+
41+
### ICE Fixes
42+
43+
* [`uninit_vec`]
44+
[rust#128720](https://github.com/rust-lang/rust/pull/128720)
1045

1146
## Rust 1.81
1247

13-
Current stable, released 2024-09-05
48+
Released 2024-09-05
1449

1550
### New Lints
1651

@@ -5621,6 +5656,7 @@ Released 2018-09-13
56215656
[`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map
56225657
[`manual_flatten`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten
56235658
[`manual_hash_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_hash_one
5659+
[`manual_ignore_case_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ignore_case_cmp
56245660
[`manual_inspect`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect
56255661
[`manual_instant_elapsed`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_instant_elapsed
56265662
[`manual_is_ascii_check`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check
@@ -5874,6 +5910,7 @@ Released 2018-09-13
58745910
[`ref_option`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_option
58755911
[`ref_option_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_option_ref
58765912
[`ref_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_patterns
5913+
[`regex_creation_in_loops`]: https://rust-lang.github.io/rust-clippy/master/index.html#regex_creation_in_loops
58775914
[`regex_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#regex_macro
58785915
[`renamed_function_params`]: https://rust-lang.github.io/rust-clippy/master/index.html#renamed_function_params
58795916
[`repeat_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#repeat_once
@@ -6027,6 +6064,7 @@ Released 2018-09-13
60276064
[`unnecessary_get_then_check`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
60286065
[`unnecessary_join`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_join
60296066
[`unnecessary_lazy_evaluations`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
6067+
[`unnecessary_literal_bound`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_bound
60306068
[`unnecessary_literal_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_unwrap
60316069
[`unnecessary_map_on_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_on_constructor
60326070
[`unnecessary_min_or_max`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_min_or_max

src/tools/clippy/Cargo.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.83"
3+
version = "0.1.84"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"
@@ -23,7 +23,7 @@ path = "src/driver.rs"
2323
[dependencies]
2424
clippy_config = { path = "clippy_config" }
2525
clippy_lints = { path = "clippy_lints" }
26-
rustc_tools_util = "0.3.0"
26+
rustc_tools_util = "0.4.0"
2727
tempfile = { version = "3.3", optional = true }
2828
termize = "0.1"
2929
color-print = "0.3.4"
@@ -39,6 +39,8 @@ toml = "0.7.3"
3939
walkdir = "2.3"
4040
filetime = "0.2.9"
4141
itertools = "0.12"
42+
pulldown-cmark = "0.11"
43+
rinja = { version = "0.3", default-features = false, features = ["config"] }
4244

4345
# UI test dependencies
4446
clippy_utils = { path = "clippy_utils" }
@@ -50,7 +52,7 @@ parking_lot = "0.12"
5052
tokio = { version = "1", features = ["io-util"] }
5153

5254
[build-dependencies]
53-
rustc_tools_util = "0.3.0"
55+
rustc_tools_util = "0.4.0"
5456

5557
[features]
5658
integration = ["tempfile"]

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ arithmetic-side-effects-allowed-unary = ["SomeType", "AnotherType"]
329329
## `array-size-threshold`
330330
The maximum allowed size for arrays on the stack
331331

332-
**Default Value:** `512000`
332+
**Default Value:** `16384`
333333

334334
---
335335
**Affected lints:**

src/tools/clippy/clippy_config/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_config"
3-
version = "0.1.83"
3+
version = "0.1.84"
44
edition = "2021"
55

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

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

+25-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,30 @@ impl ConfError {
9797
}
9898
}
9999

100+
// Remove code tags and code behind '# 's, as they are not needed for the lint docs and --explain
101+
pub fn sanitize_explanation(raw_docs: &str) -> String {
102+
// Remove tags and hidden code:
103+
let mut explanation = String::with_capacity(128);
104+
let mut in_code = false;
105+
for line in raw_docs.lines().map(str::trim) {
106+
if let Some(lang) = line.strip_prefix("```") {
107+
let tag = lang.split_once(',').map_or(lang, |(left, _)| left);
108+
if !in_code && matches!(tag, "" | "rust" | "ignore" | "should_panic" | "no_run" | "compile_fail") {
109+
explanation += "```rust\n";
110+
} else {
111+
explanation += line;
112+
explanation.push('\n');
113+
}
114+
in_code = !in_code;
115+
} else if !(in_code && line.starts_with("# ")) {
116+
explanation += line;
117+
explanation.push('\n');
118+
}
119+
}
120+
121+
explanation
122+
}
123+
100124
macro_rules! wrap_option {
101125
() => {
102126
None
@@ -366,7 +390,7 @@ define_Conf! {
366390
arithmetic_side_effects_allowed_unary: Vec<String> = <_>::default(),
367391
/// The maximum allowed size for arrays on the stack
368392
#[lints(large_const_arrays, large_stack_arrays)]
369-
array_size_threshold: u64 = 512_000,
393+
array_size_threshold: u64 = 16 * 1024,
370394
/// Suppress lints whenever the suggested change would cause breakage for other crates.
371395
#[lints(
372396
box_collection,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ mod metadata;
2626
pub mod msrvs;
2727
pub mod types;
2828

29-
pub use conf::{Conf, get_configuration_metadata, lookup_conf_file};
29+
pub use conf::{Conf, get_configuration_metadata, lookup_conf_file, sanitize_explanation};
3030
pub use metadata::ClippyConfiguration;

src/tools/clippy/clippy_config/src/msrvs.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ macro_rules! msrv_aliases {
1717

1818
// names may refer to stabilized feature flags or library items
1919
msrv_aliases! {
20-
1,83,0 { CONST_EXTERN_FN }
21-
1,83,0 { CONST_FLOAT_BITS_CONV }
20+
1,83,0 { CONST_EXTERN_FN, CONST_FLOAT_BITS_CONV, CONST_FLOAT_CLASSIFY }
2221
1,82,0 { IS_NONE_OR }
2322
1,81,0 { LINT_REASONS_STABILIZATION }
2423
1,80,0 { BOX_INTO_ITER}

src/tools/clippy/clippy_dev/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ aho-corasick = "1.0"
99
clap = { version = "4.4", features = ["derive"] }
1010
indoc = "1.0"
1111
itertools = "0.12"
12-
opener = "0.6"
12+
opener = "0.7"
1313
shell-escape = "0.1"
1414
walkdir = "2.3"
1515

src/tools/clippy/clippy_dev/src/new_lint.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ pub(crate) fn get_stabilization_version() -> String {
207207

208208
fn get_test_file_contents(lint_name: &str, msrv: bool) -> String {
209209
let mut test = formatdoc!(
210-
r#"
210+
r"
211211
#![warn(clippy::{lint_name})]
212212
213213
fn main() {{
214214
// test code goes here
215215
}}
216-
"#
216+
"
217217
);
218218

219219
if msrv {
@@ -272,31 +272,31 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
272272

273273
result.push_str(&if enable_msrv {
274274
formatdoc!(
275-
r#"
275+
r"
276276
use clippy_config::msrvs::{{self, Msrv}};
277277
use clippy_config::Conf;
278278
{pass_import}
279279
use rustc_lint::{{{context_import}, {pass_type}, LintContext}};
280280
use rustc_session::impl_lint_pass;
281281
282-
"#
282+
"
283283
)
284284
} else {
285285
formatdoc!(
286-
r#"
286+
r"
287287
{pass_import}
288288
use rustc_lint::{{{context_import}, {pass_type}}};
289289
use rustc_session::declare_lint_pass;
290290
291-
"#
291+
"
292292
)
293293
});
294294

295295
let _: fmt::Result = writeln!(result, "{}", get_lint_declaration(&name_upper, category));
296296

297297
result.push_str(&if enable_msrv {
298298
formatdoc!(
299-
r#"
299+
r"
300300
pub struct {name_camel} {{
301301
msrv: Msrv,
302302
}}
@@ -315,15 +315,15 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
315315
316316
// TODO: Add MSRV level to `clippy_config/src/msrvs.rs` if needed.
317317
// TODO: Update msrv config comment in `clippy_config/src/conf.rs`
318-
"#
318+
"
319319
)
320320
} else {
321321
formatdoc!(
322-
r#"
322+
r"
323323
declare_lint_pass!({name_camel} => [{name_upper}]);
324324
325325
impl {pass_type}{pass_lifetimes} for {name_camel} {{}}
326-
"#
326+
"
327327
)
328328
});
329329

@@ -416,7 +416,7 @@ fn create_lint_for_ty(lint: &LintData<'_>, enable_msrv: bool, ty: &str) -> io::R
416416
} else {
417417
let _: fmt::Result = writedoc!(
418418
lint_file_contents,
419-
r#"
419+
r"
420420
use rustc_lint::{{{context_import}, LintContext}};
421421
422422
use super::{name_upper};
@@ -425,7 +425,7 @@ fn create_lint_for_ty(lint: &LintData<'_>, enable_msrv: bool, ty: &str) -> io::R
425425
pub(super) fn check(cx: &{context_import}{pass_lifetimes}) {{
426426
todo!();
427427
}}
428-
"#
428+
"
429429
);
430430
}
431431

src/tools/clippy/clippy_dev/src/serve.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ pub fn run(port: u16, lint: Option<String>) -> ! {
1919
});
2020

2121
loop {
22-
if mtime("util/gh-pages/lints.json") < mtime("clippy_lints/src") {
22+
let index_time = mtime("util/gh-pages/index.html");
23+
24+
if index_time < mtime("clippy_lints/src") || index_time < mtime("util/gh-pages/index_template.html") {
2325
Command::new(env::var("CARGO").unwrap_or("cargo".into()))
2426
.arg("collect-metadata")
2527
.spawn()

src/tools/clippy/clippy_lints/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.83"
3+
version = "0.1.84"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"
@@ -13,7 +13,6 @@ arrayvec = { version = "0.7", default-features = false }
1313
cargo_metadata = "0.18"
1414
clippy_config = { path = "../clippy_config" }
1515
clippy_utils = { path = "../clippy_utils" }
16-
declare_clippy_lint = { path = "../declare_clippy_lint" }
1716
itertools = "0.12"
1817
quine-mc_cluskey = "0.2"
1918
regex-syntax = "0.8"

src/tools/clippy/clippy_lints/src/box_default.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl LateLintPass<'_> for BoxDefault {
4747
// And the call is that of a `Box` method
4848
&& path_def_id(cx, ty).map_or(false, |id| Some(id) == cx.tcx.lang_items().owned_box())
4949
// And the single argument to the call is another function call
50-
// This is the `T::default()` of `Box::new(T::default())`
50+
// This is the `T::default()` (or default equivalent) of `Box::new(T::default())`
5151
&& let ExprKind::Call(arg_path, _) = arg.kind
5252
// And we are not in a foreign crate's macro
5353
&& !in_external_macro(cx.sess(), expr.span)

src/tools/clippy/clippy_lints/src/byte_char_slices.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl EarlyLintPass for ByteCharSlice {
4141
"can be more succinctly written as a byte str",
4242
"try",
4343
format!("b\"{slice}\""),
44-
Applicability::MaybeIncorrect,
44+
Applicability::MachineApplicable,
4545
);
4646
}
4747
}

src/tools/clippy/clippy_lints/src/casts/cast_abs_to_unsigned.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(super) fn check(
1919
if msrv.meets(msrvs::UNSIGNED_ABS)
2020
&& let ty::Int(from) = cast_from.kind()
2121
&& let ty::Uint(to) = cast_to.kind()
22-
&& let ExprKind::MethodCall(method_path, receiver, ..) = cast_expr.kind
22+
&& let ExprKind::MethodCall(method_path, receiver, [], _) = cast_expr.kind
2323
&& method_path.ident.name.as_str() == "abs"
2424
{
2525
let span = if from.bit_width() == to.bit_width() {

src/tools/clippy/clippy_lints/src/casts/cast_ptr_alignment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
1919
cx.typeck_results().expr_ty(expr),
2020
);
2121
lint_cast_ptr_alignment(cx, expr, cast_from, cast_to);
22-
} else if let ExprKind::MethodCall(method_path, self_arg, ..) = &expr.kind {
22+
} else if let ExprKind::MethodCall(method_path, self_arg, [], _) = &expr.kind {
2323
if method_path.ident.name == sym!(cast)
2424
&& let Some(generic_args) = method_path.args
2525
&& let [GenericArg::Type(cast_to)] = generic_args.args

src/tools/clippy/clippy_lints/src/create_dir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ declare_lint_pass!(CreateDir => [CREATE_DIR]);
3434

3535
impl LateLintPass<'_> for CreateDir {
3636
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
37-
if let ExprKind::Call(func, [arg, ..]) = expr.kind
37+
if let ExprKind::Call(func, [arg]) = expr.kind
3838
&& let ExprKind::Path(ref path) = func.kind
3939
&& let Some(def_id) = cx.qpath_res(path, func.hir_id).opt_def_id()
4040
&& cx.tcx.is_diagnostic_item(sym::fs_create_dir, def_id)

0 commit comments

Comments
 (0)