about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/impl-trait/multiple-lifetimes/error-handling.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/test/ui/impl-trait/multiple-lifetimes/error-handling.rs b/src/test/ui/impl-trait/multiple-lifetimes/error-handling.rs
index b226cf058aa..8fb4794e891 100644
--- a/src/test/ui/impl-trait/multiple-lifetimes/error-handling.rs
+++ b/src/test/ui/impl-trait/multiple-lifetimes/error-handling.rs
@@ -12,10 +12,17 @@ type E<'a, 'b> = impl Sized;
 
 fn foo<'a, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> {
     //~^ ERROR lifetime may not live long enough
-    let v = CopyIfEq::<*mut _, *mut _>(&mut {x}, &mut y);
+    let v = CopyIfEq::<*mut _, *mut _>(&mut { x }, &mut y);
+
+    // This assignment requires that `x` and `y` have the same type due to the
+    // `Copy` impl. The reason why we are using a copy to create a constraint
+    // is that only borrow checking (not regionck in type checking) enforces
+    // this bound.
     let u = v;
     let _: *mut &'a i32 = u.1;
-    unsafe { let _: &'b i32 = *u.0; }
+    unsafe {
+        let _: &'b i32 = *u.0;
+    }
     u.0
 }