diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2019-06-17 08:40:50 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2019-07-02 12:25:21 -0400 |
| commit | 0b15a66a806a8f46af6ae24f640814f3a69eddfb (patch) | |
| tree | adff2b234ec2f0f5029b7a2944f9651db672e70d /src/test/ui/impl-trait | |
| parent | 3e01c7416a091dc29dd0d349fafb6cc5d3c4d97c (diff) | |
| download | rust-0b15a66a806a8f46af6ae24f640814f3a69eddfb.tar.gz rust-0b15a66a806a8f46af6ae24f640814f3a69eddfb.zip | |
account for the pick-constraint edges when reporting errors
Also, thread through better span info to improve the error message to something tolerable.
Diffstat (limited to 'src/test/ui/impl-trait')
| -rw-r--r-- | src/test/ui/impl-trait/multiple-lifetimes/error-handling.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/multiple-lifetimes/error-handling.stderr | 15 |
2 files changed, 36 insertions, 0 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 new file mode 100644 index 00000000000..b4cbf0ba8ed --- /dev/null +++ b/src/test/ui/impl-trait/multiple-lifetimes/error-handling.rs @@ -0,0 +1,21 @@ +// compile-flags:-Zborrowck=mir + +#![feature(existential_type)] + +#[derive(Clone)] +struct CopyIfEq<T, U>(T, U); + +impl<T: Copy> Copy for CopyIfEq<T, T> {} + +existential type E<'a, 'b>: Sized; +//~^ ERROR lifetime may not live long enough + +fn foo<'a, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> { + let v = CopyIfEq::<*mut _, *mut _>(&mut {x}, &mut y); + let u = v; + let _: *mut &'a i32 = u.1; + unsafe { let _: &'b i32 = *u.0; } + u.0 +} + +fn main() {} diff --git a/src/test/ui/impl-trait/multiple-lifetimes/error-handling.stderr b/src/test/ui/impl-trait/multiple-lifetimes/error-handling.stderr new file mode 100644 index 00000000000..f42ec5b62f1 --- /dev/null +++ b/src/test/ui/impl-trait/multiple-lifetimes/error-handling.stderr @@ -0,0 +1,15 @@ +error: lifetime may not live long enough + --> $DIR/error-handling.rs:10:1 + | +LL | existential type E<'a, 'b>: Sized; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ opaque type requires that `'a` must outlive `'static` +... +LL | fn foo<'a, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> { + | -- lifetime `'a` defined here +help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a constraint + | +LL | existential type E<'a, 'b>: Sized; + 'a + | + +error: aborting due to previous error + |
