2019-06-12 15:18:32 +00:00
|
|
|
// check-pass
|
2021-05-27 18:37:49 +00:00
|
|
|
// revisions: mir thir
|
|
|
|
// [thir]compile-flags: -Zthir-unsafeck
|
2019-06-12 15:18:32 +00:00
|
|
|
|
2017-06-18 16:18:08 +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
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-31 12:08:01 +00:00
|
|
|
fn main() {
|
2017-06-18 16:18:08 +00:00
|
|
|
let element = Element { attrs: Vec::new() };
|
2023-06-12 08:55:36 +00:00
|
|
|
unsafe { let () = element.get_attr("foo"); };
|
2017-06-18 16:18:08 +00:00
|
|
|
}
|