Skip to content

Commit 4b133f2

Browse files
committed
Apply review comments
1 parent 3999b30 commit 4b133f2

File tree

8 files changed

+39
-39
lines changed

8 files changed

+39
-39
lines changed

clippy_lints/src/methods/mod.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,7 @@ fn lint_iter_nth<'a, 'tcx>(
21382138
ITER_NTH,
21392139
expr.span,
21402140
&format!("called `.iter{0}().nth()` on a {1}", mut_str, caller_type),
2141-
&format!("Calling `.get{}()` is both faster and more readable", mut_str),
2141+
&format!("calling `.get{}()` is both faster and more readable", mut_str),
21422142
);
21432143
}
21442144

@@ -2247,7 +2247,7 @@ fn lint_iter_skip_next(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>) {
22472247
ITER_SKIP_NEXT,
22482248
expr.span,
22492249
"called `skip(x).next()` on an iterator",
2250-
"This is more succinctly expressed by calling `nth(x)`.",
2250+
"this is more succinctly expressed by calling `nth(x)`",
22512251
);
22522252
}
22532253
}
@@ -2309,8 +2309,8 @@ fn lint_unwrap(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, unwrap_args: &[hi
23092309
expr.span,
23102310
&format!("used `unwrap()` on `{}` value", kind,),
23112311
&format!(
2312-
"If you don't want to handle the `{}` case gracefully, consider \
2313-
using `expect()` to provide a better panic message.",
2312+
"if you don't want to handle the `{}` case gracefully, consider \
2313+
using `expect()` to provide a better panic message",
23142314
none_value,
23152315
),
23162316
);
@@ -2335,7 +2335,7 @@ fn lint_expect(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, expect_args: &[hi
23352335
lint,
23362336
expr.span,
23372337
&format!("used `expect()` on `{}` value", kind,),
2338-
&format!("If this value is an `{}`, it will panic.", none_value,),
2338+
&format!("if this value is an `{}`, it will panic", none_value,),
23392339
);
23402340
}
23412341
}
@@ -2355,7 +2355,7 @@ fn lint_ok_expect(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, ok_args: &[hir
23552355
OK_EXPECT,
23562356
expr.span,
23572357
"called `ok().expect()` on a `Result` value",
2358-
"You can call `expect()` directly on the `Result`",
2358+
"you can call `expect()` directly on the `Result`",
23592359
);
23602360
}
23612361
}
@@ -2608,7 +2608,7 @@ fn lint_filter_map<'a, 'tcx>(
26082608
// lint if caller of `.filter().map()` is an Iterator
26092609
if match_trait_method(cx, expr, &paths::ITERATOR) {
26102610
let msg = "called `filter(p).map(q)` on an `Iterator`";
2611-
let hint = "This is more succinctly expressed by calling `.filter_map(..)` instead.";
2611+
let hint = "this is more succinctly expressed by calling `.filter_map(..)` instead";
26122612
span_help_and_lint(cx, FILTER_MAP, expr.span, msg, hint);
26132613
}
26142614
}
@@ -2648,7 +2648,7 @@ fn lint_find_map<'a, 'tcx>(
26482648
// lint if caller of `.filter().map()` is an Iterator
26492649
if match_trait_method(cx, &map_args[0], &paths::ITERATOR) {
26502650
let msg = "called `find(p).map(q)` on an `Iterator`";
2651-
let hint = "This is more succinctly expressed by calling `.find_map(..)` instead.";
2651+
let hint = "this is more succinctly expressed by calling `.find_map(..)` instead";
26522652
span_help_and_lint(cx, FIND_MAP, expr.span, msg, hint);
26532653
}
26542654
}
@@ -2663,7 +2663,7 @@ fn lint_filter_map_map<'a, 'tcx>(
26632663
// lint if caller of `.filter().map()` is an Iterator
26642664
if match_trait_method(cx, expr, &paths::ITERATOR) {
26652665
let msg = "called `filter_map(p).map(q)` on an `Iterator`";
2666-
let hint = "This is more succinctly expressed by only calling `.filter_map(..)` instead.";
2666+
let hint = "this is more succinctly expressed by only calling `.filter_map(..)` instead";
26672667
span_help_and_lint(cx, FILTER_MAP, expr.span, msg, hint);
26682668
}
26692669
}
@@ -2678,8 +2678,8 @@ fn lint_filter_flat_map<'a, 'tcx>(
26782678
// lint if caller of `.filter().flat_map()` is an Iterator
26792679
if match_trait_method(cx, expr, &paths::ITERATOR) {
26802680
let msg = "called `filter(p).flat_map(q)` on an `Iterator`";
2681-
let hint = "This is more succinctly expressed by calling `.flat_map(..)` \
2682-
and filtering by returning an empty Iterator.";
2681+
let hint = "this is more succinctly expressed by calling `.flat_map(..)` \
2682+
and filtering by returning `iter::empty()`";
26832683
span_help_and_lint(cx, FILTER_MAP, expr.span, msg, hint);
26842684
}
26852685
}
@@ -2694,8 +2694,8 @@ fn lint_filter_map_flat_map<'a, 'tcx>(
26942694
// lint if caller of `.filter_map().flat_map()` is an Iterator
26952695
if match_trait_method(cx, expr, &paths::ITERATOR) {
26962696
let msg = "called `filter_map(p).flat_map(q)` on an `Iterator`";
2697-
let hint = "This is more succinctly expressed by calling `.flat_map(..)` \
2698-
and filtering by returning an empty Iterator.";
2697+
let hint = "this is more succinctly expressed by calling `.flat_map(..)` \
2698+
and filtering by returning `iter::empty()`";
26992699
span_help_and_lint(cx, FILTER_MAP, expr.span, msg, hint);
27002700
}
27012701
}

