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

Commit b105fb4

Browse files
committed
Auto merge of rust-lang#11629 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 7217c0f + b8677e5 commit b105fb4

24 files changed

+118
-87
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.74"
3+
version = "0.1.75"
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"

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.74"
3+
version = "0.1.75"
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"

clippy_lints/src/init_numbered_fields.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for NumberedFields {
5050
&& fields
5151
.iter()
5252
.all(|f| f.ident.as_str().as_bytes().iter().all(u8::is_ascii_digit))
53-
&& !matches!(cx.qpath_res(path, e.hir_id), Res::Def(DefKind::TyAlias { .. }, ..))
53+
&& !matches!(cx.qpath_res(path, e.hir_id), Res::Def(DefKind::TyAlias, ..))
5454
{
5555
let expr_spans = fields
5656
.iter()

clippy_lints/src/methods/unnecessary_literal_unwrap.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ fn get_ty_from_args<'a>(args: Option<&'a [hir::GenericArg<'a>]>, index: usize) -
2424
}
2525
}
2626

27-
#[expect(clippy::too_many_lines)]
2827
pub(super) fn check(
2928
cx: &LateContext<'_>,
3029
expr: &hir::Expr<'_>,
@@ -101,15 +100,11 @@ pub(super) fn check(
101100
(expr.span.with_lo(args[0].span.hi()), String::new()),
102101
]),
103102
("None", "unwrap_or_else", _) => match args[0].kind {
104-
hir::ExprKind::Closure(hir::Closure {
105-
fn_decl:
106-
hir::FnDecl {
107-
output: hir::FnRetTy::DefaultReturn(span) | hir::FnRetTy::Return(hir::Ty { span, .. }),
108-
..
109-
},
110-
..
111-
}) => Some(vec![
112-
(expr.span.with_hi(span.hi()), String::new()),
103+
hir::ExprKind::Closure(hir::Closure { body, .. }) => Some(vec![
104+
(
105+
expr.span.with_hi(cx.tcx.hir().body(*body).value.span.lo()),
106+
String::new(),
107+
),
113108
(expr.span.with_lo(args[0].span.hi()), String::new()),
114109
]),
115110
_ => None,

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
401401
= get_callee_generic_args_and_args(cx, parent_expr)
402402
{
403403
// FIXME: the `instantiate_identity()` below seems incorrect, since we eventually
404-
// call `tcx.try_subst_and_normalize_erasing_regions` further down
404+
// call `tcx.try_instantiate_and_normalize_erasing_regions` further down
405405
// (i.e., we are explicitly not in the identity context).
406406
let fn_sig = cx.tcx.fn_sig(callee_def_id).instantiate_identity().skip_binder();
407407
if let Some(arg_index) = recv.into_iter().chain(call_args).position(|arg| arg.hir_id == expr.hir_id)
@@ -452,7 +452,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
452452

453453
let output_ty = fn_sig.output();
454454
if output_ty.contains(*param_ty) {
455-
if let Ok(new_ty) = cx.tcx.try_subst_and_normalize_erasing_regions(
455+
if let Ok(new_ty) = cx.tcx.try_instantiate_and_normalize_erasing_regions(
456456
new_subst, cx.param_env, EarlyBinder::bind(output_ty)) {
457457
expr = parent_expr;
458458
ty = new_ty;

clippy_lints/src/mixed_read_write_in_expression.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,27 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
134134
}
135135
}
136136

137+
fn stmt_might_diverge(stmt: &Stmt<'_>) -> bool {
138+
!matches!(stmt.kind, StmtKind::Item(..))
139+
}
140+
137141
impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
138142
fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
139143
match e.kind {
140144
// fix #10776
141145
ExprKind::Block(block, ..) => match (block.stmts, block.expr) {
142-
([], Some(e)) => self.visit_expr(e),
143-
([stmt], None) => match stmt.kind {
144-
StmtKind::Expr(e) | StmtKind::Semi(e) => self.visit_expr(e),
145-
_ => {},
146+
(stmts, Some(e)) => {
147+
if stmts.iter().all(|stmt| !stmt_might_diverge(stmt)) {
148+
self.visit_expr(e);
149+
}
150+
},
151+
([first @ .., stmt], None) => {
152+
if first.iter().all(|stmt| !stmt_might_diverge(stmt)) {
153+
match stmt.kind {
154+
StmtKind::Expr(e) | StmtKind::Semi(e) => self.visit_expr(e),
155+
_ => {},
156+
}
157+
}
146158
},
147159
_ => {},
148160
},

clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ declare_clippy_lint! {
2828
/// know the name of the lint.
2929
///
3030
/// ### Known problems
31-
/// Only checks for lints associated using the
32-
/// `declare_lint_pass!`, `impl_lint_pass!`, and `lint_array!` macros.
31+
/// Only checks for lints associated using the `declare_lint_pass!` and
32+
/// `impl_lint_pass!` macros.
3333
///
3434
/// ### Example
3535
/// ```rust,ignore

clippy_utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_utils"
3-
version = "0.1.74"
3+
version = "0.1.75"
44
edition = "2021"
55
publish = false
66

clippy_utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ pub fn is_wild(pat: &Pat<'_>) -> bool {
287287
/// Checks if the given `QPath` belongs to a type alias.
288288
pub fn is_ty_alias(qpath: &QPath<'_>) -> bool {
289289
match *qpath {
290-
QPath::Resolved(_, path) => matches!(path.res, Res::Def(DefKind::TyAlias { .. } | DefKind::AssocTy, ..)),
290+
QPath::Resolved(_, path) => matches!(path.res, Res::Def(DefKind::TyAlias | DefKind::AssocTy, ..)),
291291
QPath::TypeRelative(ty, _) if let TyKind::Path(qpath) = ty.kind => { is_ty_alias(&qpath) },
292292
_ => false,
293293
}

clippy_utils/src/macros.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,26 @@ pub enum PanicExpn<'a> {
228228

229229
impl<'a> PanicExpn<'a> {
230230
pub fn parse(expr: &'a Expr<'a>) -> Option<Self> {
231-
let ExprKind::Call(callee, [arg, rest @ ..]) = &expr.kind else {
231+
let ExprKind::Call(callee, args) = &expr.kind else {
232232
return None;
233233
};
234234
let ExprKind::Path(QPath::Resolved(_, path)) = &callee.kind else {
235235
return None;
236236
};
237-
let result = match path.segments.last().unwrap().ident.as_str() {
237+
let name = path.segments.last().unwrap().ident.as_str();
238+
239+
// This has no argument
240+
if name == "panic_cold_explicit" {
241+
return Some(Self::Empty);
242+
};
243+
244+
let [arg, rest @ ..] = args else {
245+
return None;
246+
};
247+
let result = match name {
238248
"panic" if arg.span.ctxt() == expr.span.ctxt() => Self::Empty,
239249
"panic" | "panic_str" => Self::Str(arg),
240-
"panic_display" => {
250+
"panic_display" | "panic_cold_display" => {
241251
let ExprKind::AddrOf(_, _, e) = &arg.kind else {
242252
return None;
243253
};

0 commit comments

Comments
 (0)