summary refs log tree commit diff
path: root/src/test/ui/issues/issue-11740.rs
blob: 47bdf085ee5db2f285233e6371fe976fefc97fab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// compile-pass
// skip-codegen
#![allow(warnings)]
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() };
    let _ = unsafe { element.get_attr("foo") };
}