about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-09-10 13:18:06 +0000
committerbors <bors@rust-lang.org>2022-09-10 13:18:06 +0000
commitda8afc9ecfe4cdec3b4e07f38e2671578765c6b1 (patch)
treefac4a35c73b06b8003e0dc3c617822a1535e900e /tests/ui
parent5652ccbc0ff4e3895caca34a147db04c40d734c6 (diff)
parentbdb13cd887c9068262e230bd38730d360a7db0c5 (diff)
downloadrust-da8afc9ecfe4cdec3b4e07f38e2671578765c6b1.tar.gz
rust-da8afc9ecfe4cdec3b4e07f38e2671578765c6b1.zip
Auto merge of #9453 - kraktus:a_on_re_state, r=Jarcho
[`assertions_on_result_states`]: Fix suggestion when `assert!` is not in a statement.

fix https://github.com/rust-lang/rust-clippy/issues/9450

changelog: [`assertions_on_result_states`]: Fix suggestion when `assert!` is not in a statement.
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/assertions_on_result_states.fixed6
-rw-r--r--tests/ui/assertions_on_result_states.rs6
-rw-r--r--tests/ui/assertions_on_result_states.stderr8
3 files changed, 19 insertions, 1 deletions
diff --git a/tests/ui/assertions_on_result_states.fixed b/tests/ui/assertions_on_result_states.fixed
index 795f435f24c..2bb755290c5 100644
--- a/tests/ui/assertions_on_result_states.fixed
+++ b/tests/ui/assertions_on_result_states.fixed
@@ -75,3 +75,9 @@ fn main() {
     let r: Result<Foo, Foo> = Err(Foo);
     assert!(r.is_err());
 }
+
+#[allow(dead_code)]
+fn issue9450() {
+    let res: Result<i32, i32> = Ok(1);
+    res.unwrap_err();
+}
diff --git a/tests/ui/assertions_on_result_states.rs b/tests/ui/assertions_on_result_states.rs
index 1101aec1e1b..d8a9bd2f1c4 100644
--- a/tests/ui/assertions_on_result_states.rs
+++ b/tests/ui/assertions_on_result_states.rs
@@ -75,3 +75,9 @@ fn main() {
     let r: Result<Foo, Foo> = Err(Foo);
     assert!(r.is_err());
 }
+
+#[allow(dead_code)]
+fn issue9450() {
+    let res: Result<i32, i32> = Ok(1);
+    assert!(res.is_err())
+}
diff --git a/tests/ui/assertions_on_result_states.stderr b/tests/ui/assertions_on_result_states.stderr
index 97a5f3dfca4..298d63c9c34 100644
--- a/tests/ui/assertions_on_result_states.stderr
+++ b/tests/ui/assertions_on_result_states.stderr
@@ -36,5 +36,11 @@ error: called `assert!` with `Result::is_err`
 LL |     assert!(r.is_err());
    |     ^^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap_err()`
 
-error: aborting due to 6 previous errors
+error: called `assert!` with `Result::is_err`
+  --> $DIR/assertions_on_result_states.rs:82:5
+   |
+LL |     assert!(res.is_err())
+   |     ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err();`
+
+error: aborting due to 7 previous errors