rust/tests/ui/methods/clone-missing.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
418 B
Rust
Raw Normal View History

2025-04-19 06:38:08 +00:00
// 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.
struct Foo {
i: isize,
}
fn foo(i:isize) -> Foo {
Foo {
i: i
}
}
fn main() {
let x = foo(10);
let _y = x.clone();
//~^ ERROR no method named `clone` found
}