Skip to content

Commit

Permalink
fix: testcases in generate_delegate_trait
Browse files Browse the repository at this point in the history
  • Loading branch information
roife committed Dec 13, 2023
1 parent 59aa791 commit 5070534
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions crates/ide-assists/src/handlers/generate_delegate_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,28 +1032,29 @@ struct B<T> {
}
trait Trait<T> {
fn f(a: T);
fn f(&self, a: T) -> T;
}
impl<T1, T2> Trait<T1> for B<T2> {
fn f(a: T1) -> T2 { self.a }
fn f(&self, a: T1) -> T1 { a }
}
struct A {}
struct S {
b$0 : B<A>,
}"#,
b :$0 B<A>,
}
"#,
r#"
struct B<T> {
a: T
}
trait Trait<T> {
fn f(a: T);
fn f(&self, a: T) -> T;
}
impl<T1, T2> Trait<T1> for B<T2> {
fn f(a: T1) -> T2 { self.a }
fn f(&self, a: T1) -> T1 { a }
}
struct A {}
Expand All @@ -1062,10 +1063,11 @@ struct S {
}
impl<T1> Trait<T1> for S {
fn f(a: T1) -> A {
<B<A> as Trait<T1>>::f(a)
fn f(&self, a: T1) -> T1 {
<B<A> as Trait<T1>>::f(&self.b, a)
}
}"#,
}
"#,
);
}

Expand All @@ -1088,7 +1090,8 @@ impl<T, T0> Trait<T> for B<T0> {
struct S<T> {
b : $0B<T>,
}"#,
}
"#,
r#"
struct B<T> {
a: T
Expand All @@ -1110,7 +1113,8 @@ impl<T, T1> Trait<T> for S<T1> {
fn f(&self, a: T) -> T {
<B<T1> as Trait<T>>::f(&self.b, a)
}
}"#,
}
"#,
);
}

Expand All @@ -1133,7 +1137,8 @@ impl<'a, T, T0> Trait<T> for B<'a, T0> {
struct S<'a, T> {
b : $0B<'a, T>,
}"#,
}
"#,
r#"
struct B<'a, T> {
a: &'a T
Expand All @@ -1155,7 +1160,8 @@ impl<'a, T, T1> Trait<T> for S<'a, T1> {
fn f(&self, a: T) -> T {
<B<'a, T1> as Trait<T>>::f(&self.b, a)
}
}"#,
}
"#,
);
}

Expand All @@ -1179,7 +1185,8 @@ impl<T, T0> Trait<T> for B<T, T0> {
struct S<T> {
b :$0 B<i32, T>,
}"#,
}
"#,
r#"
struct B<T1, T2> {
a: T1,
Expand All @@ -1202,7 +1209,8 @@ impl<T1> Trait<i32> for S<T1> {
fn f(&self, a: i32) -> i32 {
<B<i32, T1> as Trait<i32>>::f(&self.b, a)
}
}"#,
}
"#,
);
}

Expand All @@ -1225,7 +1233,8 @@ impl<T> Trait<T> for B<T> {
struct S<T> {
b : $0B<T>,
}"#,
}
"#,
r#"
struct B<T> {
a: T
Expand All @@ -1247,7 +1256,8 @@ impl<T0> Trait<T0> for S<T0> {
fn f(&self, a: T0) -> T0 {
<B<T0> as Trait<T0>>::f(&self.b, a)
}
}"#,
}
"#,
);
}

Expand Down

0 comments on commit 5070534

Please sign in to comment.