diff options
| author | Jared Roesch <roeschinc@gmail.com> | 2015-01-14 13:43:17 -0800 |
|---|---|---|
| committer | Jared Roesch <roeschinc@gmail.com> | 2015-01-14 13:43:17 -0800 |
| commit | 6a66b3227087d3336d8a0e2583dfd35ae93f950b (patch) | |
| tree | 16508acfc187613ffb06904a6d511412e552bf9b /src/test/compile-fail | |
| parent | 896cb36ecab3eaeb7f101087e030e43771eca5ca (diff) | |
| download | rust-6a66b3227087d3336d8a0e2583dfd35ae93f950b.tar.gz rust-6a66b3227087d3336d8a0e2583dfd35ae93f950b.zip | |
Refactor compare_impl_method to use all bounds
Refactor compare_impl_method into its own file. Modify the code to stop comparing individual parameter bounds. Instead we now use the predicates list attached to the trait and implementation generics. This ensures consistency even when bounds are declared in different places (i.e on a parameter vs. in a where clause).
Diffstat (limited to 'src/test/compile-fail')
| -rw-r--r-- | src/test/compile-fail/issue-14853.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-2611-4.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/regions-bound-missing-bound-in-impl.rs | 12 | ||||
| -rw-r--r-- | src/test/compile-fail/trait-bounds-impl-comparison-1.rs | 15 | ||||
| -rw-r--r-- | src/test/compile-fail/trait-bounds-impl-comparison-2.rs | 2 |
5 files changed, 18 insertions, 17 deletions
diff --git a/src/test/compile-fail/issue-14853.rs b/src/test/compile-fail/issue-14853.rs index 3d8ebc1ecdf..22ba54fea14 100644 --- a/src/test/compile-fail/issue-14853.rs +++ b/src/test/compile-fail/issue-14853.rs @@ -20,8 +20,7 @@ struct X { data: u32 } impl Something for X { fn yay<T: Str>(_:Option<X>, thing: &[T]) { -//~^ ERROR in method `yay`, type parameter 0 requires bound `Str`, which is not required - + //~^ ERROR the requirement `T : Str` appears on the impl method } } diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index b141c1f441a..31796e5e20c 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -20,7 +20,8 @@ struct E { } impl A for E { - fn b<F: Sync, G>(_x: F) -> F { panic!() } //~ ERROR type parameter 0 requires `Sync` + fn b<F: Sync, G>(_x: F) -> F { panic!() } + //~^ ERROR `F : core::marker::Sync` appears on the impl method } fn main() {} diff --git a/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs index 5028ec89972..a3c38dff6b0 100644 --- a/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs +++ b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs @@ -16,15 +16,16 @@ struct Inv<'a> { // invariant w/r/t 'a x: &'a mut &'a isize } -pub trait Foo<'a> { +pub trait Foo<'a, 't> { fn no_bound<'b>(self, b: Inv<'b>); fn has_bound<'b:'a>(self, b: Inv<'b>); fn wrong_bound1<'b,'c,'d:'a+'b>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>); - fn wrong_bound2<'b,'c,'d:'a+'b+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>); + fn okay_bound<'b,'c,'d:'a+'b+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>); + fn another_bound<'x: 'a>(self, x: Inv<'x>); } -impl<'a> Foo<'a> for &'a isize { +impl<'a, 't> Foo<'a, 't> for &'a isize { fn no_bound<'b:'a>(self, b: Inv<'b>) { //~^ ERROR lifetime parameters or bounds on method `no_bound` do not match } @@ -47,9 +48,10 @@ impl<'a> Foo<'a> for &'a isize { // cases. } - fn wrong_bound2<'b,'c,'e:'b+'c>(self, b: Inv<'b>, c: Inv<'c>, e: Inv<'e>) { - //~^ ERROR distinct set of bounds from its counterpart + fn okay_bound<'b,'c,'e:'b+'c>(self, b: Inv<'b>, c: Inv<'c>, e: Inv<'e>) { } + + fn another_bound<'x: 't>(self, x: Inv<'x>) {} } fn main() { } diff --git a/src/test/compile-fail/trait-bounds-impl-comparison-1.rs b/src/test/compile-fail/trait-bounds-impl-comparison-1.rs index 5fc80d5660d..477bd4f5be9 100644 --- a/src/test/compile-fail/trait-bounds-impl-comparison-1.rs +++ b/src/test/compile-fail/trait-bounds-impl-comparison-1.rs @@ -32,15 +32,15 @@ trait Foo { impl Foo for isize { // invalid bound for T, was defined as Eq in trait fn test_error1_fn<T: Ord>(&self) {} - //~^ ERROR in method `test_error1_fn`, type parameter 0 requires bound `core::cmp::Ord` + //~^ ERROR the requirement `T : core::cmp::Ord` appears on the impl // invalid bound for T, was defined as Eq + Ord in trait fn test_error2_fn<T: Eq + B>(&self) {} - //~^ ERROR in method `test_error2_fn`, type parameter 0 requires bound `B` + //~^ ERROR the requirement `T : B` appears on the impl // invalid bound for T, was defined as Eq + Ord in trait fn test_error3_fn<T: B + Eq>(&self) {} - //~^ ERROR in method `test_error3_fn`, type parameter 0 requires bound `B` + //~^ ERROR the requirement `T : B` appears on the impl // multiple bounds, same order as in trait fn test3_fn<T: Ord + Eq>(&self) {} @@ -50,16 +50,16 @@ impl Foo for isize { // parameters in impls must be equal or more general than in the defining trait fn test_error5_fn<T: B>(&self) {} - //~^ ERROR in method `test_error5_fn`, type parameter 0 requires bound `B` + //~^ ERROR the requirement `T : B` appears on the impl // bound `std::cmp::Eq` not enforced by this implementation, but this is OK fn test6_fn<T: A>(&self) {} fn test_error7_fn<T: A + Eq>(&self) {} - //~^ ERROR in method `test_error7_fn`, type parameter 0 requires bound `core::cmp::Eq` + //~^ ERROR the requirement `T : core::cmp::Eq` appears on the impl fn test_error8_fn<T: C>(&self) {} - //~^ ERROR in method `test_error8_fn`, type parameter 0 requires bound `C` + //~^ ERROR the requirement `T : C` appears on the impl } @@ -71,8 +71,7 @@ trait Trait { impl Trait for usize { fn method<G: Getter<usize>>() {} - //~^ ERROR in method `method`, type parameter 0 requires bound `Getter<usize>` + //~^ G : Getter<usize>` appears on the impl method but not on the corresponding trait method } fn main() {} - diff --git a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs index a970a86408e..8ad19116e7b 100644 --- a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs +++ b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs @@ -20,7 +20,7 @@ trait IteratorUtil<A> { impl<A, T: Iterator<A>> IteratorUtil<A> for T { fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<T, U> { - //~^ ERROR in method `zip`, type parameter 1 requires bound `Iterator<B>` + //~^ ERROR the requirement `U : Iterator<B>` appears on the impl method ZipIterator{a: self, b: other} } } |
