about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-12-07 00:07:46 +0000
committerbors <bors@rust-lang.org>2021-12-07 00:07:46 +0000
commitf615ea474b7658c5dac0e4020b6990b4fd509f83 (patch)
treebb2d91647d6e94b61f18be466c77292d53cbf2b9 /tests
parent48d939f5166a19529a9e4723ed3bf5bab2314563 (diff)
parent01ca66cbd70ecfa7ba6294219ecba9f6ad9c8b2b (diff)
downloadrust-f615ea474b7658c5dac0e4020b6990b4fd509f83.tar.gz
rust-f615ea474b7658c5dac0e4020b6990b4fd509f83.zip
Auto merge of #8080 - dswij:8019, r=giraffate
Fix FP on `question_mark` if returned object is not local

Closes #8019

changelog: [`question_mark`] Fix FP when returned object is not local
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/question_mark.fixed19
-rw-r--r--tests/ui/question_mark.rs19
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/ui/question_mark.fixed b/tests/ui/question_mark.fixed
index e93469e5f55..13ce0f32d4b 100644
--- a/tests/ui/question_mark.fixed
+++ b/tests/ui/question_mark.fixed
@@ -136,6 +136,24 @@ fn result_func(x: Result<i32, i32>) -> Result<i32, i32> {
     Ok(y)
 }
 
+// see issue #8019
+pub enum NotOption {
+    None,
+    First,
+    AfterFirst,
+}
+
+fn obj(_: i32) -> Result<(), NotOption> {
+    Err(NotOption::First)
+}
+
+fn f() -> NotOption {
+    if obj(2).is_err() {
+        return NotOption::None;
+    }
+    NotOption::First
+}
+
 fn main() {
     some_func(Some(42));
     some_func(None);
@@ -157,4 +175,5 @@ fn main() {
     func();
 
     let _ = result_func(Ok(42));
+    let _ = f();
 }
diff --git a/tests/ui/question_mark.rs b/tests/ui/question_mark.rs
index dd179e9bee8..60590fd9311 100644
--- a/tests/ui/question_mark.rs
+++ b/tests/ui/question_mark.rs
@@ -168,6 +168,24 @@ fn result_func(x: Result<i32, i32>) -> Result<i32, i32> {
     Ok(y)
 }
 
+// see issue #8019
+pub enum NotOption {
+    None,
+    First,
+    AfterFirst,
+}
+
+fn obj(_: i32) -> Result<(), NotOption> {
+    Err(NotOption::First)
+}
+
+fn f() -> NotOption {
+    if obj(2).is_err() {
+        return NotOption::None;
+    }
+    NotOption::First
+}
+
 fn main() {
     some_func(Some(42));
     some_func(None);
@@ -189,4 +207,5 @@ fn main() {
     func();
 
     let _ = result_func(Ok(42));
+    let _ = f();
 }