diff options
| author | mejrs <59372212+mejrs@users.noreply.github.com> | 2025-04-29 12:46:26 +0200 |
|---|---|---|
| committer | mejrs <59372212+mejrs@users.noreply.github.com> | 2025-04-29 12:46:26 +0200 |
| commit | a4ce307c0137dca593e2eaa982ee413c7ba03525 (patch) | |
| tree | 4a8817dc04f91b334cd10e76509db8b2f29c01b2 /tests/ui/methods/clone-missing.rs | |
| parent | fc2cd77e114a651755f39f2d9dc5cec6911f4bd9 (diff) | |
| download | rust-a4ce307c0137dca593e2eaa982ee413c7ba03525.tar.gz rust-a4ce307c0137dca593e2eaa982ee413c7ba03525.zip | |
Coalesce duplicate missing clone tests
Diffstat (limited to 'tests/ui/methods/clone-missing.rs')
| -rw-r--r-- | tests/ui/methods/clone-missing.rs | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/tests/ui/methods/clone-missing.rs b/tests/ui/methods/clone-missing.rs index f2e4ad268c6..c5ecd3f175e 100644 --- a/tests/ui/methods/clone-missing.rs +++ b/tests/ui/methods/clone-missing.rs @@ -1,19 +1,34 @@ -// This test checks that calling `.clone()` on a type that does not implement the `Clone` trait -// results in a compilation error. The `Foo` struct does not derive or implement `Clone`, -// so attempting to clone it should fail. +//! This test checks that calling `.clone()` on a type that does +//! not implement the `Clone` trait results in a compilation error. +//! The `NotClone` and AlsoNotClone structs do not derive or +//! implement `Clone`, so attempting to clone them should fail. -struct Foo { - i: isize, +struct NotClone { + i: isize, } -fn foo(i:isize) -> Foo { - Foo { - i: i +fn not_clone(i: isize) -> NotClone { + NotClone { i } +} + +struct AlsoNotClone { + i: isize, + j: NotClone, +} + +fn also_not_clone(i: isize) -> AlsoNotClone { + AlsoNotClone { + i, + j: NotClone { i: i }, } } fn main() { - let x = foo(10); + let x = not_clone(10); + let _y = x.clone(); + //~^ ERROR no method named `clone` found + + let x = also_not_clone(10); let _y = x.clone(); //~^ ERROR no method named `clone` found } |
