From cc73abf72c46d9f13a176d93d1d38f3a72d638e3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 18 Jun 2021 23:33:01 +0300 Subject: minor: use minicore --- .../handlers/missing_ok_or_some_in_tail_expr.rs | 76 ++-------------------- 1 file changed, 6 insertions(+), 70 deletions(-) (limited to 'crates/ide_diagnostics') diff --git a/crates/ide_diagnostics/src/handlers/missing_ok_or_some_in_tail_expr.rs b/crates/ide_diagnostics/src/handlers/missing_ok_or_some_in_tail_expr.rs index 63de54570..c0edcd7d3 100644 --- a/crates/ide_diagnostics/src/handlers/missing_ok_or_some_in_tail_expr.rs +++ b/crates/ide_diagnostics/src/handlers/missing_ok_or_some_in_tail_expr.rs @@ -49,26 +49,15 @@ mod tests { fn test_wrap_return_type_option() { check_fix( r#" -//- /main.rs crate:main deps:core -use core::option::Option::{self, Some, None}; - +//- minicore: option, result fn div(x: i32, y: i32) -> Option { if y == 0 { return None; } x / y$0 } -//- /core/lib.rs crate:core -pub mod result { - pub enum Result { Ok(T), Err(E) } -} -pub mod option { - pub enum Option { Some(T), None } -} "#, r#" -use core::option::Option::{self, Some, None}; - fn div(x: i32, y: i32) -> Option { if y == 0 { return None; @@ -83,26 +72,15 @@ fn div(x: i32, y: i32) -> Option { fn test_wrap_return_type() { check_fix( r#" -//- /main.rs crate:main deps:core -use core::result::Result::{self, Ok, Err}; - +//- minicore: option, result fn div(x: i32, y: i32) -> Result { if y == 0 { return Err(()); } x / y$0 } -//- /core/lib.rs crate:core -pub mod result { - pub enum Result { Ok(T), Err(E) } -} -pub mod option { - pub enum Option { Some(T), None } -} "#, r#" -use core::result::Result::{self, Ok, Err}; - fn div(x: i32, y: i32) -> Result { if y == 0 { return Err(()); @@ -117,26 +95,15 @@ fn div(x: i32, y: i32) -> Result { fn test_wrap_return_type_handles_generic_functions() { check_fix( r#" -//- /main.rs crate:main deps:core -use core::result::Result::{self, Ok, Err}; - +//- minicore: option, result fn div(x: T) -> Result { if x == 0 { return Err(7); } $0x } -//- /core/lib.rs crate:core -pub mod result { - pub enum Result { Ok(T), Err(E) } -} -pub mod option { - pub enum Option { Some(T), None } -} "#, r#" -use core::result::Result::{self, Ok, Err}; - fn div(x: T) -> Result { if x == 0 { return Err(7); @@ -151,9 +118,7 @@ fn div(x: T) -> Result { fn test_wrap_return_type_handles_type_aliases() { check_fix( r#" -//- /main.rs crate:main deps:core -use core::result::Result::{self, Ok, Err}; - +//- minicore: option, result type MyResult = Result; fn div(x: i32, y: i32) -> MyResult { @@ -162,17 +127,8 @@ fn div(x: i32, y: i32) -> MyResult { } x $0/ y } -//- /core/lib.rs crate:core -pub mod result { - pub enum Result { Ok(T), Err(E) } -} -pub mod option { - pub enum Option { Some(T), None } -} "#, r#" -use core::result::Result::{self, Ok, Err}; - type MyResult = Result; fn div(x: i32, y: i32) -> MyResult { @@ -189,18 +145,8 @@ fn div(x: i32, y: i32) -> MyResult { fn test_wrap_return_type_not_applicable_when_expr_type_does_not_match_ok_type() { check_diagnostics( r#" -//- /main.rs crate:main deps:core -use core::result::Result::{self, Ok, Err}; - +//- minicore: option, result fn foo() -> Result<(), i32> { 0 } - -//- /core/lib.rs crate:core -pub mod result { - pub enum Result { Ok(T), Err(E) } -} -pub mod option { - pub enum Option { Some(T), None } -} "#, ); } @@ -209,20 +155,10 @@ pub mod option { fn test_wrap_return_type_not_applicable_when_return_type_is_not_result_or_option() { check_diagnostics( r#" -//- /main.rs crate:main deps:core -use core::result::Result::{self, Ok, Err}; - +//- minicore: option, result enum SomeOtherEnum { Ok(i32), Err(String) } fn foo() -> SomeOtherEnum { 0 } - -//- /core/lib.rs crate:core -pub mod result { - pub enum Result { Ok(T), Err(E) } -} -pub mod option { - pub enum Option { Some(T), None } -} "#, ); } -- cgit v1.2.3