mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
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 <lukastw97@gmail.com>
This commit is contained in:
commit
c69f6f31d1
2 changed files with 46 additions and 1 deletions
|
@ -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()': ()
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue