fix(assist): display where predicates when we want to generate impl

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
Benjamin Coenen 2021-02-20 15:05:01 +01:00
parent ba3a5c518a
commit d8559588c0
2 changed files with 33 additions and 1 deletions

View file

@ -122,6 +122,31 @@ mod tests {
$0
}"#,
);
check_assist(
generate_impl,
r#"pub trait Trait {}
struct Struct<T>$0
where
T: Trait,
{
inner: T,
}"#,
r#"pub trait Trait {}
struct Struct<T>
where
T: Trait,
{
inner: T,
}
impl<T> Struct<T>
where
T: Trait,
{
$0
}"#,
);
}
#[test]

View file

@ -421,7 +421,14 @@ fn generate_impl_text_inner(adt: &ast::Adt, trait_text: Option<&str>, code: &str
format_to!(buf, "<{}>", lifetime_params.chain(type_params).format(", "))
}
format_to!(buf, " {{\n{}\n}}", code);
match adt.where_clause() {
Some(where_clause) => {
format_to!(buf, "\n{}\n{{\n{}\n}}", where_clause, code);
}
None => {
format_to!(buf, " {{\n{}\n}}", code);
}
}
buf
}