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

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

29 lines
529 B
Rust
Raw Normal View History

// run-pass
#![allow(dead_code)]
2013-08-19 17:52:07 +00:00
trait IDummy {
fn do_nothing(&self);
}
2015-01-28 13:34:18 +00:00
#[derive(Debug)]
struct A { a: isize }
2015-01-28 13:34:18 +00:00
#[derive(Debug)]
struct B<'a> { b: isize, pa: &'a A }
2013-08-19 17:52:07 +00:00
impl IDummy for A {
fn do_nothing(&self) {
println!("A::do_nothing() is called");
2013-08-19 17:52:07 +00:00
}
}
impl<'a> B<'a> {
2019-05-28 18:47:21 +00:00
fn get_pa(&self) -> &'a dyn IDummy { self.pa as &'a dyn IDummy }
2013-08-19 17:52:07 +00:00
}
pub fn main() {
let sa = A { a: 100 };
let sb = B { b: 200, pa: &sa };
println!("sa is {:?}", sa);
println!("sb is {:?}", sb);
2013-08-19 17:52:07 +00:00
}