diff options
author | Lukas Wirth <[email protected]> | 2021-03-30 20:43:23 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-03-30 22:23:00 +0100 |
commit | 6f0575f08adca0c8a8f38a301913a1cfe636eb94 (patch) | |
tree | ce24189f7b8c3f71726edb5cb95d05c6ae927d80 /crates/hir_ty/src/tests | |
parent | 0b68e03bf56c00f63fcc65e7879cc64c6d5c4f30 (diff) |
Fix generic arguments being incorrectly offset in qualified trait casts
Diffstat (limited to 'crates/hir_ty/src/tests')
-rw-r--r-- | crates/hir_ty/src/tests/traits.rs | 43 |
1 files changed, 43 insertions, 0 deletions
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 | } | ||