summaryrefslogtreecommitdiffstats
path: root/tests/ui/issues/issue-11740.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/issues/issue-11740.rs')
-rw-r--r--tests/ui/issues/issue-11740.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/ui/issues/issue-11740.rs b/tests/ui/issues/issue-11740.rs
new file mode 100644
index 000000000..9faeb7770
--- /dev/null
+++ b/tests/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") };
+}