Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 238edf2

Browse files
authored
r? @ghost changelog: none
2 parents bbf65f0 + e6be02e commit 238edf2

File tree

274 files changed

+3505
-2467
lines changed

Some content is hidden

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

274 files changed

+3505
-2467
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy"
33
# begin autogenerated version
4-
version = "0.1.86"
4+
version = "0.1.87"
55
# end autogenerated version
66
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
77
repository = "https://github.com/rust-lang/rust-clippy"

clippy_config/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy_config"
33
# begin autogenerated version
4-
version = "0.1.86"
4+
version = "0.1.87"
55
# end autogenerated version
66
edition = "2024"
77
publish = false

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy_lints"
33
# begin autogenerated version
4-
version = "0.1.86"
4+
version = "0.1.87"
55
# end autogenerated version
66
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
77
repository = "https://github.com/rust-lang/rust-clippy"

clippy_lints/src/approx_const.rs

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use clippy_utils::diagnostics::span_lint_and_help;
33
use clippy_utils::msrvs::{self, Msrv};
44
use rustc_ast::ast::{FloatTy, LitFloatType, LitKind};
55
use rustc_attr_parsing::RustcVersion;
6-
use rustc_hir::{Expr, ExprKind};
6+
use rustc_hir::{HirId, Lit};
77
use rustc_lint::{LateContext, LateLintPass};
88
use rustc_session::impl_lint_pass;
9-
use rustc_span::symbol;
9+
use rustc_span::{Span, symbol};
1010
use std::f64::consts as f64;
1111

1212
declare_clippy_lint! {
@@ -73,30 +73,36 @@ impl ApproxConstant {
7373
msrv: conf.msrv.clone(),
7474
}
7575
}
76+
}
7677

