diff options
| author | bors <bors@rust-lang.org> | 2015-12-18 20:44:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-12-18 20:44:33 +0000 |
| commit | 5dd29cc3107f7febc26ec56ed4149cd67c1f49d8 (patch) | |
| tree | 0805b87696a6b3e3450518dfc6b8d5f94a308178 /src/test | |
| parent | ef91cdb140d7dffa4b04f42ab0bc02dc257940e3 (diff) | |
| parent | dbf994bbaff214e6441a8e97df180db7b29e7189 (diff) | |
| download | rust-5dd29cc3107f7febc26ec56ed4149cd67c1f49d8.tar.gz rust-5dd29cc3107f7febc26ec56ed4149cd67c1f49d8.zip | |
Auto merge of #30389 - nikomatsakis:rfc1214-error, r=arielb1
Make RFC 1214 warnings into errors, and rip out the "warn or err" associated machinery. Future such attempts should go through lints anyhow. There is a fair amount of fallout in the compile-fail tests, as WF checking now occurs earlier in the process. r? @arielb1
Diffstat (limited to 'src/test')
71 files changed, 193 insertions, 227 deletions
diff --git a/src/test/auxiliary/associated-types-cc-lib.rs b/src/test/auxiliary/associated-types-cc-lib.rs index b3960c2707b..175e8730cbc 100644 --- a/src/test/auxiliary/associated-types-cc-lib.rs +++ b/src/test/auxiliary/associated-types-cc-lib.rs @@ -13,7 +13,7 @@ #![crate_type="lib"] -pub trait Bar { +pub trait Bar: Sized { type T; fn get(x: Option<Self>) -> <Self as Bar>::T; diff --git a/src/test/auxiliary/static-methods-crate.rs b/src/test/auxiliary/static-methods-crate.rs index e61fb49add5..b8fd59bf703 100644 --- a/src/test/auxiliary/static-methods-crate.rs +++ b/src/test/auxiliary/static-methods-crate.rs @@ -11,7 +11,7 @@ #![crate_name="static_methods_crate"] #![crate_type = "lib"] -pub trait read { +pub trait read: Sized { fn readMaybe(s: String) -> Option<Self>; } diff --git a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs index 233532a6085..0b1d6a5b71a 100644 --- a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs +++ b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs @@ -25,10 +25,7 @@ trait Get { trait Other { fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {} - // (note that we no longer catch the error here, since the - // error below aborts compilation. - // See also associated-types-no-suitable-supertrait-2.rs - // which checks that this error would be caught eventually.) + //~^ ERROR the trait `Get` is not implemented for the type `Self` } impl<T:Get> Other for T { diff --git a/src/test/compile-fail/builtin-superkinds-self-type.rs b/src/test/compile-fail/builtin-superkinds-self-type.rs index 037364c7a53..3065ecfaa30 100644 --- a/src/test/compile-fail/builtin-superkinds-self-type.rs +++ b/src/test/compile-fail/builtin-superkinds-self-type.rs @@ -13,7 +13,7 @@ use std::sync::mpsc::{channel, Sender}; -trait Foo : Sync+'static { +trait Foo : Sized+Sync+'static { fn foo(self, mut chan: Sender<Self>) { } } diff --git a/src/test/compile-fail/coherence-impl-trait-for-trait-object-safe.rs b/src/test/compile-fail/coherence-impl-trait-for-trait-object-safe.rs index b08e4bad1e9..8bb9556fcc0 100644 --- a/src/test/compile-fail/coherence-impl-trait-for-trait-object-safe.rs +++ b/src/test/compile-fail/coherence-impl-trait-for-trait-object-safe.rs @@ -13,9 +13,7 @@ // If the trait is not object-safe, we give a more tailored message // because we're such schnuckels: -trait NotObjectSafe { fn eq(&self, other: &Self); } -impl NotObjectSafe for NotObjectSafe { //~ ERROR E0372 - fn eq(&self, other: &Self) { panic!(); } -} +trait NotObjectSafe { fn eq(&self, other: Self); } +impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038 fn main() { } diff --git a/src/test/compile-fail/cross-fn-cache-hole.rs b/src/test/compile-fail/cross-fn-cache-hole.rs index 0aefd0ae288..7d4c618de66 100644 --- a/src/test/compile-fail/cross-fn-cache-hole.rs +++ b/src/test/compile-fail/cross-fn-cache-hole.rs @@ -21,14 +21,15 @@ trait Foo<X,Y>: Bar<X> { trait Bar<X> { } -fn vacuous<A>() +// We don't always check where clauses for sanity, but in this case +// wfcheck does report an error here: +fn vacuous<A>() //~ ERROR the trait `Bar<u32>` is not implemented for the type `i32` where i32: Foo<u32, A> { - // vacuous could never be called, because it requires that i32: - // Bar<u32>. But the code doesn't check that this could never be - // satisfied. + // ... the original intention was to check that we don't use that + // vacuous where clause (which could never be satisfied) to accept + // the following line and then mess up calls elsewhere. require::<i32, u32>(); - //~^ ERROR the trait `Bar<u32>` is not implemented for the type `i32` } fn require<A,B>() diff --git a/src/test/compile-fail/issue-13853-2.rs b/src/test/compile-fail/issue-13853-2.rs index ea0d880f4a1..1635a8f69a6 100644 --- a/src/test/compile-fail/issue-13853-2.rs +++ b/src/test/compile-fail/issue-13853-2.rs @@ -10,7 +10,7 @@ trait FromStructReader<'a> { } trait ResponseHook { - fn get<'a, T: FromStructReader<'a>>(&'a self); + fn get(&self); } fn foo(res : Box<ResponseHook>) { res.get } //~ ERROR attempted to take value of method fn main() {} diff --git a/src/test/compile-fail/issue-13853.rs b/src/test/compile-fail/issue-13853.rs index f5d158d64e1..7643310298d 100644 --- a/src/test/compile-fail/issue-13853.rs +++ b/src/test/compile-fail/issue-13853.rs @@ -13,11 +13,14 @@ trait Node { } trait Graph<N: Node> { - fn nodes<'a, I: Iterator<Item=&'a N>>(&'a self) -> I; + fn nodes<'a, I: Iterator<Item=&'a N>>(&'a self) -> I + where N: 'a; } impl<N: Node> Graph<N> for Vec<N> { - fn nodes<'a, I: Iterator<Item=&'a N>>(&self) -> I { + fn nodes<'a, I: Iterator<Item=&'a N>>(&self) -> I + where N: 'a + { self.iter() //~ ERROR mismatched types } } diff --git a/src/test/compile-fail/issue-14853.rs b/src/test/compile-fail/issue-14853.rs index 51deb99a4f2..c6c1a0fd177 100644 --- a/src/test/compile-fail/issue-14853.rs +++ b/src/test/compile-fail/issue-14853.rs @@ -12,7 +12,7 @@ use std::fmt::Debug; trait Str {} -trait Something { +trait Something: Sized { fn yay<T: Debug>(_: Option<Self>, thing: &[T]); } diff --git a/src/test/compile-fail/issue-18959.rs b/src/test/compile-fail/issue-18959.rs index 5f6216a898a..7a6d012a3b6 100644 --- a/src/test/compile-fail/issue-18959.rs +++ b/src/test/compile-fail/issue-18959.rs @@ -19,14 +19,12 @@ impl Foo for Thing { #[inline(never)] fn foo(b: &Bar) { + //~^ ERROR E0038 b.foo(&0) - //~^ ERROR the trait `Foo` is not implemented for the type `Bar` - //~| ERROR E0038 - //~| WARNING E0038 } fn main() { let mut thing = Thing; - let test: &Bar = &mut thing; //~ ERROR E0038 + let test: &Bar = &mut thing; foo(test); } diff --git a/src/test/compile-fail/issue-19380.rs b/src/test/compile-fail/issue-19380.rs index aae77c90b6b..322952ffef1 100644 --- a/src/test/compile-fail/issue-19380.rs +++ b/src/test/compile-fail/issue-19380.rs @@ -19,10 +19,10 @@ impl Qiz for Foo { struct Bar { foos: &'static [&'static (Qiz + 'static)] +//~^ ERROR E0038 } const FOO : Foo = Foo; const BAR : Bar = Bar { foos: &[&FOO]}; -//~^ ERROR E0038 fn main() { } diff --git a/src/test/compile-fail/issue-20005.rs b/src/test/compile-fail/issue-20005.rs index 041289c2ccd..aaf27ba527b 100644 --- a/src/test/compile-fail/issue-20005.rs +++ b/src/test/compile-fail/issue-20005.rs @@ -15,13 +15,10 @@ trait From<Src> { } trait To { - fn to<Dst>( - self //~ error: the trait `core::marker::Sized` is not implemented + fn to<Dst>( //~ ERROR the trait `core::marker::Sized` is not implemented + self ) -> <Dst as From<Self>>::Result where Dst: From<Self> { - From::from( //~ error: the trait `core::marker::Sized` is not implemented - //~^ ERROR E0277 - self - ) + From::from(self) } } diff --git a/src/test/compile-fail/issue-20831-debruijn.rs b/src/test/compile-fail/issue-20831-debruijn.rs index a38278eae24..3f96a9c3422 100644 --- a/src/test/compile-fail/issue-20831-debruijn.rs +++ b/src/test/compile-fail/issue-20831-debruijn.rs @@ -38,6 +38,8 @@ impl<'a> Publisher<'a> for MyStruct<'a> { fn subscribe(&mut self, t : Box<Subscriber<Input=<Self as Publisher>::Output> + 'a>) { // Not obvious, but there is an implicit lifetime here -------^ //~^^ ERROR cannot infer + //~| ERROR cannot infer + //~| ERROR cannot infer // // The fact that `Publisher` is using an implicit lifetime is // what was causing the debruijn accounting to be off, so diff --git a/src/test/compile-fail/issue-21974.rs b/src/test/compile-fail/issue-21974.rs index f768d6c00ec..6ddfa4c8e3e 100644 --- a/src/test/compile-fail/issue-21974.rs +++ b/src/test/compile-fail/issue-21974.rs @@ -17,11 +17,11 @@ trait Foo { fn foo(self); } -fn foo<'a,'b,T>(x: &'a T, y: &'b T) +fn foo<'a,'b,T>(x: &'a T, y: &'b T) //~ ERROR type annotations required where &'a T : Foo, &'b T : Foo { - x.foo(); //~ ERROR type annotations required + x.foo(); y.foo(); } diff --git a/src/test/compile-fail/issue-23041.rs b/src/test/compile-fail/issue-23041.rs index c08cdd72b38..1a9bb4c29f3 100644 --- a/src/test/compile-fail/issue-23041.rs +++ b/src/test/compile-fail/issue-23041.rs @@ -13,5 +13,5 @@ fn main() { fn bar(x:i32) ->i32 { 3*x }; let b:Box<Any> = Box::new(bar as fn(_)->_); - b.downcast_ref::<fn(_)->_>(); //~ ERROR E0101 + b.downcast_ref::<fn(_)->_>(); //~ ERROR E0282 } diff --git a/src/test/compile-fail/issue-23305.rs b/src/test/compile-fail/issue-23305.rs index 68f053c357b..4acb1f70d34 100644 --- a/src/test/compile-fail/issue-23305.rs +++ b/src/test/compile-fail/issue-23305.rs @@ -13,6 +13,6 @@ pub trait ToNbt<T> { } impl ToNbt<Self> {} //~ ERROR use of `Self` outside of an impl or trait -//~^ WARNING the trait `ToNbt` cannot be made into an object +//~^ ERROR the trait `ToNbt` cannot be made into an object fn main() {} diff --git a/src/test/compile-fail/issue-3907-2.rs b/src/test/compile-fail/issue-3907-2.rs index ee8bc7d6e29..130647966f2 100644 --- a/src/test/compile-fail/issue-3907-2.rs +++ b/src/test/compile-fail/issue-3907-2.rs @@ -18,6 +18,6 @@ struct S { } fn bar(_x: Foo) {} -//~^ ERROR E0277 +//~^ ERROR E0038 fn main() {} diff --git a/src/test/compile-fail/object-safety-generics.rs b/src/test/compile-fail/object-safety-generics.rs index 63e5718537c..341736f7ab5 100644 --- a/src/test/compile-fail/object-safety-generics.rs +++ b/src/test/compile-fail/object-safety-generics.rs @@ -22,16 +22,13 @@ trait Quux { } fn make_bar<T:Bar>(t: &T) -> &Bar { - t //~^ ERROR E0038 //~| NOTE method `bar` has generic type parameters + t } fn make_bar_explicit<T:Bar>(t: &T) -> &Bar { t as &Bar - //~^ ERROR E0038 - //~| NOTE method `bar` has generic type parameters - //~| ERROR E0038 } fn make_quux<T:Quux>(t: &T) -> &Quux { diff --git a/src/test/compile-fail/object-safety-mentions-Self.rs b/src/test/compile-fail/object-safety-mentions-Self.rs index 55b78090635..edd31c1f796 100644 --- a/src/test/compile-fail/object-safety-mentions-Self.rs +++ b/src/test/compile-fail/object-safety-mentions-Self.rs @@ -25,29 +25,15 @@ trait Quux { } fn make_bar<T:Bar>(t: &T) -> &Bar { - t - //~^ ERROR E0038 - //~| NOTE method `bar` references the `Self` type in its arguments or return type -} - -fn make_bar_explicit<T:Bar>(t: &T) -> &Bar { - t as &Bar //~^ ERROR E0038 //~| NOTE method `bar` references the `Self` type in its arguments or return type - //~| ERROR E0038 + loop { } } fn make_baz<T:Baz>(t: &T) -> &Baz { - t //~^ ERROR E0038 //~| NOTE method `bar` references the `Self` type in its arguments or return type -} - -fn make_baz_explicit<T:Baz>(t: &T) -> &Baz { - t as &Baz - //~^ ERROR E0038 - //~| NOTE method `bar` references the `Self` type in its arguments or return type - //~| ERROR E0038 + t } fn make_quux<T:Quux>(t: &T) -> &Quux { diff --git a/src/test/compile-fail/object-safety-no-static.rs b/src/test/compile-fail/object-safety-no-static.rs index 2dc7983d1b5..dd1d5af3f4a 100644 --- a/src/test/compile-fail/object-safety-no-static.rs +++ b/src/test/compile-fail/object-safety-no-static.rs @@ -16,16 +16,8 @@ trait Foo { } fn foo_implicit<T:Foo+'static>(b: Box<T>) -> Box<Foo+'static> { - b - //~^ ERROR E0038 - //~| NOTE method `foo` has no receiver -} - -fn foo_explicit<T:Foo+'static>(b: Box<T>) -> Box<Foo+'static> { - b as Box<Foo> - //~^ ERROR E0038 - //~| NOTE method `foo` has no receiver - //~| ERROR E0038 + //~^ ERROR E0038 + loop { } } fn main() { diff --git a/src/test/compile-fail/object-safety-sized-2.rs b/src/test/compile-fail/object-safety-sized-2.rs index 401602bd681..3e1942d5a01 100644 --- a/src/test/compile-fail/object-safety-sized-2.rs +++ b/src/test/compile-fail/object-safety-sized-2.rs @@ -18,16 +18,8 @@ trait Bar } fn make_bar<T:Bar>(t: &T) -> &Bar { - t //~^ ERROR E0038 - //~| NOTE the trait cannot require that `Self : Sized` -} - -fn make_bar_explicit<T:Bar>(t: &T) -> &Bar { - t as &Bar - //~^ ERROR E0038 - //~| NOTE the trait cannot require that `Self : Sized` - //~| ERROR E0038 + loop { } } fn main() { diff --git a/src/test/compile-fail/object-safety-sized.rs b/src/test/compile-fail/object-safety-sized.rs index 29b4e4db65c..501d61d20fe 100644 --- a/src/test/compile-fail/object-safety-sized.rs +++ b/src/test/compile-fail/object-safety-sized.rs @@ -16,16 +16,9 @@ trait Bar : Sized { } fn make_bar<T:Bar>(t: &T) -> &Bar { - t - //~^ ERROR E0038 - //~| NOTE the trait cannot require that `Self : Sized` -} - -fn make_bar_explicit<T:Bar>(t: &T) -> &Bar { - t as &Bar //~^ ERROR E0038 //~| NOTE the trait cannot require that `Self : Sized` - //~| ERROR E0038 + t } fn main() { diff --git a/src/test/compile-fail/regions-close-object-into-object-5.rs b/src/test/compile-fail/regions-close-object-into-object-5.rs index ac269a4d896..152c65cb69b 100644 --- a/src/test/compile-fail/regions-close-object-into-object-5.rs +++ b/src/test/compile-fail/regions-close-object-into-object-5.rs @@ -26,10 +26,10 @@ fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> { // oh dear! box B(&*v) as Box<X> //~^ ERROR the parameter type `T` may not live long enough - //~| WARNING the parameter type `T` may not live long enough - //~| WARNING the parameter type `T` may not live long enough //~| ERROR the parameter type `T` may not live long enough - //~| WARNING the parameter type `T` may not live long enough + //~| ERROR the parameter type `T` may not live long enough + //~| ERROR the parameter type `T` may not live long enough + //~| ERROR the parameter type `T` may not live long enough //~| ERROR the parameter type `T` may not live long enough //~| ERROR the parameter type `T` may not live long enough } diff --git a/src/test/compile-fail/regions-free-region-ordering-callee-4.rs b/src/test/compile-fail/regions-free-region-ordering-callee-4.rs new file mode 100644 index 00000000000..bd31d1a5a90 --- /dev/null +++ b/src/test/compile-fail/regions-free-region-ordering-callee-4.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that callees correctly infer an ordering between free regions +// that appear in their parameter list. See also +// regions-free-region-ordering-caller.rs + +fn ordering4<'a, 'b, F>(a: &'a usize, b: &'b usize, x: F) where F: FnOnce(&'a &'b usize) { + //~^ ERROR reference has a longer lifetime than the data it references + // Do not infer ordering from closure argument types. + let z: Option<&'a &'b usize> = None; +} + +fn main() {} diff --git a/src/test/compile-fail/regions-free-region-ordering-callee.rs b/src/test/compile-fail/regions-free-region-ordering-callee.rs index 22724081a1b..1893395e2b0 100644 --- a/src/test/compile-fail/regions-free-region-ordering-callee.rs +++ b/src/test/compile-fail/regions-free-region-ordering-callee.rs @@ -30,11 +30,7 @@ fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { panic!(); } -fn ordering4<'a, 'b, F>(a: &'a usize, b: &'b usize, x: F) where F: FnOnce(&'a &'b usize) { - // Do not infer ordering from closure argument types. - let z: Option<&'a &'b usize> = None; - //~^ ERROR reference has a longer lifetime than the data it references -} +// see regions-free-region-ordering-callee-4.rs fn ordering5<'a, 'b>(a: &'a usize, b: &'b usize, x: Option<&'a &'b usize>) { let z: Option<&'a &'b usize> = None; diff --git a/src/test/compile-fail/regions-implied-bounds-projection-gap-hr-1.rs b/src/test/compile-fail/regions-implied-bounds-projection-gap-hr-1.rs index 47985f931dd..fd186d16559 100644 --- a/src/test/compile-fail/regions-implied-bounds-projection-gap-hr-1.rs +++ b/src/test/compile-fail/regions-implied-bounds-projection-gap-hr-1.rs @@ -24,16 +24,13 @@ trait Trait2<'a, 'b> { type Foo; } -fn wf<T>() { } - -// As a side-effect of the conservative process above, this argument -// is not automatically considered well-formed, since for it to be WF, -// we would need to know that `'y: 'x`, but we do not infer that. -fn callee<'x, 'y, T>( - t: &'x for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) -{ - wf::<&'x &'y i32>(); +// As a side-effect of the conservative process above, the type of +// this argument `t` is not automatically considered well-formed, +// since for it to be WF, we would need to know that `'y: 'x`, but we +// do not infer that. +fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) //~^ ERROR reference has a longer lifetime than the data it references +{ } fn main() { } diff --git a/src/test/compile-fail/regions-wf-trait-object.rs b/src/test/compile-fail/regions-wf-trait-object.rs index e1f1fdaeb34..40b715cf3b1 100644 --- a/src/test/compile-fail/regions-wf-trait-object.rs +++ b/src/test/compile-fail/regions-wf-trait-object.rs @@ -14,8 +14,7 @@ trait TheTrait<'t>: 't { } struct Foo<'a,'b> { - x: Box<TheTrait<'a>+'b> - //~^ ERROR reference has a longer lifetime + x: Box<TheTrait<'a>+'b> //~ ERROR E0478 } fn main() { } diff --git a/src/test/compile-fail/rfc1214-warn-and-error.rs b/src/test/compile-fail/rfc1214-warn-and-error.rs deleted file mode 100644 index 50fd3fc961c..00000000000 --- a/src/test/compile-fail/rfc1214-warn-and-error.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that an RFC1214 warning from an earlier function (`foo`) does -// not suppress an error for the same problem (`WantEq<NotEq>`, -// `NotEq: !Eq`) in a later function (`bar)`. Earlier versions of the -// warning mechanism had an issue due to caching. - -#![allow(dead_code)] -#![allow(unused_variables)] - -struct WantEq<T:Eq> { t: T } - -struct NotEq; - -trait Trait<T> { } - -fn foo() { - let x: Box<Trait<WantEq<NotEq>>> = loop { }; - //~^ WARN E0277 -} - -fn bar() { - wf::<WantEq<NotEq>>(); - //~^ ERROR E0277 -} - -fn wf<T>() { } - -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 beabdcea2bb..01910939a80 100644 --- a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs +++ b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs @@ -14,7 +14,7 @@ trait Iterator<A> { fn next(&mut self) -> Option<A>; } -trait IteratorUtil<A> +trait IteratorUtil<A>: Sized { fn zip<B, U: Iterator<U>>(self, other: U) -> ZipIterator<Self, U>; } diff --git a/src/test/compile-fail/trait-test-2.rs b/src/test/compile-fail/trait-test-2.rs index 73be7cf0dc0..2d4df77f960 100644 --- a/src/test/compile-fail/trait-test-2.rs +++ b/src/test/compile-fail/trait-test-2.rs @@ -22,5 +22,4 @@ fn main() { //~^ ERROR E0038 //~| ERROR E0038 //~| ERROR E0277 - //~| WARNING E0038 } diff --git a/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause-2.rs b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause-2.rs new file mode 100644 index 00000000000..ad58ae92b46 --- /dev/null +++ b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause-2.rs @@ -0,0 +1,36 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +// Test that when a `..` impl applies, we also check that any +// supertrait conditions are met. + +#![feature(optin_builtin_traits)] + +trait NotImplemented { } + +trait MyTrait: Sized + where Option<Self> : NotImplemented +{} + +impl NotImplemented for i32 {} + +impl MyTrait for .. {} + +fn bar<T:NotImplemented>() { } + +fn test() { + bar::<Option<i32>>(); + //~^ ERROR the trait `NotImplemented` is not implemented for the type `core::option::Option<i32>` +} + +fn main() { +} diff --git a/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs index 8057ca56621..ff8fbd49574 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs @@ -17,7 +17,7 @@ trait NotImplemented { } -trait MyTrait +trait MyTrait: Sized where Option<Self> : NotImplemented {} @@ -26,20 +26,11 @@ impl NotImplemented for i32 {} impl MyTrait for .. {} fn foo<T:MyTrait>() { - bar::<Option<T>>() //~^ ERROR the trait `NotImplemented` is not implemented for the type `core::option::Option<T>` - // // This should probably typecheck. This is #20671. } fn bar<T:NotImplemented>() { } -fn test() { - bar::<Option<i32>>(); - //~^ ERROR the trait `NotImplemented` is not implemented for the type `core::option::Option<i32>` -} - fn main() { - foo::<u32>(); - //~^ ERROR the trait `NotImplemented` is not implemented for the type `core::option::Option<u32>` } diff --git a/src/test/compile-fail/variance-invariant-self-trait-match.rs b/src/test/compile-fail/variance-invariant-self-trait-match.rs index b46cd302ae5..fe61dee23bc 100644 --- a/src/test/compile-fail/variance-invariant-self-trait-match.rs +++ b/src/test/compile-fail/variance-invariant-self-trait-match.rs @@ -15,13 +15,13 @@ trait Get { } fn get_min_from_max<'min, 'max, G>() - where 'max : 'min, &'max G : Get + where 'max : 'min, &'max G : Get, G : 'max { impls_get::<&'min G>(); //~ ERROR mismatched types } fn get_max_from_min<'min, 'max, G>() - where 'max : 'min, &'min G : Get + where 'max : 'min, &'min G : Get, G : 'min { impls_get::<&'max G>(); //~ ERROR mismatched types } diff --git a/src/test/compile-fail/wf-array-elem-sized.rs b/src/test/compile-fail/wf-array-elem-sized.rs index c8b7f35b3aa..946341a1a75 100644 --- a/src/test/compile-fail/wf-array-elem-sized.rs +++ b/src/test/compile-fail/wf-array-elem-sized.rs @@ -14,8 +14,8 @@ #![allow(dead_code)] struct Foo { - foo: [[u8]], //~ WARN E0277 + foo: [[u8]], //~ ERROR E0277 } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-enum-bound.rs b/src/test/compile-fail/wf-enum-bound.rs index 1d271d1530a..e3e79fdd940 100644 --- a/src/test/compile-fail/wf-enum-bound.rs +++ b/src/test/compile-fail/wf-enum-bound.rs @@ -16,11 +16,11 @@ trait ExtraCopy<T:Copy> { } -enum SomeEnum<T,U> //~ WARN E0277 +enum SomeEnum<T,U> //~ ERROR E0277 where T: ExtraCopy<U> { SomeVariant(T,U) } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-fn-where-clause.rs b/src/test/compile-fail/wf-fn-where-clause.rs index 769894613c7..3ed9e5d9f1e 100644 --- a/src/test/compile-fail/wf-fn-where-clause.rs +++ b/src/test/compile-fail/wf-fn-where-clause.rs @@ -16,9 +16,9 @@ trait ExtraCopy<T:Copy> { } -fn foo<T,U>() where T: ExtraCopy<U> //~ WARN E0277 +fn foo<T,U>() where T: ExtraCopy<U> //~ ERROR E0277 { } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-impl-associated-type-region.rs b/src/test/compile-fail/wf-impl-associated-type-region.rs index 2d7727fff35..a319b676eeb 100644 --- a/src/test/compile-fail/wf-impl-associated-type-region.rs +++ b/src/test/compile-fail/wf-impl-associated-type-region.rs @@ -17,8 +17,8 @@ pub trait Foo<'a> { } impl<'a, T> Foo<'a> for T { - type Bar = &'a T; //~ WARN E0309 + type Bar = &'a T; //~ ERROR E0309 } #[rustc_error] -fn main() { } //~ ERROR compilation +fn main() { } diff --git a/src/test/compile-fail/wf-impl-associated-type-trait.rs b/src/test/compile-fail/wf-impl-associated-type-trait.rs index 8a612c32157..ba31de98e7f 100644 --- a/src/test/compile-fail/wf-impl-associated-type-trait.rs +++ b/src/test/compile-fail/wf-impl-associated-type-trait.rs @@ -25,9 +25,9 @@ pub trait Foo { impl<T> Foo for T { type Bar = MySet<T>; - //~^ WARN the trait `MyHash` is not implemented for the type `T` + //~^ ERROR the trait `MyHash` is not implemented for the type `T` } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-in-fn-type-static.rs b/src/test/compile-fail/wf-in-fn-type-static.rs index 593c9435f6c..8e3bca09758 100644 --- a/src/test/compile-fail/wf-in-fn-type-static.rs +++ b/src/test/compile-fail/wf-in-fn-type-static.rs @@ -20,13 +20,13 @@ struct MustBeCopy<T:Copy> { struct Foo<T> { // needs T: 'static - x: fn() -> &'static T //~ WARN E0310 + x: fn() -> &'static T //~ ERROR E0310 } struct Bar<T> { // needs T: Copy - x: fn(&'static T) //~ WARN E0310 + x: fn(&'static T) //~ ERROR E0310 } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-in-fn-where-clause.rs b/src/test/compile-fail/wf-in-fn-where-clause.rs index fc3d234aac2..c2f66a2a460 100644 --- a/src/test/compile-fail/wf-in-fn-where-clause.rs +++ b/src/test/compile-fail/wf-in-fn-where-clause.rs @@ -16,10 +16,10 @@ trait MustBeCopy<T:Copy> { } -fn bar<T,U>() //~ WARN E0277 +fn bar<T,U>() //~ ERROR E0277 where T: MustBeCopy<U> { } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-in-obj-type-static.rs b/src/test/compile-fail/wf-in-obj-type-static.rs index c697dfd50ad..11535fb9f9e 100644 --- a/src/test/compile-fail/wf-in-obj-type-static.rs +++ b/src/test/compile-fail/wf-in-obj-type-static.rs @@ -21,8 +21,8 @@ struct MustBeCopy<T:Copy> { struct Foo<T> { // needs T: 'static - x: Object<&'static T> //~ WARN E0310 + x: Object<&'static T> //~ ERROR E0310 } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-inherent-impl-method-where-clause.rs b/src/test/compile-fail/wf-inherent-impl-method-where-clause.rs index 44671be8355..78e12c47e24 100644 --- a/src/test/compile-fail/wf-inherent-impl-method-where-clause.rs +++ b/src/test/compile-fail/wf-inherent-impl-method-where-clause.rs @@ -19,9 +19,9 @@ trait ExtraCopy<T:Copy> { } struct Foo<T,U>(T,U); impl<T,U> Foo<T,U> { - fn foo(self) where T: ExtraCopy<U> //~ WARN E0277 + fn foo(self) where T: ExtraCopy<U> //~ ERROR E0277 {} } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-inherent-impl-where-clause.rs b/src/test/compile-fail/wf-inherent-impl-where-clause.rs index a0f588c1961..7edbb11e245 100644 --- a/src/test/compile-fail/wf-inherent-impl-where-clause.rs +++ b/src/test/compile-fail/wf-inherent-impl-where-clause.rs @@ -18,9 +18,9 @@ trait ExtraCopy<T:Copy> { } struct Foo<T,U>(T,U); -impl<T,U> Foo<T,U> where T: ExtraCopy<U> //~ WARN E0277 +impl<T,U> Foo<T,U> where T: ExtraCopy<U> //~ ERROR E0277 { } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-outlives-ty-in-fn-or-trait.rs b/src/test/compile-fail/wf-outlives-ty-in-fn-or-trait.rs index dc0cbeff153..c11b2e4c544 100644 --- a/src/test/compile-fail/wf-outlives-ty-in-fn-or-trait.rs +++ b/src/test/compile-fail/wf-outlives-ty-in-fn-or-trait.rs @@ -19,14 +19,14 @@ trait Trait<T> { } struct Foo<'a,T> { f: &'a fn(T), - //~^ WARN E0309 + //~^ ERROR E0309 } struct Bar<'a,T> { f: &'a Trait<T>, - //~^ WARN E0309 + //~^ ERROR E0309 } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-struct-bound.rs b/src/test/compile-fail/wf-struct-bound.rs index 43378061e40..e263b251aa3 100644 --- a/src/test/compile-fail/wf-struct-bound.rs +++ b/src/test/compile-fail/wf-struct-bound.rs @@ -16,11 +16,11 @@ trait ExtraCopy<T:Copy> { } -struct SomeStruct<T,U> //~ WARN E0277 +struct SomeStruct<T,U> //~ ERROR E0277 where T: ExtraCopy<U> { data: (T,U) } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-trait-associated-type-bound.rs b/src/test/compile-fail/wf-trait-associated-type-bound.rs index 63a532138e3..8420edd66a1 100644 --- a/src/test/compile-fail/wf-trait-associated-type-bound.rs +++ b/src/test/compile-fail/wf-trait-associated-type-bound.rs @@ -16,9 +16,9 @@ trait ExtraCopy<T:Copy> { } -trait SomeTrait<T> { //~ WARN E0277 +trait SomeTrait<T> { //~ ERROR E0277 type Type1: ExtraCopy<T>; } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-trait-associated-type-region.rs b/src/test/compile-fail/wf-trait-associated-type-region.rs index b3aa4e19c96..95d9ffdf9d3 100644 --- a/src/test/compile-fail/wf-trait-associated-type-region.rs +++ b/src/test/compile-fail/wf-trait-associated-type-region.rs @@ -17,8 +17,8 @@ trait SomeTrait<'a> { type Type1; type Type2 = &'a Self::Type1; - //~^ WARN E0309 + //~^ ERROR E0309 } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-trait-associated-type-trait.rs b/src/test/compile-fail/wf-trait-associated-type-trait.rs index 8c491e04c98..902cbe2676b 100644 --- a/src/test/compile-fail/wf-trait-associated-type-trait.rs +++ b/src/test/compile-fail/wf-trait-associated-type-trait.rs @@ -19,8 +19,8 @@ struct IsCopy<T:Copy> { x: T } trait SomeTrait { type Type1; type Type2 = IsCopy<Self::Type1>; - //~^ WARN E0277 + //~^ ERROR E0277 } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-trait-bound.rs b/src/test/compile-fail/wf-trait-bound.rs index 147b3ce236d..ca15a6ab648 100644 --- a/src/test/compile-fail/wf-trait-bound.rs +++ b/src/test/compile-fail/wf-trait-bound.rs @@ -16,10 +16,10 @@ trait ExtraCopy<T:Copy> { } -trait SomeTrait<T,U> //~ WARN E0277 +trait SomeTrait<T,U> //~ ERROR E0277 where T: ExtraCopy<U> { } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-trait-default-fn-arg.rs b/src/test/compile-fail/wf-trait-default-fn-arg.rs index 57c6c1979f8..453aa2428ce 100644 --- a/src/test/compile-fail/wf-trait-default-fn-arg.rs +++ b/src/test/compile-fail/wf-trait-default-fn-arg.rs @@ -19,11 +19,11 @@ struct Bar<T:Eq+?Sized> { value: Box<T> } trait Foo { fn bar(&self, x: &Bar<Self>) { - //~^ WARN E0277 + //~^ ERROR E0277 // // Here, Eq ought to be implemented. } } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-trait-default-fn-ret.rs b/src/test/compile-fail/wf-trait-default-fn-ret.rs index 939876403e5..d94708d3e06 100644 --- a/src/test/compile-fail/wf-trait-default-fn-ret.rs +++ b/src/test/compile-fail/wf-trait-default-fn-ret.rs @@ -19,12 +19,11 @@ struct Bar<T:Eq+?Sized> { value: Box<T> } trait Foo { fn bar(&self) -> Bar<Self> { - //~^ WARN E0277 + //~^ ERROR E0277 // // Here, Eq ought to be implemented. loop { } } } -#[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-trait-default-fn-where-clause.rs b/src/test/compile-fail/wf-trait-default-fn-where-clause.rs index b1c0d71fc5b..29c85250583 100644 --- a/src/test/compile-fail/wf-trait-default-fn-where-clause.rs +++ b/src/test/compile-fail/wf-trait-default-fn-where-clause.rs @@ -19,11 +19,11 @@ trait Bar<T:Eq+?Sized> { } trait Foo { fn bar<A>(&self) where A: Bar<Self> { - //~^ WARN E0277 + //~^ ERROR E0277 // // Here, Eq ought to be implemented. } } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-trait-fn-arg.rs b/src/test/compile-fail/wf-trait-fn-arg.rs index ff263c85eb3..d88e36faeec 100644 --- a/src/test/compile-fail/wf-trait-fn-arg.rs +++ b/src/test/compile-fail/wf-trait-fn-arg.rs @@ -18,10 +18,9 @@ struct Bar<T:Eq+?Sized> { value: Box<T> } trait Foo { fn bar(&self, x: &Bar<Self>); - //~^ WARN E0277 + //~^ ERROR E0277 // // Here, Eq ought to be implemented. } -#[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-trait-fn-ret.rs b/src/test/compile-fail/wf-trait-fn-ret.rs index 5c8f3030c2c..c368ff9a4a8 100644 --- a/src/test/compile-fail/wf-trait-fn-ret.rs +++ b/src/test/compile-fail/wf-trait-fn-ret.rs @@ -18,10 +18,9 @@ struct Bar<T:Eq+?Sized> { value: Box<T> } trait Foo { fn bar(&self) -> &Bar<Self>; - //~^ WARN E0277 + //~^ ERROR E0277 // // Here, Eq ought to be implemented. } -#[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-trait-fn-where-clause.rs b/src/test/compile-fail/wf-trait-fn-where-clause.rs index 51b5475e51f..f59dca93bb9 100644 --- a/src/test/compile-fail/wf-trait-fn-where-clause.rs +++ b/src/test/compile-fail/wf-trait-fn-where-clause.rs @@ -18,10 +18,10 @@ struct Bar<T:Eq+?Sized> { value: Box<T> } trait Foo { fn bar(&self) where Bar<Self>: Copy; - //~^ WARN E0277 + //~^ ERROR E0277 // // Here, Eq ought to be implemented. } #[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/compile-fail/wf-trait-superbound.rs b/src/test/compile-fail/wf-trait-superbound.rs index 58ee766dad1..ea8b2fdf3a1 100644 --- a/src/test/compile-fail/wf-trait-superbound.rs +++ b/src/test/compile-fail/wf-trait-superbound.rs @@ -16,8 +16,7 @@ trait ExtraCopy<T:Copy> { } -trait SomeTrait<T>: ExtraCopy<T> { //~ WARN E0277 +trait SomeTrait<T>: ExtraCopy<T> { //~ ERROR E0277 } -#[rustc_error] -fn main() { } //~ ERROR compilation successful +fn main() { } diff --git a/src/test/run-pass/cycle-generic-bound.rs b/src/test/run-pass/cycle-generic-bound.rs index 86b41284cdf..b6d84f9d5a2 100644 --- a/src/test/run-pass/cycle-generic-bound.rs +++ b/src/test/run-pass/cycle-generic-bound.rs @@ -15,4 +15,6 @@ trait Chromosome<X: Chromosome<i32>> { } +impl Chromosome<i32> for i32 { } + fn main() { } diff --git a/src/test/run-pass/cycle-trait-type-trait.rs b/src/test/run-pass/cycle-trait-type-trait.rs index 50bc9e971fb..4ae5c599b43 100644 --- a/src/test/run-pass/cycle-trait-type-trait.rs +++ b/src/test/run-pass/cycle-trait-type-trait.rs @@ -22,4 +22,12 @@ trait Get<A> { struct Struct<C:Chromosome> { c: C } +impl Chromosome for i32 { } + +impl Get<Struct<i32>> for i32 { + fn get(&self) -> Struct<i32> { + Struct { c: *self } + } +} + fn main() { } diff --git a/src/test/run-pass/issue-25810.rs b/src/test/run-pass/issue-25810.rs index 49a0642ce18..820872ad3fc 100644 --- a/src/test/run-pass/issue-25810.rs +++ b/src/test/run-pass/issue-25810.rs @@ -14,7 +14,9 @@ fn main() { println!("{:?}",y); } -trait Foo { +trait Foo + where for<'a> &'a Self: Bar +{ fn foo<'a>(&'a self) -> <&'a Self as Bar>::Output; } diff --git a/src/test/run-pass/issue-6898.rs b/src/test/run-pass/issue-6898.rs index 8ea0804af18..e0d2f13ad68 100644 --- a/src/test/run-pass/issue-6898.rs +++ b/src/test/run-pass/issue-6898.rs @@ -22,7 +22,7 @@ pub fn size_of_val<T>(val: &T) -> usize { val.size_of_val() } -pub trait TypeInfo { +pub trait TypeInfo: Sized { fn size_of(_lame_type_hint: Option<Self>) -> usize; fn size_of_val(&self) -> usize; } diff --git a/src/test/run-pass/regions-issue-22246.rs b/src/test/run-pass/regions-issue-22246.rs index 16236f94655..b6815d92967 100644 --- a/src/test/run-pass/regions-issue-22246.rs +++ b/src/test/run-pass/regions-issue-22246.rs @@ -17,7 +17,7 @@ use std::ops::Deref; -pub trait ToOwned { +pub trait ToOwned: Sized { type Owned: Borrow<Self>; fn to_owned(&self) -> Self::Owned; } diff --git a/src/test/run-pass/regions-no-variance-from-fn-generics.rs b/src/test/run-pass/regions-no-variance-from-fn-generics.rs index d385804da57..c339be25f8b 100644 --- a/src/test/run-pass/regions-no-variance-from-fn-generics.rs +++ b/src/test/run-pass/regions-no-variance-from-fn-generics.rs @@ -22,7 +22,7 @@ trait UseLife01 { } trait UseLife02 { - fn refs<'a, T, H: HasType<&'a T>>(&'a self) -> H; + fn refs<'a, T: 'a, H: HasType<&'a T>>(&'a self) -> H; } @@ -33,7 +33,7 @@ pub trait HasType<T> trait UseLife03<T> { - fn refs<'a, H: HasType<&'a T>>(&'a self) -> H; + fn refs<'a, H: HasType<&'a T>>(&'a self) -> H where T: 'a; } @@ -45,7 +45,7 @@ pub fn top_refs_1<'a, H: HasLife<'a>>(_s: &'a ()) -> H { unimplemented!() } -pub fn top_refs_2<'a, T, H: HasType<&'a T>>(_s: &'a ()) -> H { +pub fn top_refs_2<'a, T: 'a, H: HasType<&'a T>>(_s: &'a ()) -> H { unimplemented!() } diff --git a/src/test/run-pass/trait-inheritance-num0.rs b/src/test/run-pass/trait-inheritance-num0.rs index 83c2a9ad339..70515a088e2 100644 --- a/src/test/run-pass/trait-inheritance-num0.rs +++ b/src/test/run-pass/trait-inheritance-num0.rs @@ -16,7 +16,7 @@ use std::cmp::PartialOrd; -pub trait NumCast { +pub trait NumCast: Sized { fn from(i: i32) -> Option<Self>; } diff --git a/src/test/run-pass/trait-inheritance-num1.rs b/src/test/run-pass/trait-inheritance-num1.rs index 14a6a9a0c66..e21abdae730 100644 --- a/src/test/run-pass/trait-inheritance-num1.rs +++ b/src/test/run-pass/trait-inheritance-num1.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -pub trait NumCast { +pub trait NumCast: Sized { fn from(i: i32) -> Option<Self>; } diff --git a/src/test/run-pass/trait-inheritance-num3.rs b/src/test/run-pass/trait-inheritance-num3.rs index abf8d2baf87..fb56ae82b30 100644 --- a/src/test/run-pass/trait-inheritance-num3.rs +++ b/src/test/run-pass/trait-inheritance-num3.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub trait NumCast { +pub trait NumCast: Sized { fn from(i: i32) -> Option<Self>; } diff --git a/src/test/run-pass/trait-inheritance-num5.rs b/src/test/run-pass/trait-inheritance-num5.rs index c6f8a5d4f1d..bd442629243 100644 --- a/src/test/run-pass/trait-inheritance-num5.rs +++ b/src/test/run-pass/trait-inheritance-num5.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -pub trait NumCast { +pub trait NumCast: Sized { fn from(i: i32) -> Option<Self>; } diff --git a/src/test/run-pass/trait-inheritance-self-in-supertype.rs b/src/test/run-pass/trait-inheritance-self-in-supertype.rs index c7e206cb474..e353be16b45 100644 --- a/src/test/run-pass/trait-inheritance-self-in-supertype.rs +++ b/src/test/run-pass/trait-inheritance-self-in-supertype.rs @@ -17,7 +17,7 @@ pub trait FuzzyEq<Eps> { fn fuzzy_eq_eps(&self, other: &Self, epsilon: &Eps) -> bool; } -trait Float: FuzzyEq<Self> { +trait Float: Sized+FuzzyEq<Self> { fn two_pi() -> Self; } diff --git a/src/test/run-pass/trait-inheritance-self.rs b/src/test/run-pass/trait-inheritance-self.rs index 7d975da4a24..a025be5d651 100644 --- a/src/test/run-pass/trait-inheritance-self.rs +++ b/src/test/run-pass/trait-inheritance-self.rs @@ -12,7 +12,7 @@ trait Foo<T> { fn f(&self, x: &T); } -trait Bar : Foo<Self> { +trait Bar : Sized + Foo<Self> { fn g(&self); } diff --git a/src/test/run-pass/trait-inheritance-subst.rs b/src/test/run-pass/trait-inheritance-subst.rs index 3d82ee67925..73bb4bacf64 100644 --- a/src/test/run-pass/trait-inheritance-subst.rs +++ b/src/test/run-pass/trait-inheritance-subst.rs @@ -13,7 +13,7 @@ pub trait Add<RHS,Result> { fn add(&self, rhs: &RHS) -> Result; } -trait MyNum : Add<Self,Self> { } +trait MyNum : Sized + Add<Self,Self> { } struct MyInt { val: isize } diff --git a/src/test/run-pass/trait-inheritance-subst2.rs b/src/test/run-pass/trait-inheritance-subst2.rs index 6a363995435..7d3ebc19e8f 100644 --- a/src/test/run-pass/trait-inheritance-subst2.rs +++ b/src/test/run-pass/trait-inheritance-subst2.rs @@ -17,7 +17,7 @@ trait Add<RHS,Result>: Panda<RHS> { fn add(&self, rhs: &RHS) -> Result; } -trait MyNum : Add<Self,Self> { } +trait MyNum : Sized + Add<Self,Self> { } struct MyInt { val: isize } diff --git a/src/test/run-pass/unsized2.rs b/src/test/run-pass/unsized2.rs index 1cce98ae6b7..5b9fa5230d1 100644 --- a/src/test/run-pass/unsized2.rs +++ b/src/test/run-pass/unsized2.rs @@ -67,26 +67,26 @@ fn f7<X: ?Sized+T3>(x: &X) { trait T4<X> { fn dummy(&self) { } - fn m1(x: &T4<X>, y: X); - fn m2(x: &T5<X>, y: X); + fn m1(&self, x: &T4<X>, y: X); + fn m2(&self, x: &T5<X>, y: X); } trait T5<X: ?Sized> { fn dummy(&self) { } // not an error (for now) - fn m1(x: &T4<X>); - fn m2(x: &T5<X>); + fn m1(&self, x: &T4<X>); + fn m2(&self, x: &T5<X>); } trait T6<X: T> { fn dummy(&self) { } - fn m1(x: &T4<X>); - fn m2(x: &T5<X>); + fn m1(&self, x: &T4<X>); + fn m2(&self, x: &T5<X>); } trait T7<X: ?Sized+T> { fn dummy(&self) { } // not an error (for now) - fn m1(x: &T4<X>); - fn m2(x: &T5<X>); + fn m1(&self, x: &T4<X>); + fn m2(&self, x: &T5<X>); } // The last field in a struct or variant may be unsized |
