From 215e229dd1a495cda6541371c75145ba03f62de5 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 11 Jun 2020 17:28:32 +0200 Subject: Update wrap return tests Update "no diagnostic" tests, use `()` instead of `String` --- crates/ra_ide/src/diagnostics.rs | 46 +++++++++++++++------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 0f1cb0bcc..f44feaf69 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -321,29 +321,26 @@ mod tests { fn test_wrap_return_type() { let before = r#" //- /main.rs - use core::{string::String, result::Result::{self, Ok, Err}}; + use core::result::Result::{self, Ok, Err}; - fn div(x: i32, y: i32) -> Result { + fn div(x: i32, y: i32) -> Result { if y == 0 { - return Err("div by zero".into()); + return Err(()); } x / y<|> } //- /core/lib.rs - pub mod string { - pub struct String { } - } pub mod result { pub enum Result { Ok(T), Err(E) } } "#; let after = r#" - use core::{string::String, result::Result::{self, Ok, Err}}; + use core::result::Result::{self, Ok, Err}; - fn div(x: i32, y: i32) -> Result { + fn div(x: i32, y: i32) -> Result { if y == 0 { - return Err("div by zero".into()); + return Err(()); } Ok(x / y) } @@ -386,32 +383,29 @@ mod tests { fn test_wrap_return_type_handles_type_aliases() { let before = r#" //- /main.rs - use core::{string::String, result::Result::{self, Ok, Err}}; + use core::result::Result::{self, Ok, Err}; - type MyResult = Result; + type MyResult = Result; fn div(x: i32, y: i32) -> MyResult { if y == 0 { - return Err("div by zero".into()); + return Err(()); } x <|>/ y } //- /core/lib.rs - pub mod string { - pub struct String { } - } pub mod result { pub enum Result { Ok(T), Err(E) } } "#; let after = r#" - use core::{string::String, result::Result::{self, Ok, Err}}; + use core::result::Result::{self, Ok, Err}; - type MyResult = Result; + type MyResult = Result; fn div(x: i32, y: i32) -> MyResult { if y == 0 { - return Err("div by zero".into()); + return Err(()); } Ok(x / y) } @@ -423,16 +417,13 @@ mod tests { fn test_wrap_return_type_not_applicable_when_expr_type_does_not_match_ok_type() { let content = r#" //- /main.rs - use std::{string::String, result::Result::{self, Ok, Err}}; + use core::result::Result::{self, Ok, Err}; - fn foo() -> Result { + fn foo() -> Result<(), i32> { 0<|> } - //- /std/lib.rs - pub mod string { - pub struct String { } - } + //- /core/lib.rs pub mod result { pub enum Result { Ok(T), Err(E) } } @@ -444,7 +435,7 @@ mod tests { fn test_wrap_return_type_not_applicable_when_return_type_is_not_result() { let content = r#" //- /main.rs - use std::{string::String, result::Result::{self, Ok, Err}}; + use core::result::Result::{self, Ok, Err}; enum SomeOtherEnum { Ok(i32), @@ -455,10 +446,7 @@ mod tests { 0<|> } - //- /std/lib.rs - pub mod string { - pub struct String { } - } + //- /core/lib.rs pub mod result { pub enum Result { Ok(T), Err(E) } } -- cgit v1.2.3