Remove the coherence impls pass that was specialized to builtin bounds,

since there are separate checks that apply to Copy (and Send uses the
generic defaulted trait rules). Also prohibit `Sized` from being
manually implemented for now.
This commit is contained in:
Niko Matsakis 2015-03-06 15:55:30 -05:00
parent 2e216896e4
commit 4e789e03be
11 changed files with 184 additions and 90 deletions

View file

@ -15,3 +15,5 @@ use std::marker::MarkerTrait;
pub trait DefaultedTrait : MarkerTrait { }
impl DefaultedTrait for .. { }
pub struct Something<T> { t: T }

View file

@ -0,0 +1,39 @@
// 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)]
use std::marker::Copy;
enum TestE {
A
}
struct MyType;
struct NotSync;
impl !Sync for NotSync {}
impl Copy for TestE {}
impl Copy for MyType {}
impl Copy for (MyType, MyType) {}
//~^ ERROR E0206
impl Copy for &'static NotSync {}
//~^ ERROR E0206
impl Copy for [MyType] {}
//~^ ERROR E0206
impl Copy for &'static [NotSync] {}
//~^ ERROR E0206
fn main() {
}

View file

@ -10,7 +10,7 @@
#![feature(optin_builtin_traits)]
use std::marker::Send;
use std::marker::Copy;
enum TestE {
A
@ -24,20 +24,17 @@ impl !Sync for NotSync {}
unsafe impl Send for TestE {}
unsafe impl Send for MyType {}
unsafe impl Send for (MyType, MyType) {}
//~^ ERROR builtin traits can only be implemented on structs or enums
//~^ ERROR E0321
unsafe impl Send for &'static NotSync {}
//~^ ERROR builtin traits can only be implemented on structs or enums
//~^ ERROR E0321
unsafe impl Send for [MyType] {}
//~^ ERROR builtin traits can only be implemented on structs or enums
//~^ ERROR E0321
unsafe impl Send for &'static [NotSync] {}
//~^ ERROR builtin traits can only be implemented on structs or enums
//~^^ ERROR conflicting implementations for trait `core::marker::Send`
fn is_send<T: Send>() {}
//~^ ERROR E0321
//~| ERROR conflicting implementations
fn main() {
is_send::<(MyType, TestE)>();
}

View file

@ -0,0 +1,33 @@
// 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)]
use std::marker::Copy;
enum TestE {
A
}
struct MyType;
struct NotSync;
impl !Sync for NotSync {}
impl Sized for TestE {} //~ ERROR E0322
impl Sized for MyType {} //~ ERROR E0322
impl Sized for (MyType, MyType) {} //~ ERROR E0322
impl Sized for &'static NotSync {} //~ ERROR E0322
impl Sized for [MyType] {} //~ ERROR E0322
//~^ ERROR E0277
impl Sized for &'static [NotSync] {} //~ ERROR E0322
fn main() {
}

View file

@ -19,13 +19,15 @@ use lib::TheTrait;
struct TheType;
impl TheTrait<usize> for isize { } //~ ERROR E0117
impl TheTrait<usize> for isize { }
//~^ ERROR E0117
impl TheTrait<TheType> for isize { }
impl TheTrait<isize> for TheType { }
impl !Send for Vec<isize> { } //~ ERROR E0117
//~^ ERROR conflicting
impl !Send for Vec<isize> { }
//~^ ERROR E0117
//~| ERROR E0119
fn main() { }

View file

@ -20,15 +20,15 @@ extern crate "typeck-default-trait-impl-cross-crate-coherence-lib" as lib;
use lib::DefaultedTrait;
struct A;
impl DefaultedTrait for (A,) { }
//~^ ERROR can only be implemented for a struct or enum type
impl DefaultedTrait for (A,) { } //~ ERROR E0321
struct B;
impl !DefaultedTrait for (B,) { }
//~^ ERROR can only be implemented for a struct or enum type
impl !DefaultedTrait for (B,) { } //~ ERROR E0321
struct C;
impl DefaultedTrait for Box<C> { }
//~^ ERROR can only be implemented for a struct or enum type
struct D<T>(T);
impl DefaultedTrait for Box<C> { } //~ ERROR E0321
impl DefaultedTrait for lib::Something<C> { } //~ ERROR E0321
impl DefaultedTrait for D<C> { } // OK
fn main() { }

View file

@ -13,6 +13,6 @@
#![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.
//~^ ERROR E0318
fn main() {}