diff options
author | Aleksey Kladov <[email protected]> | 2021-06-18 21:33:01 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-06-18 21:33:01 +0100 |
commit | cc73abf72c46d9f13a176d93d1d38f3a72d638e3 (patch) | |
tree | 526ec0b4cf0c91baa404a7f84a486445da439ccb /crates/ide_diagnostics/src | |
parent | 181184a350046a460441209fd34821c2c796b066 (diff) |
minor: use minicore
Diffstat (limited to 'crates/ide_diagnostics/src')
-rw-r--r-- | crates/ide_diagnostics/src/handlers/missing_ok_or_some_in_tail_expr.rs | 76 |
1 files changed, 6 insertions, 70 deletions
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 { | |||
49 | fn test_wrap_return_type_option() { | 49 | fn test_wrap_return_type_option() { |
50 | check_fix( | 50 | check_fix( |
51 | r#" | 51 | r#" |
52 | //- /main.rs crate:main deps:core | 52 | //- minicore: option, result |
53 | use core::option::Option::{self, Some, None}; | ||
54 | |||
55 | fn div(x: i32, y: i32) -> Option<i32> { | 53 | fn div(x: i32, y: i32) -> Option<i32> { |
56 | if y == 0 { | 54 | if y == 0 { |
57 | return None; | 55 | return None; |
58 | } | 56 | } |
59 | x / y$0 | 57 | x / y$0 |
60 | } | 58 | } |
61 | //- /core/lib.rs crate:core | ||
62 | pub mod result { | ||
63 | pub enum Result<T, E> { Ok(T), Err(E) } | ||
64 | } | ||
65 | pub mod option { | ||
66 | pub enum Option<T> { Some(T), None } | ||
67 | } | ||
68 | "#, | 59 | "#, |
69 | r#" | 60 | r#" |
70 | use core::option::Option::{self, Some, None}; | ||
71 | |||
72 | fn div(x: i32, y: i32) -> Option<i32> { | 61 | fn div(x: i32, y: i32) -> Option<i32> { |
73 | if y == 0 { | 62 | if y == 0 { |
74 | return None; | 63 | return None; |
@@ -83,26 +72,15 @@ fn div(x: i32, y: i32) -> Option<i32> { | |||
83 | fn test_wrap_return_type() { | 72 | fn test_wrap_return_type() { |
84 | check_fix( | 73 | check_fix( |
85 | r#" | 74 | r#" |
86 | //- /main.rs crate:main deps:core | 75 | //- minicore: option, result |
87 | use core::result::Result::{self, Ok, Err}; | ||
88 | |||
89 | fn div(x: i32, y: i32) -> Result<i32, ()> { | 76 | fn div(x: i32, y: i32) -> Result<i32, ()> { |
90 | if y == 0 { | 77 | if y == 0 { |
91 | return Err(()); | 78 | return Err(()); |
92 | } | 79 | } |
93 | x / y$0 | 80 | x / y$0 |
94 | } | 81 | } |
95 | //- /core/lib.rs crate:core | ||
96 | pub mod result { | ||
97 | pub enum Result<T, E> { Ok(T), Err(E) } | ||
98 | } | ||
99 | pub mod option { | ||
100 | pub enum Option<T> { Some(T), None } | ||
101 | } | ||
102 | "#, | 82 | "#, |
103 | r#" | 83 | r#" |
104 | use core::result::Result::{self, Ok, Err}; | ||
105 | |||
106 | fn div(x: i32, y: i32) -> Result<i32, ()> { | 84 | fn div(x: i32, y: i32) -> Result<i32, ()> { |
107 | if y == 0 { | 85 | if y == 0 { |
108 | return Err(()); | 86 | return Err(()); |
@@ -117,26 +95,15 @@ fn div(x: i32, y: i32) -> Result<i32, ()> { | |||
117 | fn test_wrap_return_type_handles_generic_functions() { | 95 | fn test_wrap_return_type_handles_generic_functions() { |
118 | check_fix( | 96 | check_fix( |
119 | r#" | 97 | r#" |
120 | //- /main.rs crate:main deps:core | 98 | //- minicore: option, result |
121 | use core::result::Result::{self, Ok, Err}; | ||
122 | |||
123 | fn div<T>(x: T) -> Result<T, i32> { | 99 | fn div<T>(x: T) -> Result<T, i32> { |
124 | if x == 0 { | 100 | if x == 0 { |
125 | return Err(7); | 101 | return Err(7); |
126 | } | 102 | } |
127 | $0x | 103 | $0x |
128 | } | 104 | } |
129 | //- /core/lib.rs crate:core | ||
130 | pub mod result { | ||
131 | pub enum Result<T, E> { Ok(T), Err(E) } | ||
132 | } | ||
133 | pub mod option { | ||
134 | pub enum Option<T> { Some(T), None } | ||
135 | } | ||
136 | "#, | 105 | "#, |
137 | r#" | 106 | r#" |
138 | use core::result::Result::{self, Ok, Err}; | ||
139 | |||
140 | fn div<T>(x: T) -> Result<T, i32> { | 107 | fn div<T>(x: T) -> Result<T, i32> { |
141 | if x == 0 { | 108 | if x == 0 { |
142 | return Err(7); | 109 | return Err(7); |
@@ -151,9 +118,7 @@ fn div<T>(x: T) -> Result<T, i32> { | |||
151 | fn test_wrap_return_type_handles_type_aliases() { | 118 | fn test_wrap_return_type_handles_type_aliases() { |
152 | check_fix( | 119 | check_fix( |
153 | r#" | 120 | r#" |
154 | //- /main.rs crate:main deps:core | 121 | //- minicore: option, result |
155 | use core::result::Result::{self, Ok, Err}; | ||
156 | |||
157 | type MyResult<T> = Result<T, ()>; | 122 | type MyResult<T> = Result<T, ()>; |
158 | 123 | ||
159 | fn div(x: i32, y: i32) -> MyResult<i32> { | 124 | fn div(x: i32, y: i32) -> MyResult<i32> { |
@@ -162,17 +127,8 @@ fn div(x: i32, y: i32) -> MyResult<i32> { | |||
162 | } | 127 | } |
163 | x $0/ y | 128 | x $0/ y |
164 | } | 129 | } |
165 | //- /core/lib.rs crate:core | ||
166 | pub mod result { | ||
167 | pub enum Result<T, E> { Ok(T), Err(E) } | ||
168 | } | ||
169 | pub mod option { | ||
170 | pub enum Option<T> { Some(T), None } | ||
171 | } | ||
172 | "#, | 130 | "#, |
173 | r#" | 131 | r#" |
174 | use core::result::Result::{self, Ok, Err}; | ||
175 | |||
176 | type MyResult<T> = Result<T, ()>; | 132 | type MyResult<T> = Result<T, ()>; |
177 | 133 | ||
178 | fn div(x: i32, y: i32) -> MyResult<i32> { | 134 | fn div(x: i32, y: i32) -> MyResult<i32> { |
@@ -189,18 +145,8 @@ fn div(x: i32, y: i32) -> MyResult<i32> { | |||
189 | fn test_wrap_return_type_not_applicable_when_expr_type_does_not_match_ok_type() { | 145 | fn test_wrap_return_type_not_applicable_when_expr_type_does_not_match_ok_type() { |
190 | check_diagnostics( | 146 | check_diagnostics( |
191 | r#" | 147 | r#" |
192 | //- /main.rs crate:main deps:core | 148 | //- minicore: option, result |
193 | use core::result::Result::{self, Ok, Err}; | ||
194 | |||
195 | fn foo() -> Result<(), i32> { 0 } | 149 | fn foo() -> Result<(), i32> { 0 } |
196 | |||
197 | //- /core/lib.rs crate:core | ||
198 | pub mod result { | ||
199 | pub enum Result<T, E> { Ok(T), Err(E) } | ||
200 | } | ||
201 | pub mod option { | ||
202 | pub enum Option<T> { Some(T), None } | ||
203 | } | ||
204 | "#, | 150 | "#, |
205 | ); | 151 | ); |
206 | } | 152 | } |
@@ -209,20 +155,10 @@ pub mod option { | |||
209 | fn test_wrap_return_type_not_applicable_when_return_type_is_not_result_or_option() { | 155 | fn test_wrap_return_type_not_applicable_when_return_type_is_not_result_or_option() { |
210 | check_diagnostics( | 156 | check_diagnostics( |
211 | r#" | 157 | r#" |
212 | //- /main.rs crate:main deps:core | 158 | //- minicore: option, result |
213 | use core::result::Result::{self, Ok, Err}; | ||
214 | |||
215 | enum SomeOtherEnum { Ok(i32), Err(String) } | 159 | enum SomeOtherEnum { Ok(i32), Err(String) } |
216 | 160 | ||
217 | fn foo() -> SomeOtherEnum { 0 } | 161 | fn foo() -> SomeOtherEnum { 0 } |
218 | |||
219 | //- /core/lib.rs crate:core | ||
220 | pub mod result { | ||
221 | pub enum Result<T, E> { Ok(T), Err(E) } | ||
222 | } | ||
223 | pub mod option { | ||
224 | pub enum Option<T> { Some(T), None } | ||
225 | } | ||
226 | "#, | 162 | "#, |
227 | ); | 163 | ); |
228 | } | 164 | } |