rust/tests/ui/moves/needs-clone-through-deref.fixed

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

19 lines
427 B
Rust
Raw Normal View History

2024-03-13 00:46:53 -05:00
//@ run-rustfix
#![allow(dead_code, noop_method_call)]
use std::ops::Deref;
struct S(Vec<usize>);
impl Deref for S {
type Target = Vec<usize>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl S {
fn foo(&self) {
// `self.clone()` returns `&S`, not `Vec`
for _ in <Vec<usize> as Clone>::clone(&self).into_iter() {} //~ ERROR cannot move out of dereference of `S`
}
}
fn main() {}