77-
fn check_lit(&self, cx: &LateContext<'_>, lit: &LitKind, e: &Expr<'_>) {
78-
match *lit {
78+
impl LateLintPass<'_> for ApproxConstant {
79+
fn check_lit(&mut self, cx: &LateContext<'_>, _hir_id: HirId, lit: &Lit, _negated: bool) {
80+
match lit.node {
7981
LitKind::Float(s, LitFloatType::Suffixed(fty)) => match fty {
80-
FloatTy::F16 => self.check_known_consts(cx, e, s, "f16"),
81-
FloatTy::F32 => self.check_known_consts(cx, e, s, "f32"),
82-
FloatTy::F64 => self.check_known_consts(cx, e, s, "f64"),
83-
FloatTy::F128 => self.check_known_consts(cx, e, s, "f128"),
82+
FloatTy::F16 => self.check_known_consts(cx, lit.span, s, "f16"),
83+
FloatTy::F32 => self.check_known_consts(cx, lit.span, s, "f32"),
84+
FloatTy::F64 => self.check_known_consts(cx, lit.span, s, "f64"),
85+
FloatTy::F128 => self.check_known_consts(cx, lit.span, s, "f128"),
8486
},
8587
// FIXME(f16_f128): add `f16` and `f128` when these types become stable.
86-
LitKind::Float(s, LitFloatType::Unsuffixed) => self.check_known_consts(cx, e, s, "f{32, 64}"),
88+
LitKind::Float(s, LitFloatType::Unsuffixed) => self.check_known_consts(cx, lit.span, s, "f{32, 64}"),
8789
_ => (),
8890
}
8991
}
9092

91-
fn check_known_consts(&self, cx: &LateContext<'_>, e: &Expr<'_>, s: symbol::Symbol, module: &str) {
93+
extract_msrv_attr!(LateContext);
94+
}
95+
96+
impl ApproxConstant {
97+
fn check_known_consts(&self, cx: &LateContext<'_>, span: Span, s: symbol::Symbol, module: &str) {
9298
let s = s.as_str();
9399
if s.parse::<f64>().is_ok() {
94100
for &(constant, name, min_digits, msrv) in &KNOWN_CONSTS {
95101
if is_approx_const(constant, s, min_digits) && msrv.is_none_or(|msrv| self.msrv.meets(msrv)) {
96102
span_lint_and_help(
97103
cx,
98104
APPROX_CONSTANT,
99-
e.span,
105+
span,
100106
format!("approximate value of `{module}::consts::{name}` found"),
101107
None,
102108
"consider using the constant directly",
@@ -110,16 +116,6 @@ impl ApproxConstant {
110116

111117
impl_lint_pass!(ApproxConstant => [APPROX_CONSTANT]);
112118

113-
impl<'tcx> LateLintPass<'tcx> for ApproxConstant {
114-
fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
115-
if let ExprKind::Lit(lit) = &e.kind {
116-
self.check_lit(cx, &lit.node, e);
117-
}
118-
}
119-
120-
extract_msrv_attr!(LateContext);
121-
}
122-
123119
/// Returns `false` if the number of significant figures in `value` are
124120
/// less than `min_digits`; otherwise, returns true if `value` is equal
125121
/// to `constant`, rounded to the number of digits present in `value`.

clippy_lints/src/arbitrary_source_item_ordering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
338338
return;
339339
}
340340

341-
let items = module.item_ids.iter().map(|&id| cx.tcx.hir().item(id));
341+
let items = module.item_ids.iter().map(|&id| cx.tcx.hir_item(id));
342342

343343
// Iterates over the items within a module.
344344
//

clippy_lints/src/async_yields_async.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync {
6060
// XXXkhuey maybe we should?
6161
return;
6262
},
63-
CoroutineSource::Block => cx.tcx.hir().body(*body_id).value,
63+
CoroutineSource::Block => cx.tcx.hir_body(*body_id).value,
6464
CoroutineSource::Closure => {
6565
// Like `async fn`, async closures are wrapped in an additional block
6666
// to move all of the closure's arguments into the future.
6767

68-
let async_closure_body = cx.tcx.hir().body(*body_id).value;
68+
let async_closure_body = cx.tcx.hir_body(*body_id).value;
6969
let ExprKind::Block(block, _) = async_closure_body.kind else {
7070
return;
7171
};

clippy_lints/src/attrs/mixed_attributes_style.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use super::MIXED_ATTRIBUTES_STYLE;
22
use clippy_utils::diagnostics::span_lint;
33
use rustc_ast::{AttrKind, AttrStyle, Attribute};
44
use rustc_data_structures::fx::FxHashSet;
5-
use rustc_data_structures::sync::Lrc;
65
use rustc_lint::{EarlyContext, LintContext};
76
use rustc_span::source_map::SourceMap;
87
use rustc_span::{SourceFile, Span, Symbol};
8+
use std::sync::Arc;
99

1010
#[derive(Hash, PartialEq, Eq)]
1111
enum SimpleAttrKind {
@@ -79,7 +79,7 @@ fn lint_mixed_attrs(cx: &EarlyContext<'_>, attrs: &[Attribute]) {
7979
);
8080
}
8181

82-
fn attr_in_same_src_as_item(source_map: &SourceMap, item_src: &Lrc<SourceFile>, attr_span: Span) -> bool {
82+
fn attr_in_same_src_as_item(source_map: &SourceMap, item_src: &Arc<SourceFile>, attr_span: Span) -> bool {
8383
let attr_src = source_map.lookup_source_file(attr_span.lo());
84-
Lrc::ptr_eq(item_src, &attr_src)
84+
Arc::ptr_eq(item_src, &attr_src)
8585
}

clippy_lints/src/attrs/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ pub(super) fn is_lint_level(symbol: Symbol, attr_id: AttrId) -> bool {
2222

2323
pub(super) fn is_relevant_item(cx: &LateContext<'_>, item: &Item<'_>) -> bool {
2424
if let ItemKind::Fn { body: eid, .. } = item.kind {
25-
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir().body(eid).value)
25+
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir_body(eid).value)
2626
} else {
2727
true
2828
}
2929
}
3030

3131
pub(super) fn is_relevant_impl(cx: &LateContext<'_>, item: &ImplItem<'_>) -> bool {
3232
match item.kind {
33-
ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir().body(eid).value),
33+
ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir_body(eid).value),
3434
_ => false,
3535
}
3636
}
@@ -39,7 +39,7 @@ pub(super) fn is_relevant_trait(cx: &LateContext<'_>, item: &TraitItem<'_>) -> b
3939
match item.kind {
4040
TraitItemKind::Fn(_, TraitFn::Required(_)) => true,
4141
TraitItemKind::Fn(_, TraitFn::Provided(eid)) => {
42-
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir().body(eid).value)
42+
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir_body(eid).value)
4343
},
4444
_ => false,
4545
}

clippy_lints/src/booleans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ fn simplify_not(cx: &LateContext<'_>, curr_msrv: &Msrv, expr: &Expr<'_>) -> Opti
454454
})
455455
},
456456
ExprKind::Closure(closure) => {
457-
let body = cx.tcx.hir().body(closure.body);
457+
let body = cx.tcx.hir_body(closure.body);
458458
let params = body
459459
.params
460460
.iter()

clippy_lints/src/casts/cast_possible_truncation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ use clippy_utils::expr_or_init;
44
use clippy_utils::source::snippet;
55
use clippy_utils::sugg::Sugg;
66
use clippy_utils::ty::{get_discriminant_value, is_isize_or_usize};
7+
use rustc_abi::IntegerType;
78
use rustc_errors::{Applicability, Diag};
89
use rustc_hir::def::{DefKind, Res};
910
use rustc_hir::{BinOpKind, Expr, ExprKind};
1011
use rustc_lint::LateContext;
1112
use rustc_middle::ty::{self, FloatTy, Ty};
1213
use rustc_span::Span;
13-
use rustc_target::abi::IntegerType;
1414

1515
use super::{CAST_ENUM_TRUNCATION, CAST_POSSIBLE_TRUNCATION, utils};
1616

0 commit comments

Comments
 (0)