rust/tests/ui/moves/move-deref-coercion.rs

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

34 lines
475 B
Rust
Raw Normal View History

use std::ops::Deref;
struct NotCopy {
inner: bool
}
impl NotCopy {
fn inner_method(&self) {}
}
struct Foo {
first: NotCopy,
second: NotCopy
}
impl Deref for Foo {
type Target = NotCopy;
fn deref(&self) -> &NotCopy {
&self.second
}
}
fn use_field(val: Foo) {
let _val = val.first;
val.inner; //~ ERROR borrow of
}
fn use_method(val: Foo) {
let _val = val.first;
val.inner_method(); //~ ERROR borrow of
}
fn main() {}