diff options
Diffstat (limited to 'crates/hir_def/src/item_tree/tests.rs')
-rw-r--r-- | crates/hir_def/src/item_tree/tests.rs | 122 |
1 files changed, 121 insertions, 1 deletions
diff --git a/crates/hir_def/src/item_tree/tests.rs b/crates/hir_def/src/item_tree/tests.rs index 100ae9b97..6407871b5 100644 --- a/crates/hir_def/src/item_tree/tests.rs +++ b/crates/hir_def/src/item_tree/tests.rs | |||
@@ -183,7 +183,11 @@ trait Tr: SuperTrait + 'lifetime { | |||
183 | _: (), | 183 | _: (), |
184 | ) -> (); | 184 | ) -> (); |
185 | 185 | ||
186 | pub(self) trait Tr: SuperTrait + 'lifetime { | 186 | pub(self) trait Tr<Self>: SuperTrait + 'lifetime |
187 | where | ||
188 | Self: SuperTrait, | ||
189 | Self: 'lifetime | ||
190 | { | ||
187 | pub(self) type Assoc: AssocBound = Default; | 191 | pub(self) type Assoc: AssocBound = Default; |
188 | 192 | ||
189 | // flags = 0x1 | 193 | // flags = 0x1 |
@@ -207,6 +211,8 @@ mod inline { | |||
207 | 211 | ||
208 | fn fn_in_module() {} | 212 | fn fn_in_module() {} |
209 | } | 213 | } |
214 | |||
215 | mod outline; | ||
210 | "#, | 216 | "#, |
211 | expect![[r##" | 217 | expect![[r##" |
212 | #[doc = " outer"] // AttrId { is_doc_comment: true, ast_index: 0 } | 218 | #[doc = " outer"] // AttrId { is_doc_comment: true, ast_index: 0 } |
@@ -217,6 +223,8 @@ mod inline { | |||
217 | // flags = 0x2 | 223 | // flags = 0x2 |
218 | pub(self) fn fn_in_module() -> (); | 224 | pub(self) fn fn_in_module() -> (); |
219 | } | 225 | } |
226 | |||
227 | pub(self) mod outline; | ||
220 | "##]], | 228 | "##]], |
221 | ); | 229 | ); |
222 | } | 230 | } |
@@ -242,3 +250,115 @@ m!(); | |||
242 | "#]], | 250 | "#]], |
243 | ); | 251 | ); |
244 | } | 252 | } |
253 | |||
254 | #[test] | ||
255 | fn mod_paths() { | ||
256 | check( | ||
257 | r#" | ||
258 | struct S { | ||
259 | a: self::Ty, | ||
260 | b: super::SuperTy, | ||
261 | c: super::super::SuperSuperTy, | ||
262 | d: ::abs::Path, | ||
263 | e: crate::Crate, | ||
264 | f: plain::path::Ty, | ||
265 | } | ||
266 | "#, | ||
267 | expect![[r#" | ||
268 | pub(self) struct S { | ||
269 | pub(self) a: self::Ty, | ||
270 | pub(self) b: super::SuperTy, | ||
271 | pub(self) c: super::super::SuperSuperTy, | ||
272 | pub(self) d: ::abs::Path, | ||
273 | pub(self) e: crate::Crate, | ||
274 | pub(self) f: plain::path::Ty, | ||
275 | } | ||
276 | "#]], | ||
277 | ) | ||
278 | } | ||
279 | |||
280 | #[test] | ||
281 | fn types() { | ||
282 | check( | ||
283 | r#" | ||
284 | struct S { | ||
285 | a: Mixed<'a, T, Item=(), OtherItem=u8>, | ||
286 | b: <Fully as Qualified>::Syntax, | ||
287 | c: <TypeAnchored>::Path::<'a>, | ||
288 | } | ||
289 | "#, | ||
290 | expect![[r#" | ||
291 | pub(self) struct S { | ||
292 | pub(self) a: Mixed<'a, T, Item = (), OtherItem = u8>, | ||
293 | pub(self) b: Qualified<Self=Fully>::Syntax, | ||
294 | pub(self) c: <TypeAnchored>::Path<'a>, | ||
295 | } | ||
296 | "#]], | ||
297 | ) | ||
298 | } | ||
299 | |||
300 | #[test] | ||
301 | fn generics() { | ||
302 | check( | ||
303 | r#" | ||
304 | struct S<'a, 'b: 'a, T: Copy + 'a + 'b, const K: u8 = 0> { | ||
305 | field: &'a &'b T, | ||
306 | } | ||
307 | |||
308 | struct Tuple<T: Copy>(T); | ||
309 | |||
310 | impl<'a, 'b: 'a, T: Copy + 'a + 'b, const K: u8 = 0> S<'a, 'b, T, K> { | ||
311 | fn f<G: 'a>(arg: impl Copy) -> impl Copy {} | ||
312 | } | ||
313 | |||
314 | enum Enum<'a, T, const U: u8> {} | ||
315 | union Union<'a, T, const U: u8> {} | ||
316 | |||
317 | trait Tr<'a, T: 'a>: Super {} | ||
318 | "#, | ||
319 | expect![[r#" | ||
320 | pub(self) struct S<'a, 'b, T, const K: u8> | ||
321 | where | ||
322 | T: Copy, | ||
323 | T: 'a, | ||
324 | T: 'b | ||
325 | { | ||
326 | pub(self) field: &'a &'b T, | ||
327 | } | ||
328 | |||
329 | pub(self) struct Tuple<T>( | ||
330 | pub(self) 0: T, | ||
331 | ) | ||
332 | where | ||
333 | T: Copy; | ||
334 | |||
335 | impl<'a, 'b, T, const K: u8> S<'a, 'b, T, K> | ||
336 | where | ||
337 | T: Copy, | ||
338 | T: 'a, | ||
339 | T: 'b | ||
340 | { | ||
341 | // flags = 0x2 | ||
342 | pub(self) fn f<G, _anon_1>( | ||
343 | _: impl Copy, | ||
344 | ) -> impl Copy | ||
345 | where | ||
346 | G: 'a, | ||
347 | _anon_1: Copy; | ||
348 | } | ||
349 | |||
350 | pub(self) enum Enum<'a, T, const U: u8> { | ||
351 | } | ||
352 | |||
353 | pub(self) union Union<'a, T, const U: u8> { | ||
354 | } | ||
355 | |||
356 | pub(self) trait Tr<'a, Self, T>: Super | ||
357 | where | ||
358 | Self: Super, | ||
359 | T: 'a | ||
360 | { | ||
361 | } | ||
362 | "#]], | ||
363 | ) | ||
364 | } | ||