aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests/traits.rs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-06-01 12:39:19 +0100
committerJonas Schievink <[email protected]>2021-06-01 12:39:19 +0100
commitf96c1a0414ee302fe96503d89f2998483345c8a9 (patch)
tree6de19b3c128809cd56641f70873c35f17974aced /crates/hir_ty/src/tests/traits.rs
parent71117e6812f87e014bc8e984e195a75e222ac227 (diff)
Implement per-edition preludes
Diffstat (limited to 'crates/hir_ty/src/tests/traits.rs')
-rw-r--r--crates/hir_ty/src/tests/traits.rs48
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::*; 23pub mod prelude {
24mod 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::*; 140pub mod ops {
140mod 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::*; 147pub mod result {
148mod 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
159pub 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::*; 198pub mod result {
194mod 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
216pub 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]
220use alloc::collections::Vec; 231use alloc::collections::Vec;
221 232
222fn test() { 233fn 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::*; 242pub mod iter {
232mod iter { 243 pub trait IntoIterator {
233 trait IntoIterator {
234 type Item; 244 type Item;
235 } 245 }
236} 246}
247pub 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]
239mod collections { 255mod collections {
240 struct Vec<T> {} 256 struct Vec<T> {}
241 impl<T> Vec<T> { 257 impl<T> Vec<T> {