Auto merge of #23038 - nikomatsakis:issue-22978-defaulted-coherence, r=flaper87
Fixes #22978. r? @FlaPer87
This commit is contained in:
commit
12b846ab80
18 changed files with 299 additions and 131 deletions
|
|
@ -0,0 +1,19 @@
|
|||
// 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)]
|
||||
#![crate_type = "rlib"]
|
||||
|
||||
use std::marker::MarkerTrait;
|
||||
|
||||
pub trait DefaultedTrait : MarkerTrait { }
|
||||
impl DefaultedTrait for .. { }
|
||||
|
||||
pub struct Something<T> { t: T }
|
||||
39
src/test/compile-fail/coherence-impls-copy.rs
Normal file
39
src/test/compile-fail/coherence-impls-copy.rs
Normal 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() {
|
||||
}
|
||||
|
|
@ -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)>();
|
||||
}
|
||||
33
src/test/compile-fail/coherence-impls-sized.rs
Normal file
33
src/test/compile-fail/coherence-impls-sized.rs
Normal 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() {
|
||||
}
|
||||
|
|
@ -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() { }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:typeck-default-trait-impl-cross-crate-coherence-lib.rs
|
||||
|
||||
// Test that we do not consider associated types to be sendable without
|
||||
// some applicable trait bound (and we don't ICE).
|
||||
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
||||
extern crate "typeck-default-trait-impl-cross-crate-coherence-lib" as lib;
|
||||
|
||||
use lib::DefaultedTrait;
|
||||
|
||||
struct A;
|
||||
impl DefaultedTrait for (A,) { } //~ ERROR E0321
|
||||
|
||||
struct B;
|
||||
impl !DefaultedTrait for (B,) { } //~ ERROR E0321
|
||||
|
||||
struct C;
|
||||
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() { }
|
||||
|
|
@ -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() {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue