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 <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-03-31 09:52:47 +00:00 committed by GitHub
commit c69f6f31d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 1 deletions

View file

@ -3370,3 +3370,46 @@ fn test() {
"#]],
)
}
#[test]
fn qualified_path_as_qualified_trait() {
check_infer(
r#"
mod foo {
pub trait Foo {
type Target;
}
pub trait Bar {
type Output;
fn boo() -> Self::Output {
loop {}
}
}
}
struct F;
impl foo::Foo for F {
type Target = ();
}
impl foo::Bar for F {
type Output = <F as foo::Foo>::Target;
}
fn foo() {
use foo::Bar;
let x = <F as Bar>::boo();
}
"#,
expect![[r#"
132..163 '{ ... }': Bar::Output<Self>
146..153 'loop {}': !
151..153 '{}': ()
306..358 '{ ...o(); }': ()
334..335 'x': ()
338..353 '<F as Bar>::boo': fn boo<F>() -> <F as Bar>::Output
338..355 '<F as ...:boo()': ()
"#]],
);
}