Skip to content

Commit a1662f3

Browse files
committed
Fix linting problems
1 parent be48609 commit a1662f3

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3273,7 +3273,6 @@ Released 2018-09-13
32733273
[`exhaustive_enums`]: https://rust-lang.github.io/rust-clippy/master/index.html#exhaustive_enums
32743274
[`exhaustive_structs`]: https://rust-lang.github.io/rust-clippy/master/index.html#exhaustive_structs
32753275
[`exit`]: https://rust-lang.github.io/rust-clippy/master/index.html#exit
3276-
[`expect_err`]: https://rust-lang.github.io/rust-clippy/master/index.html#expect_err
32773276
[`expect_fun_call`]: https://rust-lang.github.io/rust-clippy/master/index.html#expect_fun_call
32783277
[`expect_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#expect_used
32793278
[`expl_impl_clone_on_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#expl_impl_clone_on_copy

clippy_lints/src/methods/expect_err.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ use rustc_lint::LateContext;
44
use rustc_span::sym;
55

66
pub(super) fn check(cx: &LateContext<'_>, expr: &rustc_hir::Expr<'_>, recv: &rustc_hir::Expr<'_>) {
7-
if_chain! {
8-
if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(recv), sym::Result);
9-
10-
then {
11-
span_lint_and_help(cx, EXPECT_ERR, expr.span, "Called `.err().expect()` on a `Result` value", None, "`.expect_err()` can be called instead")
12-
}
7+
if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(recv), sym::Result) {
8+
span_lint_and_help(
9+
cx,
10+
EXPECT_ERR,
11+
expr.span,
12+
"called `.err().expect()` on a `Result` value",
13+
None,
14+
"`.expect_err()` can be called instead",
15+
);
1316
}
1417
}

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,6 +2191,7 @@ impl_lint_pass!(Methods => [
21912191
NEEDLESS_SPLITN,
21922192
UNNECESSARY_TO_OWNED,
21932193
UNNECESSARY_JOIN,
2194+
EXPECT_ERR,
21942195
]);
21952196

21962197
/// Extracts a method call name, args, and `Span` of the method name.

tests/ui/expect_err.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Called `.err().expect()` on a `Result` value
1+
error: called `.err().expect()` on a `Result` value
22
--> $DIR/expect_err.rs:3:5
33
|
44
LL | x.err().expect("Testing expect_err");

0 commit comments

Comments
 (0)