tests/ui/expect.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | let _ = opt.expect("");
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::option-expect-used` implied by `-D warnings`
8-
= help: If this value is an `None`, it will panic.
8+
= help: if this value is an `None`, it will panic
99

1010
error: used `expect()` on `a Result` value
1111
--> $DIR/expect.rs:10:13
@@ -14,7 +14,7 @@ LL | let _ = res.expect("");
1414
| ^^^^^^^^^^^^^^
1515
|
1616
= note: `-D clippy::result-expect-used` implied by `-D warnings`
17-
= help: If this value is an `Err`, it will panic.
17+
= help: if this value is an `Err`, it will panic
1818

1919
error: aborting due to 2 previous errors
2020

tests/ui/filter_methods.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | let _: Vec<_> = vec![5; 6].into_iter().filter(|&x| x == 0).map(|x| x *
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::filter-map` implied by `-D warnings`
8-
= help: This is more succinctly expressed by calling `.filter_map(..)` instead.
8+
= help: this is more succinctly expressed by calling `.filter_map(..)` instead
99

1010
error: called `filter(p).flat_map(q)` on an `Iterator`
1111
--> $DIR/filter_methods.rs:7:21
@@ -17,7 +17,7 @@ LL | | .filter(|&x| x == 0)
1717
LL | | .flat_map(|x| x.checked_mul(2))
1818
| |_______________________________________^
1919
|
20-
= help: This is more succinctly expressed by calling `.flat_map(..)` and filtering by returning an empty Iterator.
20+
= help: this is more succinctly expressed by calling `.flat_map(..)` and filtering by returning `iter::empty()`
2121

2222
error: called `filter_map(p).flat_map(q)` on an `Iterator`
2323
--> $DIR/filter_methods.rs:13:21
@@ -29,7 +29,7 @@ LL | | .filter_map(|x| x.checked_mul(2))
2929
LL | | .flat_map(|x| x.checked_mul(2))
3030
| |_______________________________________^
3131
|
32-
= help: This is more succinctly expressed by calling `.flat_map(..)` and filtering by returning an empty Iterator.
32+
= help: this is more succinctly expressed by calling `.flat_map(..)` and filtering by returning `iter::empty()`
3333

