Skip to content

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
};

clippy_utils/src/mir/mod.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,26 @@ pub fn visit_local_usage(locals: &[Local], mir: &Body<'_>, location: Location) -
3030
locals.len()
3131
];
3232

33-
traversal::ReversePostorder::new(mir, location.block).try_fold(init, |usage, (tbb, tdata)| {
34-
// Give up on loops
35-
if tdata.terminator().successors().any(|s| s == location.block) {
36-
return None;
37-
}
33+
traversal::Postorder::new(&mir.basic_blocks, location.block)
34+
.collect::<Vec<_>>()
35+
.into_iter()
36+
.rev()
37+
.try_fold(init, |usage, tbb| {
38+
let tdata = &mir.basic_blocks[tbb];
39+
40+
// Give up on loops
41+
if tdata.terminator().successors().any(|s| s == location.block) {
42+
return None;
43+
}
3844

39-
let mut v = V {
40-
locals,
41-
location,
42-
results: usage,
43-
};
44-
v.visit_basic_block_data(tbb, tdata);
45-
Some(v.results)
46-
})
45+
let mut v = V {
46+
locals,
47+
location,
48+
results: usage,
49+
};
50+
v.visit_basic_block_data(tbb, tdata);
51+
Some(v.results)
52+
})
4753
}
4854

4955
struct V<'a> {

clippy_utils/src/qualify_min_const_fn.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ fn check_place<'tcx>(tcx: TyCtxt<'tcx>, place: Place<'tcx>, span: Span, body: &B
272272
| ProjectionElem::Downcast(..)
273273
| ProjectionElem::Subslice { .. }
274274
| ProjectionElem::Deref
275+
| ProjectionElem::Subtype(_)
275276
| ProjectionElem::Index(_) => {},
276277
}
277278
}

