diff options
author | Niko Matsakis <niko@alum.mit.edu> | 2018-09-24 15:36:50 -0400 |
---|---|---|
committer | Niko Matsakis <niko@alum.mit.edu> | 2018-09-26 09:38:26 -0400 |
commit | f87189dd3c08c7b8b930cfbe25266318adba293c (patch) | |
tree | ddd1217256c4089232643f6c3a0d1d456910727c | |
parent | a13c9f6bfd5266e8b5f567a204f8f3e8051a936d (diff) | |
download | rust-f87189dd3c08c7b8b930cfbe25266318adba293c.tar.gz |
update tests and add stderr files
10 files changed, 72 insertions, 81 deletions
diff --git a/src/test/ui/nll/ty-outlives/projection-body.rs b/src/test/ui/nll/ty-outlives/projection-body.rs index 680e26de65b..2e105ece8b5 100644 --- a/src/test/ui/nll/ty-outlives/projection-body.rs +++ b/src/test/ui/nll/ty-outlives/projection-body.rs @@ -1,5 +1,7 @@ // Test that when we infer the lifetime to a subset of the fn body, it // works out. +// +// compile-pass trait MyTrait<'a> { type Output; diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs b/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs index d525135f759..6667457e13b 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs +++ b/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs @@ -74,18 +74,10 @@ where T: Anything<'b>, T::AssocType: 'a, { - // This error is unfortunate. This code ought to type-check: we - // are projecting `<T as Anything<'b>>::AssocType`, and we know - // that this outlives `'a` because of the where-clause. However, - // the way the region checker works, we don't register this - // outlives obligation, and hence we get an error: this is because - // what we see is a projection like `<T as - // Anything<'?0>>::AssocType`, and we don't yet know if `?0` will - // equal `'b` or not, so we ignore the where-clause. Obviously we - // can do better here with a more involved verification step. + // We are projecting `<T as Anything<'b>>::AssocType`, and we know + // that this outlives `'a` because of the where-clause. with_signature(cell, t, |cell, t| require(cell, t)); - //~^ ERROR } #[rustc_regions] diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr index 981320af3bb..455fbba2320 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr @@ -106,7 +106,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ closure body requires that `'b` must outlive `'a` note: External requirements - --> $DIR/projection-one-region-closure.rs:87:29 + --> $DIR/projection-one-region-closure.rs:80:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -129,7 +129,7 @@ LL | | where LL | | T: Anything<'b>, LL | | T::AssocType: 'a, ... | -LL | | //~^ ERROR +LL | | with_signature(cell, t, |cell, t| require(cell, t)); LL | | } | |_^ | @@ -139,16 +139,8 @@ LL | | } T ] -error[E0309]: the associated type `<T as Anything<'_#5r>>::AssocType` may not live long enough - --> $DIR/projection-one-region-closure.rs:87:29 - | -LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `<T as Anything<'_#5r>>::AssocType: ReEarlyBound(0, 'a)`... - note: External requirements - --> $DIR/projection-one-region-closure.rs:98:29 + --> $DIR/projection-one-region-closure.rs:90:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -165,7 +157,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: where '_#2r: '_#3r note: No external requirements - --> $DIR/projection-one-region-closure.rs:92:1 + --> $DIR/projection-one-region-closure.rs:84:1 | LL | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -182,6 +174,6 @@ LL | | } T ] -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs index 923faadc296..a94d8239fbe 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs +++ b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs @@ -64,18 +64,10 @@ where T: Anything<'b>, T::AssocType: 'a, { - // This error is unfortunate. This code ought to type-check: we - // are projecting `<T as Anything<'b>>::AssocType`, and we know - // that this outlives `'a` because of the where-clause. However, - // the way the region checker works, we don't register this - // outlives obligation, and hence we get an error: this is because - // what we see is a projection like `<T as - // Anything<'?0>>::AssocType`, and we don't yet know if `?0` will - // equal `'b` or not, so we ignore the where-clause. Obviously we - // can do better here with a more involved verification step. + // We are projecting `<T as Anything<'b>>::AssocType`, and we know + // that this outlives `'a` because of the where-clause. with_signature(cell, t, |cell, t| require(cell, t)); - //~^ ERROR } #[rustc_regions] diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr index 76d1eee5cb1..b98aca74058 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr @@ -88,7 +88,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ closure body requires that `'b` must outlive `'a` note: External requirements - --> $DIR/projection-one-region-trait-bound-closure.rs:77:29 + --> $DIR/projection-one-region-trait-bound-closure.rs:70:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | | where LL | | T: Anything<'b>, LL | | T::AssocType: 'a, ... | -LL | | //~^ ERROR +LL | | with_signature(cell, t, |cell, t| require(cell, t)); LL | | } | |_^ | @@ -121,16 +121,8 @@ LL | | } T ] -error[E0309]: the associated type `<T as Anything<'_#5r>>::AssocType` may not live long enough - --> $DIR/projection-one-region-trait-bound-closure.rs:77:29 - | -LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `<T as Anything<'_#5r>>::AssocType: ReEarlyBound(0, 'a)`... - note: External requirements - --> $DIR/projection-one-region-trait-bound-closure.rs:87:29 + --> $DIR/projection-one-region-trait-bound-closure.rs:79:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -146,7 +138,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: where '_#2r: '_#3r note: No external requirements - --> $DIR/projection-one-region-trait-bound-closure.rs:82:1 + --> $DIR/projection-one-region-trait-bound-closure.rs:74:1 | LL | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -164,7 +156,7 @@ LL | | } ] note: External requirements - --> $DIR/projection-one-region-trait-bound-closure.rs:99:29 + --> $DIR/projection-one-region-trait-bound-closure.rs:91:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -179,7 +171,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: where '_#1r: '_#2r note: No external requirements - --> $DIR/projection-one-region-trait-bound-closure.rs:91:1 + --> $DIR/projection-one-region-trait-bound-closure.rs:83:1 | LL | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -195,6 +187,5 @@ LL | | } T ] -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs index b4925253524..95c344e6dff 100644 --- a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs +++ b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs @@ -65,18 +65,10 @@ where T: Anything<'b, 'c>, T::AssocType: 'a, { - // This error is unfortunate. This code ought to type-check: we - // are projecting `<T as Anything<'b>>::AssocType`, and we know - // that this outlives `'a` because of the where-clause. However, - // the way the region checker works, we don't register this - // outlives obligation, and hence we get an error: this is because - // what we see is a projection like `<T as - // Anything<'?0>>::AssocType`, and we don't yet know if `?0` will - // equal `'b` or not, so we ignore the where-clause. Obviously we - // can do better here with a more involved verification step. + // We are projecting `<T as Anything<'b>>::AssocType`, and we know + // that this outlives `'a` because of the where-clause. with_signature(cell, t, |cell, t| require(cell, t)); - //~^ ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough } #[rustc_regions] diff --git a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr index 372b803082f..f872c87b0bb 100644 --- a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr @@ -86,7 +86,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = help: consider adding an explicit lifetime bound `<T as Anything<'_#6r, '_#7r>>::AssocType: ReEarlyBound(0, 'a)`... note: External requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:78:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:71:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -110,7 +110,7 @@ LL | | where LL | | T: Anything<'b, 'c>, LL | | T::AssocType: 'a, ... | -LL | | //~^ ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough +LL | | with_signature(cell, t, |cell, t| require(cell, t)); LL | | } | |_^ | @@ -121,16 +121,8 @@ LL | | } T ] -error[E0309]: the associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough - --> $DIR/projection-two-region-trait-bound-closure.rs:78:29 - | -LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `<T as Anything<'_#6r, '_#7r>>::AssocType: ReEarlyBound(0, 'a)`... - note: External requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:88:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:80:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -147,7 +139,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#3r)>>::AssocType: '_#4r note: No external requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:83:1 + --> $DIR/projection-two-region-trait-bound-closure.rs:75:1 | LL | / fn elements_outlive1<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -166,7 +158,7 @@ LL | | } ] note: External requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:97:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:89:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -183,7 +175,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#3r)>>::AssocType: '_#4r note: No external requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:92:1 + --> $DIR/projection-two-region-trait-bound-closure.rs:84:1 | LL | / fn elements_outlive2<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -202,7 +194,7 @@ LL | | } ] note: External requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:105:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:97:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -218,7 +210,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: where <T as Anything<ReClosureBound('_#1r), ReClosureBound('_#1r)>>::AssocType: '_#2r note: No external requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:101:1 + --> $DIR/projection-two-region-trait-bound-closure.rs:93:1 | LL | / fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -235,7 +227,7 @@ LL | | } ] error: unsatisfied lifetime constraints - --> $DIR/projection-two-region-trait-bound-closure.rs:105:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:97:29 | LL | fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T) | -- -- lifetime `'b` defined here @@ -246,7 +238,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ closure body requires that `'b` must outlive `'a` note: External requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:115:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:107:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -262,7 +254,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#2r)>>::AssocType: '_#3r note: No external requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:110:1 + --> $DIR/projection-two-region-trait-bound-closure.rs:102:1 | LL | / fn two_regions_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -280,7 +272,7 @@ LL | | } ] note: External requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:127:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:119:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -295,7 +287,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: where <T as Anything<ReClosureBound('_#1r), ReClosureBound('_#1r)>>::AssocType: '_#2r note: No external requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:119:1 + --> $DIR/projection-two-region-trait-bound-closure.rs:111:1 | LL | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -311,6 +303,6 @@ LL | | } T ] -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr new file mode 100644 index 00000000000..acb978b5d5a --- /dev/null +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr @@ -0,0 +1,11 @@ +error[E0309]: the associated type `<T as MyTrait<'_>>::Output` may not live long enough + --> $DIR/projection-where-clause-env-wrong-bound.rs:17:5 + | +LL | bar::<T::Output>() //~ ERROR may not live long enough + | ^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `<T as MyTrait<'_>>::Output: 'a`... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr new file mode 100644 index 00000000000..c6d0037138c --- /dev/null +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr @@ -0,0 +1,16 @@ +error[E0309]: the associated type `<T as MyTrait<'a>>::Output` may not live long enough + --> $DIR/projection-where-clause-env-wrong-lifetime.rs:14:5 + | +LL | bar::<<T as MyTrait<'a>>::Output>() //~ ERROR the associated type `<T as MyTrait<'a>>::Output` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `<T as MyTrait<'a>>::Output: 'a`... +note: ...so that the type `<T as MyTrait<'a>>::Output` will meet its required lifetime bounds + --> $DIR/projection-where-clause-env-wrong-lifetime.rs:14:5 + | +LL | bar::<<T as MyTrait<'a>>::Output>() //~ ERROR the associated type `<T as MyTrait<'a>>::Output` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-none.stderr b/src/test/ui/nll/ty-outlives/projection-where-clause-none.stderr new file mode 100644 index 00000000000..2d171a98789 --- /dev/null +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-none.stderr @@ -0,0 +1,11 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/projection-where-clause-none.rs:16:5 + | +LL | bar::<T::Output>() //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'a`... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. |