diff options
Diffstat (limited to 'crates/hir_ty/src/tests/traits.rs')
-rw-r--r-- | crates/hir_ty/src/tests/traits.rs | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index 49add4ab9..588f0d1d4 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs | |||
@@ -20,11 +20,12 @@ fn test() { | |||
20 | } //^ u64 | 20 | } //^ u64 |
21 | 21 | ||
22 | //- /core.rs crate:core | 22 | //- /core.rs crate:core |
23 | #[prelude_import] use future::*; | 23 | pub mod prelude { |
24 | mod future { | 24 | pub mod rust_2018 { |
25 | #[lang = "future_trait"] | 25 | #[lang = "future_trait"] |
26 | trait Future { | 26 | pub trait Future { |
27 | type Output; | 27 | type Output; |
28 | } | ||
28 | } | 29 | } |
29 | } | 30 | } |
30 | "#, | 31 | "#, |
@@ -136,17 +137,15 @@ fn test() { | |||
136 | } //^ i32 | 137 | } //^ i32 |
137 | 138 | ||
138 | //- /core.rs crate:core | 139 | //- /core.rs crate:core |
139 | #[prelude_import] use ops::*; | 140 | pub mod ops { |
140 | mod ops { | 141 | pub trait Try { |
141 | trait Try { | ||
142 | type Ok; | 142 | type Ok; |
143 | type Error; | 143 | type Error; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | #[prelude_import] use result::*; | 147 | pub mod result { |
148 | mod result { | 148 | pub enum Result<O, E> { |
149 | enum Result<O, E> { | ||
150 | Ok(O), | 149 | Ok(O), |
151 | Err(E) | 150 | Err(E) |
152 | } | 151 | } |
@@ -156,6 +155,12 @@ mod result { | |||
156 | type Error = E; | 155 | type Error = E; |
157 | } | 156 | } |
158 | } | 157 | } |
158 | |||
159 | pub mod prelude { | ||
160 | pub mod rust_2018 { | ||
161 | pub use crate::{result::*, ops::*}; | ||
162 | } | ||
163 | } | ||
159 | "#, | 164 | "#, |
160 | ); | 165 | ); |
161 | } | 166 | } |
@@ -190,8 +195,7 @@ mov convert { | |||
190 | impl<T> From<T> for T {} | 195 | impl<T> From<T> for T {} |
191 | } | 196 | } |
192 | 197 | ||
193 | #[prelude_import] use result::*; | 198 | pub mod result { |
194 | mod result { | ||
195 | use crate::convert::From; | 199 | use crate::convert::From; |
196 | use crate::ops::{Try, FromResidual}; | 200 | use crate::ops::{Try, FromResidual}; |
197 | 201 | ||
@@ -208,6 +212,12 @@ mod result { | |||
208 | 212 | ||
209 | impl<T, E, F: From<E>> FromResidual<Result<Infallible, E>> for Result<T, F> {} | 213 | impl<T, E, F: From<E>> FromResidual<Result<Infallible, E>> for Result<T, F> {} |
210 | } | 214 | } |
215 | |||
216 | pub mod prelude { | ||
217 | pub mod rust_2018 { | ||
218 | pub use crate::result::*; | ||
219 | } | ||
220 | } | ||
211 | "#, | 221 | "#, |
212 | ); | 222 | ); |
213 | } | 223 | } |
@@ -217,6 +227,7 @@ fn infer_for_loop() { | |||
217 | check_types( | 227 | check_types( |
218 | r#" | 228 | r#" |
219 | //- /main.rs crate:main deps:core,alloc | 229 | //- /main.rs crate:main deps:core,alloc |
230 | #![no_std] | ||
220 | use alloc::collections::Vec; | 231 | use alloc::collections::Vec; |
221 | 232 | ||
222 | fn test() { | 233 | fn test() { |
@@ -228,14 +239,19 @@ fn test() { | |||
228 | } | 239 | } |
229 | 240 | ||
230 | //- /core.rs crate:core | 241 | //- /core.rs crate:core |
231 | #[prelude_import] use iter::*; | 242 | pub mod iter { |
232 | mod iter { | 243 | pub trait IntoIterator { |
233 | trait IntoIterator { | ||
234 | type Item; | 244 | type Item; |
235 | } | 245 | } |
236 | } | 246 | } |
247 | pub mod prelude { | ||
248 | pub mod rust_2018 { | ||
249 | pub use crate::iter::*; | ||
250 | } | ||
251 | } | ||
237 | 252 | ||
238 | //- /alloc.rs crate:alloc deps:core | 253 | //- /alloc.rs crate:alloc deps:core |
254 | #![no_std] | ||
239 | mod collections { | 255 | mod collections { |
240 | struct Vec<T> {} | 256 | struct Vec<T> {} |
241 | impl<T> Vec<T> { | 257 | impl<T> Vec<T> { |