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

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

29 lines
559 B
Rust
Raw Normal View History

2019-06-12 15:18:32 +00:00
// check-pass
// revisions: mir thir
// [thir]compile-flags: -Zthir-unsafeck
2019-06-12 15:18:32 +00:00
struct Attr {
name: String,
value: String,
}
struct Element {
attrs: Vec<Box<Attr>>,
}
impl Element {
pub unsafe fn get_attr<'a>(&'a self, name: &str) {
self.attrs
.iter()
.find(|attr| {
let attr: &&Box<Attr> = std::mem::transmute(attr);
true
});
}
}
fn main() {
let element = Element { attrs: Vec::new() };
unsafe { let () = element.get_attr("foo"); };
}