about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2022-10-10 21:51:24 +0200
committerest31 <MTest31@outlook.com>2022-10-24 22:05:39 +0200
commit748169deaa3c57e15e3a84bb90e033dddaa64e03 (patch)
tree264cdc281a8d1f03a46545d5e69ea9789dff2b8d /tests
parent01e651f2feea84ce0b4551a71101f7b29bcc65cb (diff)
downloadrust-748169deaa3c57e15e3a84bb90e033dddaa64e03.tar.gz
rust-748169deaa3c57e15e3a84bb90e033dddaa64e03.zip
Don't fire the lint if there is a type annotation
Sometimes type annotations are needed for type inferrence to work,
or because of coercions. We don't know this, and we also don't
want users to possibly repeat the entire pattern.
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/manual_let_else.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/ui/manual_let_else.rs b/tests/ui/manual_let_else.rs
index 9e5df65b74d..9046c0affb5 100644
--- a/tests/ui/manual_let_else.rs
+++ b/tests/ui/manual_let_else.rs
@@ -197,4 +197,8 @@ fn not_fire() {
 
     // Already a let-else
     let Some(a) = (if let Some(b) = Some(Some(())) { b } else { return }) else { panic!() };
+
+    // If a type annotation is present, don't lint as
+    // expressing the type might be too hard
+    let v: () = if let Some(v_some) = g() { v_some } else { panic!() };
 }