diff options
Diffstat (limited to 'src/test/compile-fail/specialization/defaultimpl')
6 files changed, 0 insertions, 226 deletions
diff --git a/src/test/compile-fail/specialization/defaultimpl/specialization-feature-gate-default.rs b/src/test/compile-fail/specialization/defaultimpl/specialization-feature-gate-default.rs deleted file mode 100644 index 5bab4c5438e..00000000000 --- a/src/test/compile-fail/specialization/defaultimpl/specialization-feature-gate-default.rs +++ /dev/null @@ -1,21 +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. - -// Check that specialization must be ungated to use the `default` keyword - -trait Foo { - fn foo(&self); -} - -default impl<T> Foo for T { //~ ERROR specialization is unstable - fn foo(&self) {} -} - -fn main() {} diff --git a/src/test/compile-fail/specialization/defaultimpl/specialization-no-default.rs b/src/test/compile-fail/specialization/defaultimpl/specialization-no-default.rs deleted file mode 100644 index 2874108157d..00000000000 --- a/src/test/compile-fail/specialization/defaultimpl/specialization-no-default.rs +++ /dev/null @@ -1,95 +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. - -#![feature(specialization)] - -// Check a number of scenarios in which one impl tries to override another, -// without correctly using `default`. - -//////////////////////////////////////////////////////////////////////////////// -// Test 1: one layer of specialization, multiple methods, missing `default` -//////////////////////////////////////////////////////////////////////////////// - -trait Foo { - fn foo(&self); - fn bar(&self); -} - -impl<T> Foo for T { - fn foo(&self) {} - fn bar(&self) {} -} - -impl Foo for u8 {} -impl Foo for u16 { - fn foo(&self) {} //~ ERROR E0520 -} -impl Foo for u32 { - fn bar(&self) {} //~ ERROR E0520 -} - -//////////////////////////////////////////////////////////////////////////////// -// Test 2: one layer of specialization, missing `default` on associated type -//////////////////////////////////////////////////////////////////////////////// - -trait Bar { - type T; -} - -impl<T> Bar for T { - type T = u8; -} - -impl Bar for u8 { - type T = (); //~ ERROR E0520 -} - -//////////////////////////////////////////////////////////////////////////////// -// Test 3a: multiple layers of specialization, missing interior `default` -//////////////////////////////////////////////////////////////////////////////// - -trait Baz { - fn baz(&self); -} - -default impl<T> Baz for T { - fn baz(&self) {} -} - -impl<T: Clone> Baz for T { - fn baz(&self) {} -} - -impl Baz for i32 { - fn baz(&self) {} //~ ERROR E0520 -} - -//////////////////////////////////////////////////////////////////////////////// -// Test 3b: multiple layers of specialization, missing interior `default`, -// redundant `default` in bottom layer. -//////////////////////////////////////////////////////////////////////////////// - -trait Redundant { - fn redundant(&self); -} - -default impl<T> Redundant for T { - fn redundant(&self) {} -} - -impl<T: Clone> Redundant for T { - fn redundant(&self) {} -} - -default impl Redundant for i32 { - fn redundant(&self) {} //~ ERROR E0520 -} - -fn main() {} diff --git a/src/test/compile-fail/specialization/defaultimpl/specialization-trait-item-not-implemented.rs b/src/test/compile-fail/specialization/defaultimpl/specialization-trait-item-not-implemented.rs deleted file mode 100644 index eacec2e40f0..00000000000 --- a/src/test/compile-fail/specialization/defaultimpl/specialization-trait-item-not-implemented.rs +++ /dev/null @@ -1,33 +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. - -// Tests that default impls do not have to supply all items but regular impls do. - -#![feature(specialization)] - -trait Foo { - fn foo_one(&self) -> &'static str; - fn foo_two(&self) -> &'static str; -} - -struct MyStruct; - -default impl<T> Foo for T { - fn foo_one(&self) -> &'static str { - "generic" - } -} - -impl Foo for MyStruct {} -//~^ ERROR not all trait items implemented, missing: `foo_two` [E0046] - -fn main() { - println!("{}", MyStruct.foo_one()); -} diff --git a/src/test/compile-fail/specialization/defaultimpl/specialization-trait-not-implemented.rs b/src/test/compile-fail/specialization/defaultimpl/specialization-trait-not-implemented.rs deleted file mode 100644 index 04ddf9ebb17..00000000000 --- a/src/test/compile-fail/specialization/defaultimpl/specialization-trait-not-implemented.rs +++ /dev/null @@ -1,34 +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. - -// Tests that: -// - default impls do not have to supply all items and -// - a default impl does not count as an impl (in this case, an incomplete default impl). - -#![feature(specialization)] - -trait Foo { - fn foo_one(&self) -> &'static str; - fn foo_two(&self) -> &'static str; -} - -struct MyStruct; - -default impl<T> Foo for T { - fn foo_one(&self) -> &'static str { - "generic" - } -} - - -fn main() { - println!("{}", MyStruct.foo_one()); - //~^ ERROR no method named `foo_one` found for type `MyStruct` in the current scope -} diff --git a/src/test/compile-fail/specialization/defaultimpl/specialization-wfcheck.rs b/src/test/compile-fail/specialization/defaultimpl/specialization-wfcheck.rs deleted file mode 100644 index 445a59a373e..00000000000 --- a/src/test/compile-fail/specialization/defaultimpl/specialization-wfcheck.rs +++ /dev/null @@ -1,20 +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. - -// Tests that a default impl still has to have a WF trait ref. - -#![feature(specialization)] - -trait Foo<'a, T: Eq + 'a> { } - -default impl<U> Foo<'static, U> for () {} -//~^ ERROR the trait bound `U: std::cmp::Eq` is not satisfied - -fn main(){} diff --git a/src/test/compile-fail/specialization/defaultimpl/validation.rs b/src/test/compile-fail/specialization/defaultimpl/validation.rs deleted file mode 100644 index 26b8b737f34..00000000000 --- a/src/test/compile-fail/specialization/defaultimpl/validation.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 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. - -#![feature(optin_builtin_traits)] -#![feature(specialization)] - -struct S; -struct Z; - -default impl S {} //~ ERROR inherent impls cannot be default - -default unsafe impl Send for S {} //~ ERROR impls of auto traits cannot be default -default impl !Send for Z {} //~ ERROR impls of auto traits cannot be default - -trait Tr {} -default impl !Tr for S {} //~ ERROR negative impls are only allowed for auto traits |
