Skip to content

Commit 4c383cd

Browse files
committed
Auto merge of rust-lang#150377 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update r? Manishearth `Cargo.lock` update due to 28d62f0. It should not affect the Rust repo, as `clippy_dev` is not used in the Rust repo.
2 parents fabece9 + b04a3dc commit 4c383cd

File tree

178 files changed

+6310
-940
lines changed

Some content is hidden

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

178 files changed

+6310
-940
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ dependencies = [
666666
"indoc",
667667
"itertools",
668668
"opener",
669+
"rustc-literal-escaper",
669670
"walkdir",
670671
]
671672

src/tools/clippy/.github/workflows/clippy_dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
# Setup
1818
- name: Checkout
19-
uses: actions/checkout@v5
19+
uses: actions/checkout@v6
2020
with:
2121
# Unsetting this would make so that any malicious package could get our Github Token
2222
persist-credentials: false

src/tools/clippy/.github/workflows/clippy_pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
steps:
2525
# Setup
2626
- name: Checkout
27-
uses: actions/checkout@v5
27+
uses: actions/checkout@v6
2828
with:
2929
# Unsetting this would make so that any malicious package could get our Github Token
3030
persist-credentials: false

src/tools/clippy/.github/workflows/remark.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020
persist-credentials: false
2121

2222
- name: Setup Node.js
23-
uses: actions/setup-node@v5
23+
uses: actions/setup-node@v6
2424
with:
25-
node-version: '20.x'
25+
node-version: '24.x'
2626

2727
- name: Install remark
2828
run: npm install remark-cli remark-lint remark-lint-maximum-line-length@^3.1.3 remark-preset-lint-recommended remark-gfm

src/tools/clippy/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6916,6 +6916,7 @@ Released 2018-09-13
69166916
[`reversed_empty_ranges`]: https://rust-lang.github.io/rust-clippy/master/index.html#reversed_empty_ranges
69176917
[`same_functions_in_if_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_functions_in_if_condition
69186918
[`same_item_push`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_item_push
6919+
[`same_length_and_capacity`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_length_and_capacity
69196920
[`same_name_method`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_name_method
69206921
[`search_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
69216922
[`seek_from_current`]: https://rust-lang.github.io/rust-clippy/master/index.html#seek_from_current

src/tools/clippy/clippy_dev/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ clap = { version = "4.4", features = ["derive"] }
1010
indoc = "1.0"
1111
itertools = "0.12"
1212
opener = "0.7"
13+
rustc-literal-escaper = "0.0.5"
1314
walkdir = "2.3"
1415

1516
[package.metadata.rust-analyzer]

src/tools/clippy/clippy_dev/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ extern crate rustc_arena;
2222
#[expect(unused_extern_crates, reason = "required to link to rustc crates")]
2323
extern crate rustc_driver;
2424
extern crate rustc_lexer;
25-
extern crate rustc_literal_escaper;
2625

2726
pub mod deprecate_lint;
2827
pub mod dogfood;

src/tools/clippy/clippy_lints/src/assertions_on_constants.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use clippy_utils::consts::{ConstEvalCtxt, Constant};
33
use clippy_utils::diagnostics::span_lint_and_help;
44
use clippy_utils::macros::{find_assert_args, root_macro_call_first_node};
55
use clippy_utils::msrvs::Msrv;
6+
use clippy_utils::visitors::is_const_evaluatable;
67
use clippy_utils::{is_inside_always_const_context, msrvs};
78
use rustc_ast::LitKind;
89
use rustc_hir::{Expr, ExprKind};
@@ -50,6 +51,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
5051
_ => return,
5152
}
5253
&& let Some((condition, _)) = find_assert_args(cx, e, macro_call.expn)
54+
&& is_const_evaluatable(cx, condition)
5355
&& let Some((Constant::Bool(assert_val), const_src)) =
5456
ConstEvalCtxt::new(cx).eval_with_source(condition, macro_call.span.ctxt())
5557
&& let in_const_context = is_inside_always_const_context(cx.tcx, e.hir_id)

src/tools/clippy/clippy_lints/src/booleans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ fn simplify_not(cx: &LateContext<'_>, curr_msrv: Msrv, expr: &Expr<'_>) -> Optio
433433
},
434434
ExprKind::MethodCall(path, receiver, args, _) => {
435435
let type_of_receiver = cx.typeck_results().expr_ty(receiver);
436-
if !type_of_receiver.is_diag_item(cx, sym::Option) && !type_of_receiver.is_diag_item(cx, sym::Result) {
436+
if !matches!(type_of_receiver.opt_diag_name(cx), Some(sym::Option | sym::Result)) {
437437
return None;
438438
}
439439
METHODS_WITH_NEGATION

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,21 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca
2323

2424
let cast_to_f64 = to_nbits == 64;
2525
let mantissa_nbits = if cast_to_f64 { 52 } else { 23 };
26-
let arch_dependent = is_isize_or_usize(cast_from) && cast_to_f64;
27-
let arch_dependent_str = "on targets with 64-bit wide pointers ";
28-
let from_nbits_str = if arch_dependent {
29-
"64".to_owned()
30-
} else if is_isize_or_usize(cast_from) {
31-
// FIXME: handle 16 bits `usize` type
32-
"32 or 64".to_owned()
26+
27+
let has_width = if is_isize_or_usize(cast_from) {
28+
"can be up to 64 bits wide depending on the target architecture".to_owned()
3329
} else {
34-
from_nbits.to_string()
30+
format!("is {from_nbits} bits wide")
3531
};
3632

3733
span_lint(
3834
cx,
3935
CAST_PRECISION_LOSS,
4036
expr.span,
4137
format!(
42-
"casting `{0}` to `{1}` causes a loss of precision {2}(`{0}` is {3} bits wide, \
43-
but `{1}`'s mantissa is only {4} bits wide)",
44-
cast_from,
45-
if cast_to_f64 { "f64" } else { "f32" },
46-
if arch_dependent { arch_dependent_str } else { "" },
47-
from_nbits_str,
48-
mantissa_nbits
38+
"casting `{cast_from}` to `{cast_to}` may cause a loss of precision \
39+
(`{cast_from}` {has_width}, \
40+
but `{cast_to}`'s mantissa is only {mantissa_nbits} bits wide)",
4941
),
5042
);
5143
}

0 commit comments

Comments
 (0)