diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-31 10:52:47 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-31 10:52:47 +0100 |
commit | c69f6f31d15826cfa69e212a739fe7e4cd58b39d (patch) | |
tree | 372d73d9963179349c32d7eef6fb4f3669559dec /crates/hir_ty | |
parent | 2436621b6c5e636fa112cd5abfdd03511c9561e0 (diff) | |
parent | 6f0575f08adca0c8a8f38a301913a1cfe636eb94 (diff) |
Merge #8266
8266: Fix generic arguments being incorrectly offset in qualified trait casts r=flodiebold a=Veykril
We reverse the segments and generic args of the lowered path after building it, this wasn't accounted for when inserting the self parameter in `Type as Trait` segments.
Fixes #5886
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/hir_ty')
-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 | } | ||