From: TheDoctor314 <64731940+TheDoctor314@users.noreply.github.com> Date: Mon, 1 Nov 2021 16:47:27 +0000 (+0530) Subject: Add failing tests for generic struct X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=4f93fa12134e47b12a27bd456e59247e8e9d51df;p=rust.git Add failing tests for generic struct --- diff --git a/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs b/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs index 042f31e5c4d..a86fe3fa169 100644 --- a/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs +++ b/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs @@ -1048,6 +1048,54 @@ impl Debug for Foo { ) } + #[test] + fn add_custom_impl_default_generic_record_struct() { + check_assist( + replace_derive_with_manual_impl, + r#" +//- minicore: default +#[derive(Defau$0lt)] +struct Foo { + foo: T, + bar: U, +} +"#, + r#" +struct Foo { + foo: T, + bar: U, +} + +impl Default for Foo { + $0fn default() -> Self { + Self { foo: Default::default(), bar: Default::default() } + } +} +"#, + ) + } + + #[test] + fn add_custom_impl_clone_generic_tuple_struct() { + check_assist( + replace_derive_with_manual_impl, + r#" +//- minicore: clone +#[derive(Clo$0ne)] +struct Foo(T, usize); +"#, + r#" +struct Foo(T, usize); + +impl Clone for Foo { + $0fn clone(&self) -> Self { + Self(self.0.clone(), self.1.clone()) + } +} +"#, + ) + } + #[test] fn test_ignore_derive_macro_without_input() { check_assist_not_applicable(