clippy_utils/src/ty/type_certainty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ fn path_segment_certainty(
219219
// See the comment preceding `qpath_certainty`. `def_id` could refer to a type or a value.
220220
let certainty = lhs.join_clearing_def_ids(rhs);
221221
if resolves_to_type {
222-
if let DefKind::TyAlias { .. } = cx.tcx.def_kind(def_id) {
222+
if let DefKind::TyAlias = cx.tcx.def_kind(def_id) {
223223
adt_def_id(cx.tcx.type_of(def_id).instantiate_identity())
224224
.map_or(certainty, |def_id| certainty.with_def_id(def_id))
225225
} else {

declare_clippy_lint/Cargo.toml

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

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2023-09-25"
2+
channel = "nightly-2023-10-06"
33
components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]

tests/ui-toml/too_many_arguments/too_many_arguments.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: this function has too many arguments (11/10)
22
--> $DIR/too_many_arguments.rs:4:1
33
|
44
LL | fn too_many(p1: u8, p2: u8, p3: u8, p4: u8, p5: u8, p6: u8, p7: u8, p8: u8, p9: u8, p10: u8, p11: u8) {}
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::too-many-arguments` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]`

tests/ui/crashes/ice-10645.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
warning: future cannot be sent between threads safely
2-
--> $DIR/ice-10645.rs:5:35
2+
--> $DIR/ice-10645.rs:5:1
33
|
44
LL | pub async fn bar<'a, T: 'a>(_: T) {}
5-
| ^ future returned by `bar` is not `Send`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `bar` is not `Send`
66
|
77
note: captured value is not `Send`
88
--> $DIR/ice-10645.rs:5:29

tests/ui/functions.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: this function has too many arguments (8/7)
22
--> $DIR/functions.rs:8:1
33
|
44
LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {}
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::too-many-arguments` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]`
@@ -17,7 +17,7 @@ LL | | two: u32,
1717
... |
1818
LL | | eight: ()
1919
LL | | ) {
20-
| |__^
20+
| |_^
2121

2222
error: this function has too many arguments (8/7)
2323
--> $DIR/functions.rs:48:5
@@ -29,7 +29,7 @@ error: this function has too many arguments (8/7)
2929
--> $DIR/functions.rs:58:5
3030
|
3131
LL | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {}
32-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3333

3434
error: this public function might dereference a raw pointer but is not marked `unsafe`
3535
--> $DIR/functions.rs:68:34

tests/ui/future_not_send.stderr

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: future cannot be sent between threads safely
2-
--> $DIR/future_not_send.rs:7:62
2+
--> $DIR/future_not_send.rs:7:1
33
|
44
LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool {
5-
| ^^^^ future returned by `private_future` is not `Send`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future` is not `Send`
66
|
77
note: future is not `Send` as this value is used across an await
88
--> $DIR/future_not_send.rs:9:20
@@ -23,10 +23,10 @@ LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool {
2323
= help: to override `-D warnings` add `#[allow(clippy::future_not_send)]`
2424

2525
error: future cannot be sent between threads safely
26-
--> $DIR/future_not_send.rs:12:42
26+
--> $DIR/future_not_send.rs:12:1
2727
|
2828
LL | pub async fn public_future(rc: Rc<[u8]>) {
29-
| ^ future returned by `public_future` is not `Send`
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future` is not `Send`
3030
|
3131
note: future is not `Send` as this value is used across an await
3232
--> $DIR/future_not_send.rs:14:20
@@ -39,10 +39,10 @@ LL | async { true }.await;
3939
= note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send`
4040

4141
error: future cannot be sent between threads safely
42-
--> $DIR/future_not_send.rs:21:63
42+
--> $DIR/future_not_send.rs:21:1
4343
|
4444
LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool {
45-
| ^^^^ future returned by `private_future2` is not `Send`
45+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future2` is not `Send`
4646
|
4747
note: captured value is not `Send`
4848
--> $DIR/future_not_send.rs:21:26
@@ -58,10 +58,10 @@ LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool {
5858
= note: `std::cell::Cell<usize>` doesn't implement `std::marker::Sync`
5959

6060
error: future cannot be sent between threads safely
61-
--> $DIR/future_not_send.rs:26:43
61+
--> $DIR/future_not_send.rs:26:1
6262
|
6363
LL | pub async fn public_future2(rc: Rc<[u8]>) {}
64-
| ^ future returned by `public_future2` is not `Send`
64+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future2` is not `Send`
6565
|
6666
note: captured value is not `Send`
6767
--> $DIR/future_not_send.rs:26:29
@@ -71,10 +71,10 @@ LL | pub async fn public_future2(rc: Rc<[u8]>) {}
7171
= note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send`
7272

7373
error: future cannot be sent between threads safely
74-
--> $DIR/future_not_send.rs:38:39
74+
--> $DIR/future_not_send.rs:38:5
7575
|
7676
LL | async fn private_future(&self) -> usize {
77-
| ^^^^^ future returned by `private_future` is not `Send`
77+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future` is not `Send`
7878
|
7979
note: future is not `Send` as this value is used across an await
8080
--> $DIR/future_not_send.rs:40:24
@@ -87,10 +87,10 @@ LL | async { true }.await;
8787
= note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync`
8888

8989
error: future cannot be sent between threads safely
90-
--> $DIR/future_not_send.rs:44:39
90+
--> $DIR/future_not_send.rs:44:5
9191
|
9292
LL | pub async fn public_future(&self) {
93-
| ^ future returned by `public_future` is not `Send`
93+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future` is not `Send`
9494
|
9595
note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync`
9696
--> $DIR/future_not_send.rs:44:32
@@ -100,10 +100,13 @@ LL | pub async fn public_future(&self) {
100100
= note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync`
101101

102102
error: future cannot be sent between threads safely
103-
--> $DIR/future_not_send.rs:55:37
103+
--> $DIR/future_not_send.rs:55:1
104104
|
105-
LL | async fn generic_future<T>(t: T) -> T
106-
| ^ future returned by `generic_future` is not `Send`
105+
LL | / async fn generic_future<T>(t: T) -> T
106+
LL | |
107+
LL | | where
108+
LL | | T: Send,
109+
| |____________^ future returned by `generic_future` is not `Send`
107110
|
108111
note: future is not `Send` as this value is used across an await
109112
--> $DIR/future_not_send.rs:61:20
@@ -115,10 +118,10 @@ LL | async { true }.await;
115118
= note: `T` doesn't implement `std::marker::Sync`
116119

117120
error: future cannot be sent between threads safely
118-
--> $DIR/future_not_send.rs:73:34
121+
--> $DIR/future_not_send.rs:73:1
119122
|
120123
LL | async fn unclear_future<T>(t: T) {}
121-
| ^ future returned by `unclear_future` is not `Send`
124+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `unclear_future` is not `Send`
122125
|
123126
note: captured value is not `Send`
124127
--> $DIR/future_not_send.rs:73:28

0 commit comments

Comments
 (0)