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