Skip to content

Commit 89b14ae

Browse files
Fix clippy
1 parent 137b6d0 commit 89b14ae

File tree

7 files changed

+14
-18
lines changed

7 files changed

+14
-18
lines changed

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

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

+1-1
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-6251.stderr

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

+3-3
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/must_use_unit.stderr

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

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

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