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

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

75 lines
1.0 KiB
Rust
Raw Normal View History

// run-pass
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use std::ops::Deref;
2014-12-07 15:22:06 +00:00
struct Root {
jsref: JSRef
}
2015-01-01 19:53:20 +00:00
impl Deref for Root {
type Target = JSRef;
2014-12-07 15:22:06 +00:00
fn deref<'a>(&'a self) -> &'a JSRef {
&self.jsref
}
}
2015-03-30 13:38:27 +00:00
#[derive(Copy, Clone)]
2014-12-07 15:22:06 +00:00
struct JSRef {
node: *const Node
}
2015-01-01 19:53:20 +00:00
impl Deref for JSRef {
type Target = Node;
2014-12-07 15:22:06 +00:00
fn deref<'a>(&'a self) -> &'a Node {
self.get()
}
}
trait INode {
fn RemoveChild(&self);
}
impl INode for JSRef {
fn RemoveChild(&self) {
self.get().RemoveChild(0)
}
}
impl JSRef {
fn AddChild(&self) {
self.get().AddChild(0);
}
fn get<'a>(&'a self) -> &'a Node {
unsafe {
&*self.node
}
}
}
struct Node;
impl Node {
fn RemoveChild(&self, _a: usize) {
2014-12-07 15:22:06 +00:00
}
fn AddChild(&self, _a: usize) {
2014-12-07 15:22:06 +00:00
}
}
fn main() {
let n = Node;
let jsref = JSRef { node: &n };
let root = Root { jsref: jsref };
root.AddChild();
jsref.AddChild();
root.RemoveChild();
jsref.RemoveChild();
}