Skip to content

Commit f0c2265

Browse files
Fix clippy
1 parent e0a8766 commit f0c2265

File tree

9 files changed

+24
-28
lines changed

9 files changed

+24
-28
lines changed

src/tools/clippy/clippy_lints/src/methods/unnecessary_literal_unwrap.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,10 @@ pub(super) fn check(
102102
]),
103103
("None", "unwrap_or_else", _) => match args[0].kind {
104104
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-
},
105+
body,
110106
..
111107
}) => Some(vec![
112-
(expr.span.with_hi(span.hi()), String::new()),
108+
(expr.span.with_hi(cx.tcx.hir().body(*body).value.span.lo()), String::new()),
113109
(expr.span.with_lo(args[0].span.hi()), String::new()),
114110
]),
115111
_ => None,

src/tools/clippy/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)]`

src/tools/clippy/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:34
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

src/tools/clippy/tests/ui/crashes/ice-6251.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: &[u8]| x }]> {
1212
| +
1313

1414
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
15-
--> $DIR/ice-6251.rs:4:54
15+
--> $DIR/ice-6251.rs:4:53
1616
|
1717
LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
18-
| ^ doesn't have a size known at compile-time
18+
| ^ doesn't have a size known at compile-time
1919
|
2020
= help: the trait `std::marker::Sized` is not implemented for `[u8]`
2121
= note: the return type of a function must have a statically known size

src/tools/clippy/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

src/tools/clippy/tests/ui/future_not_send.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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:41
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
@@ -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:42
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
@@ -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:38
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
@@ -115,10 +115,10 @@ LL | async { true }.await;
115115
= note: `T` doesn't implement `std::marker::Sync`
116116

117117
error: future cannot be sent between threads safely
118-
--> $DIR/future_not_send.rs:73:34
118+
--> $DIR/future_not_send.rs:73:33
119119
|
120120
LL | async fn unclear_future<T>(t: T) {}
121-
| ^ future returned by `unclear_future` is not `Send`
121+
| ^ future returned by `unclear_future` is not `Send`
122122
|
123123
note: captured value is not `Send`
124124
--> $DIR/future_not_send.rs:73:28

src/tools/clippy/tests/ui/must_use_unit.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: this unit-returning function has a `#[must_use]` attribute
44
LL | #[must_use]
55
| ----------- help: remove the attribute
66
LL | pub fn must_use_default() {}
7-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
88
|
99
= note: `-D clippy::must-use-unit` implied by `-D warnings`
1010
= help: to override `-D warnings` add `#[allow(clippy::must_use_unit)]`
@@ -23,7 +23,7 @@ error: this unit-returning function has a `#[must_use]` attribute
2323
LL | #[must_use = "With note"]
2424
| ------------------------- help: remove the attribute
2525
LL | pub fn must_use_with_note() {}
26-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2727

2828
error: aborting due to 3 previous errors
2929

src/tools/clippy/tests/ui/unnecessary_literal_unwrap.fixed

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ fn unwrap_option_none() {
2323
let _val: u16 = 234;
2424
let _val: u16 = 234;
2525
let _val: u16 = { 234 };
26-
let _val: u16 = { 234 };
26+
let _val: u16 = { 234 };
2727

2828
panic!();
2929
panic!("this always happens");
3030
String::default();
3131
234;
3232
234;
3333
{ 234 };
34-
{ 234 };
34+
{ 234 };
3535
}
3636

3737
fn unwrap_result_ok() {

src/tools/clippy/tests/ui/unnecessary_literal_unwrap.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ LL | let _val: u16 = None.unwrap_or_else(|| -> u16 { 234 });
116116
help: remove the `None` and `unwrap_or_else()`
117117
|
118118
LL - let _val: u16 = None.unwrap_or_else(|| -> u16 { 234 });
119-
LL + let _val: u16 = { 234 };
119+
LL + let _val: u16 = { 234 };
120120
|
121121

122122
error: used `unwrap()` on `None` value
@@ -187,7 +187,7 @@ LL | None::<u16>.unwrap_or_else(|| -> u16 { 234 });
187187
help: remove the `None` and `unwrap_or_else()`
188188
|
189189
LL - None::<u16>.unwrap_or_else(|| -> u16 { 234 });
190-
LL + { 234 };
190+
LL + { 234 };
191191
|
192192

193193
error: used `unwrap()` on `Ok` value

0 commit comments

Comments
 (0)