diff options
Diffstat (limited to 'crates/hir_ty/src/tests')
-rw-r--r-- | crates/hir_ty/src/tests/macros.rs | 26 | ||||
-rw-r--r-- | crates/hir_ty/src/tests/traits.rs | 43 |
2 files changed, 69 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs index 3eb01dbd0..86e3d8b86 100644 --- a/crates/hir_ty/src/tests/macros.rs +++ b/crates/hir_ty/src/tests/macros.rs | |||
@@ -373,6 +373,32 @@ fn recursive_inner_item_macro_rules() { | |||
373 | } | 373 | } |
374 | 374 | ||
375 | #[test] | 375 | #[test] |
376 | fn infer_macro_defining_block_with_items() { | ||
377 | check_infer( | ||
378 | r#" | ||
379 | macro_rules! foo { | ||
380 | () => {{ | ||
381 | fn bar() -> usize { 0 } | ||
382 | bar() | ||
383 | }}; | ||
384 | } | ||
385 | fn main() { | ||
386 | let _a = foo!(); | ||
387 | } | ||
388 | "#, | ||
389 | expect![[r#" | ||
390 | !15..18 '{0}': usize | ||
391 | !16..17 '0': usize | ||
392 | !0..24 '{fnbar...bar()}': usize | ||
393 | !18..21 'bar': fn bar() -> usize | ||
394 | !18..23 'bar()': usize | ||
395 | 98..122 '{ ...!(); }': () | ||
396 | 108..110 '_a': usize | ||
397 | "#]], | ||
398 | ); | ||
399 | } | ||
400 | |||
401 | #[test] | ||
376 | fn infer_type_value_macro_having_same_name() { | 402 | fn infer_type_value_macro_having_same_name() { |
377 | check_infer( | 403 | check_infer( |
378 | r#" | 404 | r#" |
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index 2ba97f814..65b71fdfa 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs | |||
@@ -3370,3 +3370,46 @@ fn test() { | |||
3370 | "#]], | 3370 | "#]], |
3371 | ) | 3371 | ) |
3372 | } | 3372 | } |
3373 | |||
3374 | #[test] | ||
3375 | fn qualified_path_as_qualified_trait() { | ||
3376 | check_infer( | ||
3377 | r#" | ||
3378 | mod foo { | ||
3379 | |||
3380 | pub trait Foo { | ||
3381 | type Target; | ||
3382 | } | ||
3383 | pub trait Bar { | ||
3384 | type Output; | ||
3385 | fn boo() -> Self::Output { | ||
3386 | loop {} | ||
3387 | } | ||
3388 | } | ||
3389 | } | ||
3390 | |||
3391 | struct F; | ||
3392 | impl foo::Foo for F { | ||
3393 | type Target = (); | ||
3394 | } | ||
3395 | impl foo::Bar for F { | ||
3396 | type Output = <F as foo::Foo>::Target; | ||
3397 | } | ||
3398 | |||
3399 | fn foo() { | ||
3400 | use foo::Bar; | ||
3401 | let x = <F as Bar>::boo(); | ||
3402 | } | ||
3403 | |||
3404 | "#, | ||
3405 | expect![[r#" | ||
3406 | 132..163 '{ ... }': Bar::Output<Self> | ||
3407 | 146..153 'loop {}': ! | ||
3408 | 151..153 '{}': () | ||
3409 | 306..358 '{ ...o(); }': () | ||
3410 | 334..335 'x': () | ||
3411 | 338..353 '<F as Bar>::boo': fn boo<F>() -> <F as Bar>::Output | ||
3412 | 338..355 '<F as ...:boo()': () | ||
3413 | "#]], | ||
3414 | ); | ||
3415 | } | ||