From 033bd8c7af79d362b4e861543b63991e7300948f Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Thu, 26 Dec 2019 21:13:51 +0000 Subject: [PATCH] Explain a test --- .../impl-trait/multiple-lifetimes/error-handling.rs | 11 +++++++++-- 1 file 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 b226cf058aa7..8fb4794e8913 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 }