]> git.lizzy.rs Git - rust.git/commitdiff
Ensure `expect_fun_call` bad suggestion is fixed
authorMichael Wright <mikerite@lavabit.com>
Wed, 6 Mar 2019 05:00:05 +0000 (07:00 +0200)
committerMichael Wright <mikerite@lavabit.com>
Wed, 6 Mar 2019 05:00:05 +0000 (07:00 +0200)
Closes #3839

tests/ui/expect_fun_call.fixed
tests/ui/expect_fun_call.rs
tests/ui/expect_fun_call.stderr

index 1f74f6b8cf14be08ef0b6c2887a8191478552586..e111ee3dfeda50b4723c6d02630f1e7237c0dc68 100644 (file)
@@ -81,4 +81,7 @@ fn main() {
         Some("foo").unwrap_or_else(|| { panic!(get_static_str()) });
         Some("foo").unwrap_or_else(|| { panic!(get_non_static_str(&0).to_string()) });
     }
+
+    //Issue #3839
+    Some(true).unwrap_or_else(|| panic!("key {}, {}", 1, 2));
 }
index 2d8b4925f358a117dfa7d55ec6c0adbd0f819a04..891ec883120c1f4a5a535629991ef2f9806e415b 100644 (file)
@@ -81,4 +81,7 @@ fn get_non_static_str(_: &u32) -> &str {
         Some("foo").expect(get_static_str());
         Some("foo").expect(get_non_static_str(&0));
     }
+
+    //Issue #3839
+    Some(true).expect(&format!("key {}, {}", 1, 2));
 }
index 900e251d964c20b2b91da0ee38fa3363c804214b..bb16fabd973bafc48d7583f92883758a6e48c94e 100644 (file)
@@ -60,5 +60,11 @@ error: use of `expect` followed by a function call
 LL |         Some("foo").expect(get_non_static_str(&0));
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!(get_non_static_str(&0).to_string()) })`
 
-error: aborting due to 10 previous errors
+error: use of `expect` followed by a function call
+  --> $DIR/expect_fun_call.rs:86:16
+   |
+LL |     Some(true).expect(&format!("key {}, {}", 1, 2));
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("key {}, {}", 1, 2))`
+
+error: aborting due to 11 previous errors