fix: preserve where clause in delegate method
This commit is contained in:
parent
934358e95c
commit
f4349ff26e
@ -134,7 +134,7 @@ pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext<'
|
||||
vis,
|
||||
fn_name,
|
||||
type_params,
|
||||
None,
|
||||
method_source.where_clause(),
|
||||
params,
|
||||
body,
|
||||
ret_type,
|
||||
@ -464,6 +464,53 @@ impl Person {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_preserve_where_clause() {
|
||||
check_assist(
|
||||
generate_delegate_methods,
|
||||
r#"
|
||||
struct Inner<T>(T);
|
||||
impl<T> Inner<T> {
|
||||
fn get(&self) -> T
|
||||
where
|
||||
T: Copy,
|
||||
T: PartialEq,
|
||||
{
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
struct Struct<T> {
|
||||
$0field: Inner<T>,
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
struct Inner<T>(T);
|
||||
impl<T> Inner<T> {
|
||||
fn get(&self) -> T
|
||||
where
|
||||
T: Copy,
|
||||
T: PartialEq,
|
||||
{
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
struct Struct<T> {
|
||||
field: Inner<T>,
|
||||
}
|
||||
|
||||
impl<T> Struct<T> {
|
||||
$0fn get(&self) -> T where
|
||||
T: Copy,
|
||||
T: PartialEq, {
|
||||
self.field.get()
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fixes_basic_self_references() {
|
||||
check_assist(
|
||||
|
Loading…
Reference in New Issue
Block a user