3434
error: called `filter_map(p).map(q)` on an `Iterator`
3535
--> $DIR/filter_methods.rs:19:21
@@ -41,7 +41,7 @@ LL | | .filter_map(|x| x.checked_mul(2))
4141
LL | | .map(|x| x.checked_mul(2))
4242
| |__________________________________^
4343
|
44-
= help: This is more succinctly expressed by only calling `.filter_map(..)` instead.
44+
= help: this is more succinctly expressed by only calling `.filter_map(..)` instead
4545

4646
error: aborting due to 4 previous errors
4747

tests/ui/find_map.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | let _: Option<i32> = a.iter().find(|s| s.parse::<i32>().is_ok()).map(|s
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::find-map` implied by `-D warnings`
8-
= help: This is more succinctly expressed by calling `.find_map(..)` instead.
8+
= help: this is more succinctly expressed by calling `.find_map(..)` instead
99

1010
error: called `find(p).map(q)` on an `Iterator`
1111
--> $DIR/find_map.rs:22:29
@@ -20,7 +20,7 @@ LL | | _ => unreachable!(),
2020
LL | | });
2121
| |__________^
2222
|
23-
= help: This is more succinctly expressed by calling `.find_map(..)` instead.
23+
= help: this is more succinctly expressed by calling `.find_map(..)` instead
2424

2525
error: aborting due to 2 previous errors
2626

tests/ui/iter_nth.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,55 @@ LL | let bad_vec = some_vec.iter().nth(3);
55
| ^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::iter-nth` implied by `-D warnings`
8-
= help: Calling `.get()` is both faster and more readable
8+
= help: calling `.get()` is both faster and more readable
99

1010
error: called `.iter().nth()` on a slice
1111
--> $DIR/iter_nth.rs:34:26
1212
|
1313
LL | let bad_slice = &some_vec[..].iter().nth(3);
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
1515
|
16-
= help: Calling `.get()` is both faster and more readable
16+
= help: calling `.get()` is both faster and more readable
1717

1818
error: called `.iter().nth()` on a slice
1919
--> $DIR/iter_nth.rs:35:31
2020
|
2121
LL | let bad_boxed_slice = boxed_slice.iter().nth(3);
2222
| ^^^^^^^^^^^^^^^^^^^^^^^^^
2323
|
24-
= help: Calling `.get()` is both faster and more readable
24+
= help: calling `.get()` is both faster and more readable
2525

2626
error: called `.iter().nth()` on a VecDeque
2727
--> $DIR/iter_nth.rs:36:29
2828
|
2929
LL | let bad_vec_deque = some_vec_deque.iter().nth(3);
3030
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3131
|
32-
= help: Calling `.get()` is both faster and more readable
32+
= help: calling `.get()` is both faster and more readable
3333

3434
error: called `.iter_mut().nth()` on a Vec
3535
--> $DIR/iter_nth.rs:41:23
3636
|
3737
LL | let bad_vec = some_vec.iter_mut().nth(3);
3838
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
3939
|
40-
= help: Calling `.get_mut()` is both faster and more readable
40+
= help: calling `.get_mut()` is both faster and more readable
4141

4242
error: called `.iter_mut().nth()` on a slice
4343
--> $DIR/iter_nth.rs:44:26
4444
|
4545
LL | let bad_slice = &some_vec[..].iter_mut().nth(3);
4646
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4747
|
48-
= help: Calling `.get_mut()` is both faster and more readable
48+
= help: calling `.get_mut()` is both faster and more readable
4949

5050
error: called `.iter_mut().nth()` on a VecDeque
5151
--> $DIR/iter_nth.rs:47:29
5252
|
5353
LL | let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
5454
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5555
|
56-
= help: Calling `.get_mut()` is both faster and more readable
56+
= help: calling `.get_mut()` is both faster and more readable
5757

5858
error: aborting due to 7 previous errors
5959

tests/ui/iter_skip_next.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@ LL | let _ = some_vec.iter().skip(42).next();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::iter-skip-next` implied by `-D warnings`
8-
= help: This is more succinctly expressed by calling `nth(x)`.
8+
= help: this is more succinctly expressed by calling `nth(x)`
99

1010
error: called `skip(x).next()` on an iterator
1111
--> $DIR/iter_skip_next.rs:14:13
1212
|
1313
LL | let _ = some_vec.iter().cycle().skip(42).next();
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1515
|
16-
= help: This is more succinctly expressed by calling `nth(x)`.
16+
= help: this is more succinctly expressed by calling `nth(x)`
1717

1818
error: called `skip(x).next()` on an iterator
1919
--> $DIR/iter_skip_next.rs:15:13
2020
|
2121
LL | let _ = (1..10).skip(10).next();
2222
| ^^^^^^^^^^^^^^^^^^^^^^^
2323
|
24-
= help: This is more succinctly expressed by calling `nth(x)`.
24+
= help: this is more succinctly expressed by calling `nth(x)`
2525

2626
error: called `skip(x).next()` on an iterator
2727
--> $DIR/iter_skip_next.rs:16:14
2828
|
2929
LL | let _ = &some_vec[..].iter().skip(3).next();
3030
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3131
|
32-
= help: This is more succinctly expressed by calling `nth(x)`.
32+
= help: this is more succinctly expressed by calling `nth(x)`
3333

3434
error: aborting due to 4 previous errors
3535

tests/ui/ok_expect.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,39 @@ LL | res.ok().expect("disaster!");
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::ok-expect` implied by `-D warnings`
8-
= help: You can call `expect()` directly on the `Result`
8+
= help: you can call `expect()` directly on the `Result`
99

1010
error: called `ok().expect()` on a `Result` value
1111
--> $DIR/ok_expect.rs:20:5
1212
|
1313
LL | res3.ok().expect("whoof");
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1515
|
16-
= help: You can call `expect()` directly on the `Result`
16+
= help: you can call `expect()` directly on the `Result`
1717

1818
error: called `ok().expect()` on a `Result` value
1919
--> $DIR/ok_expect.rs:22:5
2020
|
2121
LL | res4.ok().expect("argh");
2222
| ^^^^^^^^^^^^^^^^^^^^^^^^
2323
|
24-
= help: You can call `expect()` directly on the `Result`
24+
= help: you can call `expect()` directly on the `Result`
2525

2626
error: called `ok().expect()` on a `Result` value
2727
--> $DIR/ok_expect.rs:24:5
2828
|
2929
LL | res5.ok().expect("oops");
3030
| ^^^^^^^^^^^^^^^^^^^^^^^^
3131
|
32-
= help: You can call `expect()` directly on the `Result`
32+
= help: you can call `expect()` directly on the `Result`
3333

3434
error: called `ok().expect()` on a `Result` value
3535
--> $DIR/ok_expect.rs:26:5
3636
|
3737
LL | res6.ok().expect("meh");
3838
| ^^^^^^^^^^^^^^^^^^^^^^^
3939
|
40-
= help: You can call `expect()` directly on the `Result`
40+
= help: you can call `expect()` directly on the `Result`
4141

4242
error: aborting due to 5 previous errors
4343

tests/ui/unwrap.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | let _ = opt.unwrap();
55
| ^^^^^^^^^^^^
66
|
77
= note: `-D clippy::option-unwrap-used` implied by `-D warnings`
8-
= help: If you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message.
8+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
99

1010
error: used `unwrap()` on `a Result` value
1111
--> $DIR/unwrap.rs:10:13
@@ -14,7 +14,7 @@ LL | let _ = res.unwrap();
1414
| ^^^^^^^^^^^^
1515
|
1616
= note: `-D clippy::result-unwrap-used` implied by `-D warnings`
17-
= help: If you don't want to handle the `Err` case gracefully, consider using `expect()` to provide a better panic message.
17+
= help: if you don't want to handle the `Err` case gracefully, consider using `expect()` to provide a better panic message
1818

1919
error: aborting due to 2 previous errors
2020

0 commit comments

Comments
 (0)