Skip to content

Commit 42a229b

Browse files
committed
Explain a test
1 parent 3b6ac15 commit 42a229b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/test/ui/impl-trait/multiple-lifetimes/error-handling.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@ type E<'a, 'b> = impl Sized;
1212

1313
fn foo<'a, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> {
1414
//~^ ERROR lifetime may not live long enough
15-
let v = CopyIfEq::<*mut _, *mut _>(&mut {x}, &mut y);
15+
let v = CopyIfEq::<*mut _, *mut _>(&mut { x }, &mut y);
16+
17+
// This assignment requires that `x` and `y` have the same type due to the
18+
// `Copy` impl. The reason why we are using a copy to create a constraint
19+
// is that only borrow checking (not regionck in type checking) enforces
20+
// this bound.
1621
let u = v;
1722
let _: *mut &'a i32 = u.1;
18-
unsafe { let _: &'b i32 = *u.0; }
23+
unsafe {
24+
let _: &'b i32 = *u.0;
25+
}
1926
u.0
2027
}
2128

0 commit comments

Comments
 (0)