]> git.lizzy.rs Git - rust.git/commitdiff
Remove #[should_panic] from call_info tests
authorJeremy Kolb <kjeremy@gmail.com>
Sat, 11 Apr 2020 19:47:09 +0000 (15:47 -0400)
committerJeremy Kolb <kjeremy@gmail.com>
Sat, 11 Apr 2020 19:47:09 +0000 (15:47 -0400)
crates/ra_ide/src/call_info.rs

index ca57eceff7889ab053f7d879e826c9b7d29c9b3f..f95b6baf3d47a677f14c40eb62deb1af5c570e07 100644 (file)
@@ -208,9 +208,20 @@ fn label(&self) -> String {
         }
     }
 
-    fn call_info(text: &str) -> CallInfo {
+    fn call_info_helper(text: &str) -> Option<CallInfo> {
         let (analysis, position) = single_file_with_position(text);
-        analysis.call_info(position).unwrap().unwrap()
+        analysis.call_info(position).unwrap()
+    }
+
+    fn call_info(text: &str) -> CallInfo {
+        let info = call_info_helper(text);
+        assert!(info.is_some());
+        info.unwrap()
+    }
+
+    fn no_call_info(text: &str) {
+        let info = call_info_helper(text);
+        assert!(info.is_none());
     }
 
     #[test]
@@ -558,9 +569,8 @@ fn main() {
     }
 
     #[test]
-    #[should_panic]
     fn cant_call_named_structs() {
-        let _ = call_info(
+        no_call_info(
             r#"
 struct TS { x: u32, y: i32 }
 fn main() {
@@ -594,9 +604,8 @@ fn main() {
     }
 
     #[test]
-    #[should_panic]
     fn cant_call_enum_records() {
-        let _ = call_info(
+        no_call_info(
             r#"
 enum E {
     /// A Variant