Skip to content

Commit 238edf2

Browse files
authored
Rustup (#14262)
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

+1-1
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

+1-1
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

+1-1
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

+17-21
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

+1-1
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

+2-2
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

+3-3
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

+3-3
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

+1-1
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

+1-1
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

clippy_lints/src/casts/cast_ptr_alignment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn is_used_as_unaligned(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
6666
if matches!(name.ident.as_str(), "read_unaligned" | "write_unaligned")
6767
&& let Some(def_id) = cx.typeck_results().type_dependent_def_id(parent.hir_id)
6868
&& let Some(def_id) = cx.tcx.impl_of_method(def_id)
69-
&& cx.tcx.type_of(def_id).instantiate_identity().is_unsafe_ptr()
69+
&& cx.tcx.type_of(def_id).instantiate_identity().is_raw_ptr()
7070
{
7171
true
7272
} else {

clippy_lints/src/collection_is_never_read.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn has_no_read_access<'tcx, T: Visitable<'tcx>>(cx: &LateContext<'tcx>, id: HirI
118118
let is_read_in_closure_arg = args.iter().any(|arg| {
119119
if let ExprKind::Closure(closure) = arg.kind
120120
// To keep things simple, we only check the first param to see if its read.
121-
&& let Body { params: [param, ..], value } = cx.tcx.hir().body(closure.body)
121+
&& let Body { params: [param, ..], value } = cx.tcx.hir_body(closure.body)
122122
{
123123
!has_no_read_access(cx, param.hir_id, *value)
124124
} else {

clippy_lints/src/declared_lints.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ pub static LINTS: &[&crate::LintInfo] = &[
145145
crate::doc::DOC_NESTED_REFDEFS_INFO,
146146
crate::doc::DOC_OVERINDENTED_LIST_ITEMS_INFO,
147147
crate::doc::EMPTY_DOCS_INFO,
148-
crate::doc::EMPTY_LINE_AFTER_DOC_COMMENTS_INFO,
149-
crate::doc::EMPTY_LINE_AFTER_OUTER_ATTR_INFO,
150148
crate::doc::MISSING_ERRORS_DOC_INFO,
151149
crate::doc::MISSING_PANICS_DOC_INFO,
152150
crate::doc::MISSING_SAFETY_DOC_INFO,
@@ -163,6 +161,8 @@ pub static LINTS: &[&crate::LintInfo] = &[
163161
crate::else_if_without_else::ELSE_IF_WITHOUT_ELSE_INFO,
164162
crate::empty_drop::EMPTY_DROP_INFO,
165163
crate::empty_enum::EMPTY_ENUM_INFO,
164+
crate::empty_line_after::EMPTY_LINE_AFTER_DOC_COMMENTS_INFO,
165+
crate::empty_line_after::EMPTY_LINE_AFTER_OUTER_ATTR_INFO,
166166
crate::empty_with_brackets::EMPTY_ENUM_VARIANTS_WITH_BRACKETS_INFO,
167167
crate::empty_with_brackets::EMPTY_STRUCTS_WITH_BRACKETS_INFO,
168168
crate::endian_bytes::BIG_ENDIAN_BYTES_INFO,

clippy_lints/src/default_numeric_fallback.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ declare_lint_pass!(DefaultNumericFallback => [DEFAULT_NUMERIC_FALLBACK]);
5252

5353
impl<'tcx> LateLintPass<'tcx> for DefaultNumericFallback {
5454
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) {
55-
let hir = cx.tcx.hir();
5655
// NOTE: this is different from `clippy_utils::is_inside_always_const_context`.
5756
// Inline const supports type inference.
5857
let is_parent_const = matches!(
59-
hir.body_const_context(hir.body_owner_def_id(body.id())),
58+
cx.tcx.hir_body_const_context(cx.tcx.hir_body_owner_def_id(body.id())),
6059
Some(ConstContext::Const { inline: false } | ConstContext::Static(_))
6160
);
6261
let mut visitor = NumericFallbackVisitor::new(cx, is_parent_const);

clippy_lints/src/dereference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ fn try_parse_ref_op<'tcx>(
682682
},
683683
[arg],
684684
) => (true, typeck.qpath_res(path, *hir_id).opt_def_id()?, arg),
685-
ExprKind::Unary(UnOp::Deref, sub_expr) if !typeck.expr_ty(sub_expr).is_unsafe_ptr() => {
685+
ExprKind::Unary(UnOp::Deref, sub_expr) if !typeck.expr_ty(sub_expr).is_raw_ptr() => {
686686
return Some((RefOp::Deref, sub_expr));
687687
},
688688
ExprKind::AddrOf(BorrowKind::Ref, mutability, sub_expr) => return Some((RefOp::AddrOf(mutability), sub_expr)),

clippy_lints/src/derivable_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
197197
&& let impl_item_hir = child.id.hir_id()
198198
&& let Node::ImplItem(impl_item) = cx.tcx.hir_node(impl_item_hir)
199199
&& let ImplItemKind::Fn(_, b) = &impl_item.kind
200-
&& let Body { value: func_expr, .. } = cx.tcx.hir().body(*b)
200+
&& let Body { value: func_expr, .. } = cx.tcx.hir_body(*b)
201201
&& let &ty::Adt(adt_def, args) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind()
202202
&& let attrs = cx.tcx.hir().attrs(item.hir_id())
203203
&& !attrs.iter().any(|attr| attr.doc_str().is_some())

clippy_lints/src/derive.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ impl<'tcx> Visitor<'tcx> for UnsafeVisitor<'_, 'tcx> {
437437
walk_expr(self, expr)
438438
}
439439

440-
fn nested_visit_map(&mut self) -> Self::Map {
441-
self.cx.tcx.hir()
440+
fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
441+
self.cx.tcx
442442
}
443443
}
444444

0 commit comments

Comments
 (0)