Test all the things

This commit is contained in:
Flavio Percoco 2015-01-27 01:07:31 +01:00
parent 0be1e430cf
commit 7213ef1a8f
9 changed files with 269 additions and 0 deletions

View file

@ -0,0 +1,25 @@
// 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
#![feature(optin_builtin_traits)]
trait MyTrait {}
impl MyTrait for .. {}
impl MyTrait for .. {}
//~^ ERROR conflicting implementations for trait `MyTrait`
impl MyTrait for (i32, i32) {}
//~^ ERROR implementations for traits providing default implementations are only allowed on
fn main() {}

View file

@ -0,0 +1,18 @@
// 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(optin_builtin_traits)]
trait MyDefaultImpl {}
impl<T> MyDefaultImpl for .. {}
//~^ ERROR default trait implementations are not allowed to have genercis
fn main() {}

View file

@ -0,0 +1,30 @@
// 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(optin_builtin_traits)]
trait MyTrait {}
impl MyTrait for .. {}
struct MyS;
struct MyS2;
impl !MyTrait for MyS2 {}
fn is_mytrait<T: MyTrait>() {}
fn main() {
is_mytrait::<MyS>();
is_mytrait::<(MyS2, MyS)>();
//~^ ERROR the trait `MyTrait` is not implemented for the type `MyS2`
}

View file

@ -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.
#![feature(optin_builtin_traits)]
trait MyTrait {}
impl MyTrait for .. {}
impl<T> !MyTrait for *mut T {}
struct MyS;
struct MyS2;
impl !MyTrait for MyS2 {}
struct MyS3;
fn is_mytrait<T: MyTrait>() {}
fn main() {
is_mytrait::<MyS>();
is_mytrait::<MyS2>();
//~^ ERROR the trait `MyTrait` is not implemented for the type `MyS2`
is_mytrait::<Vec<MyS3>>();
//~^ ERROR the trait `MyTrait` is not implemented for the type `*mut MyS3`
}

View file

@ -0,0 +1,31 @@
// 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(optin_builtin_traits)]
struct MySendable {
t: *mut u8
}
unsafe impl Send for MySendable {}
struct MyNotSendable {
t: *mut u8
}
impl !Send for MyNotSendable {}
fn is_send<T: Send>() {}
fn main() {
is_send::<MySendable>();
is_send::<MyNotSendable>();
//~^ ERROR the trait `core::marker::Send` is not implemented for the type `MyNotSendable`
}

View file

@ -0,0 +1,50 @@
// 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
#![feature(optin_builtin_traits)]
use std::marker::Managed;
use std::cell::UnsafeCell;
struct MySync {
t: *mut u8
}
unsafe impl Sync for MySync {}
struct MyNotSync {
t: *mut u8
}
impl !Sync for MyNotSync {}
struct MyTypeWUnsafe {
t: UnsafeCell<u8>
}
struct MyTypeManaged {
t: Managed
}
fn is_sync<T: Sync>() {}
fn main() {
is_sync::<MySync>();
is_sync::<MyNotSync>();
//~^ ERROR the trait `core::marker::Sync` is not implemented for the type `MyNotSync`
is_sync::<MyTypeWUnsafe>();
//~^ ERROR the trait `core::marker::Sync` is not implemented for the type `core::cell::UnsafeCell<u8>`
is_sync::<MyTypeManaged>();
//~^ ERROR the trait `core::marker::Sync` is not implemented for the type `core::marker::Managed`
}

View file

@ -0,0 +1,42 @@
// 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(optin_builtin_traits)]
trait MyTrait {}
impl MyTrait for .. {}
unsafe trait MyUnsafeTrait {}
unsafe impl MyUnsafeTrait for .. {}
struct ThisImplsTrait;
impl !MyUnsafeTrait for ThisImplsTrait {}
struct ThisImplsUnsafeTrait;
impl !MyTrait for ThisImplsUnsafeTrait {}
fn is_my_trait<T: MyTrait>() {}
fn is_my_unsafe_trait<T: MyUnsafeTrait>() {}
fn main() {
is_my_trait::<ThisImplsTrait>();
is_my_trait::<ThisImplsUnsafeTrait>();
//~^ ERROR the trait `MyTrait` is not implemented for the type `ThisImplsUnsafeTrait`
is_my_unsafe_trait::<ThisImplsTrait>();
//~^ ERROR the trait `MyUnsafeTrait` is not implemented for the type `ThisImplsTrait`
is_my_unsafe_trait::<ThisImplsUnsafeTrait>();
}

View file

@ -0,0 +1,18 @@
// 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
#![feature(optin_builtin_traits)]
impl Copy for .. {}
//~^ ERROR cannot create default implementations for traits outside the crate they're defined in; define a new trait instead.
fn main() {}

View file

@ -0,0 +1,19 @@
// Copyright 2014 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)]
// pp-exact
trait MyTrait { }
impl MyTrait for .. { }
pub fn main() { }