summaryrefslogtreecommitdiffstats
path: root/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-4.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-4.rs')
-rw-r--r--src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-4.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-4.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-4.rs
new file mode 100644
index 000000000..8c2a59868
--- /dev/null
+++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-4.rs
@@ -0,0 +1,39 @@
+// check-pass
+
+use std::marker::PhantomData;
+use std::mem;
+
+trait Container<'a> {
+ type Root: 'a;
+}
+
+type RootOf<'a, T> = <T as Container<'a>>::Root;
+
+struct Test<'a, T> where T: Container<'a> {
+ pub root: T::Root,
+ marker: PhantomData<&'a mut &'a mut ()>,
+}
+
+impl<'a, 'b> Container<'b> for &'a str {
+ type Root = &'b str;
+}
+
+impl<'a, T> Test<'a, T> where T: for<'b> Container<'b> {
+ fn new(root: RootOf<'a, T>) -> Test<'a, T> {
+ Test {
+ root: root,
+ marker: PhantomData
+ }
+ }
+
+ fn with_mut<F, R>(&mut self, f: F) -> R where
+ F: for<'b> FnOnce(&'b mut RootOf<'b, T>) -> R {
+ f(unsafe { mem::transmute(&mut self.root) })
+ }
+}
+
+fn main() {
+ let val = "root";
+ let mut test: Test<&str> = Test::new(val);
+ test.with_mut(|_| { });
+}