diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/issues/issue-11740.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-11740.rs b/src/test/ui/issues/issue-11740.rs new file mode 100644 index 000000000..9faeb7770 --- /dev/null +++ b/src/test/ui/issues/issue-11740.rs @@ -0,0 +1,28 @@ +// check-pass +// revisions: mir thir +// [thir]compile-flags: -Zthir-unsafeck + +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") }; +} |