rust/tests/ui/issues/issue-18566.rs

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

26 lines
424 B
Rust
Raw Normal View History

use std::ops::Deref;
struct MyPtr<'a>(&'a mut usize);
2015-01-01 19:53:20 +00:00
impl<'a> Deref for MyPtr<'a> {
type Target = usize;
2015-01-01 19:53:20 +00:00
fn deref<'b>(&'b self) -> &'b usize { self.0 }
2014-11-10 23:47:32 +00:00
}
trait Tr {
fn poke(&self, s: &mut usize);
2014-11-10 23:47:32 +00:00
}
impl Tr for usize {
fn poke(&self, s: &mut usize) {
2014-11-10 23:47:32 +00:00
*s = 2;
}
}
fn main() {
let s = &mut 1;
2014-11-10 23:47:32 +00:00
MyPtr(s).poke(s);
//~^ ERROR cannot borrow `*s` as mutable more than once at a time
}