Add some tests

This copies and adjusts the existing coherence tests to ensure that
they continue to work using the new implementation.
This commit is contained in:
Georg Semmler 2018-11-21 21:35:56 +01:00
parent 757d7ba9c9
commit bcd7acfe04
No known key found for this signature in database
GPG Key ID: A87BCEE5205CE489
128 changed files with 3144 additions and 0 deletions

View File

@ -0,0 +1,20 @@
// 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.
#![crate_type = "rlib"]
#![feature(fundamental)]
pub trait MyCopy { }
impl MyCopy for i32 { }
pub struct MyStruct<T>(T);
#[fundamental]
pub struct MyFundamentalStruct<T>(T);

View File

@ -0,0 +1,25 @@
// 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.
#![crate_type="lib"]
pub trait Remote {
fn foo(&self) { }
}
pub trait Remote1<T> {
fn foo(&self, t: T) { }
}
pub trait Remote2<T, U> {
fn foo(&self, t: T, u: U) { }
}
pub struct Pair<T,U>(T,U);

View File

@ -0,0 +1,23 @@
pub trait Backend{}
pub trait SupportsDefaultKeyword {}
impl SupportsDefaultKeyword for Postgres {}
pub struct Postgres;
impl Backend for Postgres {}
pub struct AstPass<DB>(::std::marker::PhantomData<DB>);
pub trait QueryFragment<DB: Backend> {}
#[derive(Debug, Clone, Copy)]
pub struct BatchInsert<'a, T: 'a, Tab> {
_marker: ::std::marker::PhantomData<(&'a T, Tab)>,
}
impl<'a, T:'a, Tab, DB> QueryFragment<DB> for BatchInsert<'a, T, Tab>
where DB: SupportsDefaultKeyword + Backend,
{}

View File

@ -0,0 +1,25 @@
// 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(re_rebalance_coherence)]
// run-pass
// aux-build:coherence_lib.rs
// pretty-expanded FIXME #23616
extern crate coherence_lib as lib;
use lib::Remote1;
pub struct BigInt;
impl Remote1<BigInt> for isize { }
fn main() { }

View File

@ -0,0 +1,25 @@
// 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(re_rebalance_coherence)]
// run-pass
// aux-build:coherence_lib.rs
// pretty-expanded FIXME #23616
extern crate coherence_lib as lib;
use lib::Remote1;
pub struct BigInt;
impl Remote1<BigInt> for Vec<isize> { }
fn main() { }

View File

@ -0,0 +1,27 @@
// 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.
// run-pass
#![allow(unused_imports)]
#![feature(re_rebalance_coherence)]
// aux-build:coherence_lib.rs
// pretty-expanded FIXME #23616
extern crate coherence_lib as lib;
use lib::Remote1;
pub trait Local {
fn foo(&self) { }
}
impl<T> Local for T { }
fn main() { }

View File

@ -0,0 +1,25 @@
// 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.
// run-pass
#![allow(dead_code)]
#![feature(re_rebalance_coherence)]
// aux-build:coherence_lib.rs
// pretty-expanded FIXME #23616
extern crate coherence_lib as lib;
use lib::Remote;
struct Foo<T>(T);
impl<T> Remote for Foo<T> { }
fn main() { }

View File

@ -0,0 +1,25 @@
// 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.
// run-pass
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![feature(re_rebalance_coherence)]
pub fn main() {
#[derive(Copy, Clone)]
enum x { foo }
impl ::std::cmp::PartialEq for x {
fn eq(&self, other: &x) -> bool {
(*self) as isize == (*other) as isize
}
fn ne(&self, other: &x) -> bool { !(*self).eq(other) }
}
}

View File

@ -0,0 +1,25 @@
// 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.
// run-pass
#![allow(dead_code)]
#![feature(re_rebalance_coherence)]
// aux-build:coherence_lib.rs
// pretty-expanded FIXME #23616
extern crate coherence_lib as lib;
use lib::Remote1;
struct Foo<T>(T);
impl<T,U> Remote1<U> for Foo<T> { }
fn main() { }

View File

@ -0,0 +1,25 @@
// 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.
// run-pass
#![allow(dead_code)]
#![feature(re_rebalance_coherence)]
// aux-build:coherence_lib.rs
// pretty-expanded FIXME #23616
extern crate coherence_lib as lib;
use lib::Remote1;
struct Foo<T>(T);
impl<T> Remote1<T> for Foo<T> { }
fn main() { }

View File

@ -0,0 +1,35 @@
// 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.
// run-pass
#![allow(unused_imports)]
#![feature(re_rebalance_coherence)]
// pretty-expanded FIXME #23616
use std::fmt::Debug;
use std::default::Default;
// Test that an impl for homogeneous pairs does not conflict with a
// heterogeneous pair.
trait MyTrait {
fn get(&self) -> usize;
}
impl<T> MyTrait for (T,T) {
fn get(&self) -> usize { 0 }
}
impl MyTrait for (usize,isize) {
fn get(&self) -> usize { 0 }
}
fn main() {
}

View File

@ -0,0 +1,24 @@
// 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.
// run-pass
#![allow(dead_code)]
// pretty-expanded FIXME #23616
#![feature(optin_builtin_traits)]
#![feature(re_rebalance_coherence)]
use std::marker::Send;
struct TestType;
impl !Send for TestType {}
fn main() {}

View File

@ -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.
#![feature(re_rebalance_coherence)]
// run-pass
// check that trait matching can handle impls whose types are only
// constrained by a projection.
trait IsU32 {}
impl IsU32 for u32 {}
trait Mirror { type Image: ?Sized; }
impl<T: ?Sized> Mirror for T { type Image = T; }
trait Bar {}
impl<U: Mirror, V: Mirror<Image=L>, L: Mirror<Image=U>> Bar for V
where U::Image: IsU32 {}
trait Foo { fn name() -> &'static str; }
impl Foo for u64 { fn name() -> &'static str { "u64" } }
impl<T: Bar> Foo for T { fn name() -> &'static str { "Bar" }}
fn main() {
assert_eq!(<u64 as Foo>::name(), "u64");
assert_eq!(<u32 as Foo>::name(), "Bar");
}

View File

@ -0,0 +1,51 @@
// 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(re_rebalance_coherence)]
// run-pass
// Test that two distinct impls which match subtypes of one another
// yield coherence errors (or not) depending on the variance.
trait Contravariant {
fn foo(&self) { }
}
impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
}
impl Contravariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
}
///////////////////////////////////////////////////////////////////////////
trait Covariant {
fn foo(&self) { }
}
impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
}
impl Covariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
}
///////////////////////////////////////////////////////////////////////////
trait Invariant {
fn foo(&self) { }
}
impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
}
impl Invariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
}
fn main() { }

View File

@ -0,0 +1,49 @@
// 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(re_rebalance_coherence)]
// run-pass
use std::fmt::Debug;
use std::default::Default;
trait MyTrait {
fn get(&self) -> Self;
}
impl<T> MyTrait for T
where T : Default
{
fn get(&self) -> T {
Default::default()
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
struct MyType {
dummy: usize
}
impl MyTrait for MyType {
fn get(&self) -> MyType { (*self).clone() }
}
fn test_eq<M>(m: M, n: M)
where M : MyTrait + Debug + PartialEq
{
assert_eq!(m.get(), n);
}
pub fn main() {
test_eq(0_usize, 0_usize);
let value = MyType { dummy: 256 + 22 };
test_eq(value, value);
}

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.
// run-pass
#![allow(dead_code)]
#![feature(re_rebalance_coherence)]
// Test that we are able to introduce a negative constraint that
// `MyType: !MyTrait` along with other "fundamental" wrappers.
// aux-build:coherence_copy_like_lib.rs
extern crate coherence_copy_like_lib as lib;
struct MyType { x: i32 }
trait MyTrait { }
impl<T: lib::MyCopy> MyTrait for T { }
impl MyTrait for MyType { }
impl<'a> MyTrait for &'a MyType { }
impl MyTrait for Box<MyType> { }
impl<'a> MyTrait for &'a Box<MyType> { }
fn main() { }

View File

@ -0,0 +1,13 @@
#![feature(re_rebalance_coherence)]
// run-pass
// aux-build:re_rebalance_coherence_lib.rs
extern crate re_rebalance_coherence_lib as lib;
use lib::*;
struct Oracle;
impl Backend for Oracle {}
impl<'a, T:'a, Tab> QueryFragment<Oracle> for BatchInsert<'a, T, Tab> {}
fn main() {}

View File

@ -0,0 +1,23 @@
pub trait Backend{}
pub trait SupportsDefaultKeyword {}
impl SupportsDefaultKeyword for Postgres {}
pub struct Postgres;
impl Backend for Postgres {}
pub struct AstPass<DB>(::std::marker::PhantomData<DB>);
pub trait QueryFragment<DB: Backend> {}
#[derive(Debug, Clone, Copy)]
pub struct BatchInsert<'a, T: 'a, Tab> {
_marker: ::std::marker::PhantomData<(&'a T, Tab)>,
}
impl<'a, T:'a, Tab, DB> QueryFragment<DB> for BatchInsert<'a, T, Tab>
where DB: SupportsDefaultKeyword + Backend,
{}

View File

@ -0,0 +1,13 @@
// Test that the use of the box syntax is gated by `box_syntax` feature gate.
// aux-build:re_rebalance_coherence_lib.rs
extern crate re_rebalance_coherence_lib as lib;
use lib::*;
struct Oracle;
impl Backend for Oracle {}
impl<'a, T:'a, Tab> QueryFragment<Oracle> for BatchInsert<'a, T, Tab> {}
// ~^ ERROR E0210
fn main() {}

View File

@ -0,0 +1,11 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct<T>`)
--> $DIR/feature-gate-re-rebalance-coherence.rs:10:1
|
LL | impl<'a, T:'a, Tab> QueryFragment<Oracle> for BatchInsert<'a, T, Tab> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter
error: aborting due to previous error
For more information about this error, try `rustc --explain E0210`.

View File

@ -0,0 +1,20 @@
// 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.
#![crate_type = "rlib"]
#![feature(fundamental)]
pub trait MyCopy { }
impl MyCopy for i32 { }
pub struct MyStruct<T>(T);
#[fundamental]
pub struct MyFundamentalStruct<T>(T);

View File

@ -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.
// See coherence_inherent_cc.rs
pub trait TheTrait {
fn the_fn(&self);
}
pub struct TheStruct;
impl TheTrait for TheStruct {
fn the_fn(&self) {}
}

View File

@ -0,0 +1,25 @@
// 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.
#![crate_type="lib"]
pub trait Remote {
fn foo(&self) { }
}
pub trait Remote1<T> {
fn foo(&self, t: T) { }
}
pub trait Remote2<T, U> {
fn foo(&self, t: T, u: U) { }
}
pub struct Pair<T,U>(T,U);

View File

@ -0,0 +1,13 @@
// 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.
pub trait TheTrait<T> {
fn the_fn(&self);
}

View File

@ -0,0 +1,53 @@
// 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(specialization)]
// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy.
pub trait Go {
fn go(&self, arg: isize);
}
pub fn go<G:Go>(this: &G, arg: isize) {
this.go(arg)
}
pub trait GoMut {
fn go_mut(&mut self, arg: isize);
}
pub fn go_mut<G:GoMut>(this: &mut G, arg: isize) {
this.go_mut(arg)
}
pub trait GoOnce {
fn go_once(self, arg: isize);
}
pub fn go_once<G:GoOnce>(this: G, arg: isize) {
this.go_once(arg)
}
impl<G> GoMut for G
where G : Go
{
default fn go_mut(&mut self, arg: isize) {
go(&*self, arg)
}
}
impl<G> GoOnce for G
where G : GoMut
{
default fn go_once(mut self, arg: isize) {
go_mut(&mut self, arg)
}
}

View File

@ -0,0 +1,16 @@
// 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.
pub trait Foo {
fn foo() {}
}
impl Foo for isize {
}

View File

@ -0,0 +1,21 @@
// 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.
// aux-build:coherence_lib.rs
#![feature(re_rebalance_coherence)]
extern crate coherence_lib as lib;
use lib::Remote1;
impl<T> Remote1<T> for isize { }
//~^ ERROR E0210
fn main() { }

View File

@ -0,0 +1,11 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct<T>`)
--> $DIR/coherence-all-remote.rs:18:1
|
LL | impl<T> Remote1<T> for isize { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter
error: aborting due to previous error
For more information about this error, try `rustc --explain E0210`.

View File

@ -0,0 +1,23 @@
// 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(re_rebalance_coherence)]
// aux-build:coherence_lib.rs
extern crate coherence_lib as lib;
use lib::Remote1;
pub struct BigInt;
impl<T> Remote1<BigInt> for T { }
//~^ ERROR type parameter `T` must be used as the type parameter for some local type
fn main() { }

View File

@ -0,0 +1,11 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct<T>`)
--> $DIR/coherence-bigint-param.rs:20:1
|
LL | impl<T> Remote1<BigInt> for T { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter
error: aborting due to previous error
For more information about this error, try `rustc --explain E0210`.

View File

@ -0,0 +1,40 @@
// 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(re_rebalance_coherence)]
use std::fmt::Debug;
use std::default::Default;
// Test that two blanket impls conflict (at least without negative
// bounds). After all, some other crate could implement Even or Odd
// for the same type (though this crate doesn't).
trait MyTrait {
fn get(&self) -> usize;
}
trait Even { }
trait Odd { }
impl Even for isize { }
impl Odd for usize { }
impl<T:Even> MyTrait for T {
fn get(&self) -> usize { 0 }
}
impl<T:Odd> MyTrait for T { //~ ERROR E0119
fn get(&self) -> usize { 0 }
}
fn main() { }

View File

@ -0,0 +1,12 @@
error[E0119]: conflicting implementations of trait `MyTrait`:
--> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:36:1
|
LL | impl<T:Even> MyTrait for T {
| -------------------------- first implementation here
...
LL | impl<T:Odd> MyTrait for T { //~ ERROR E0119
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View File

@ -0,0 +1,36 @@
// 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(re_rebalance_coherence)]
use std::fmt::Debug;
use std::default::Default;
// Test that two blanket impls conflict (at least without negative
// bounds). After all, some other crate could implement Even or Odd
// for the same type (though this crate doesn't implement them at all).
trait MyTrait {
fn get(&self) -> usize;
}
trait Even {}
trait Odd {}
impl<T:Even> MyTrait for T {
fn get(&self) -> usize { 0 }
}
impl<T:Odd> MyTrait for T { //~ ERROR E0119
fn get(&self) -> usize { 0 }
}
fn main() { }

View File

@ -0,0 +1,12 @@
error[E0119]: conflicting implementations of trait `MyTrait`:
--> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:32:1
|
LL | impl<T:Even> MyTrait for T {
| -------------------------- first implementation here
...
LL | impl<T:Odd> MyTrait for T { //~ ERROR E0119
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View File

@ -0,0 +1,31 @@
// 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(re_rebalance_coherence)]
// aux-build:go_trait.rs
extern crate go_trait;
use go_trait::{Go,GoMut};
use std::fmt::Debug;
use std::default::Default;
struct MyThingy;
impl Go for MyThingy {
fn go(&self, arg: isize) { }
}
impl GoMut for MyThingy { //~ ERROR conflicting implementations
fn go_mut(&mut self, arg: isize) { }
}
fn main() { }

View File

@ -0,0 +1,13 @@
error[E0119]: conflicting implementations of trait `go_trait::GoMut` for type `MyThingy`:
--> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:27:1
|
LL | impl GoMut for MyThingy { //~ ERROR conflicting implementations
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `go_trait`:
- impl<G> go_trait::GoMut for G
where G: go_trait::Go;
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View File

@ -0,0 +1,38 @@
// 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(re_rebalance_coherence)]
use std::fmt::Debug;
use std::default::Default;
// Test that a blank impl for all T conflicts with an impl for some
// specific T, even when there are multiple type parameters involved.
trait MyTrait<T> {
fn get(&self) -> T;
}
impl<T> MyTrait<T> for T {
fn get(&self) -> T {
panic!()
}
}
#[derive(Clone)]
struct MyType {
dummy: usize
}
impl MyTrait<MyType> for MyType { //~ ERROR E0119
fn get(&self) -> usize { (*self).clone() }
}
fn main() { }

View File

@ -0,0 +1,12 @@
error[E0119]: conflicting implementations of trait `MyTrait<MyType>` for type `MyType`:
--> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:34:1
|
LL | impl<T> MyTrait<T> for T {
| ------------------------ first implementation here
...
LL | impl MyTrait<MyType> for MyType { //~ ERROR E0119
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View File

@ -0,0 +1,40 @@
// 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(re_rebalance_coherence)]
// Test that a blank impl for all T:PartialEq conflicts with an impl for some
// specific T when T:PartialEq.
trait OtherTrait {
fn noop(&self);
}
trait MyTrait {
fn get(&self) -> usize;
}
impl<T:OtherTrait> MyTrait for T {
fn get(&self) -> usize { 0 }
}
struct MyType {
dummy: usize
}
impl MyTrait for MyType { //~ ERROR E0119
fn get(&self) -> usize { self.dummy }
}
impl OtherTrait for MyType {
fn noop(&self) { }
}
fn main() { }

View File

@ -0,0 +1,12 @@
error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`:
--> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:32:1
|
LL | impl<T:OtherTrait> MyTrait for T {
| -------------------------------- first implementation here
...
LL | impl MyTrait for MyType { //~ ERROR E0119
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View File

@ -0,0 +1,35 @@
// 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(re_rebalance_coherence)]
use std::fmt::Debug;
use std::default::Default;
// Test that a blank impl for all T conflicts with an impl for some
// specific T.
trait MyTrait {
fn get(&self) -> usize;
}
impl<T> MyTrait for T {
fn get(&self) -> usize { 0 }
}
struct MyType {
dummy: usize
}
impl MyTrait for MyType { //~ ERROR E0119
fn get(&self) -> usize { self.dummy }
}
fn main() { }

View File

@ -0,0 +1,12 @@
error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`:
--> $DIR/coherence-blanket-conflicts-with-specific.rs:31:1
|
LL | impl<T> MyTrait for T {
| --------------------- first implementation here
...
LL | impl MyTrait for MyType { //~ ERROR E0119
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View File

@ -0,0 +1,29 @@
// 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)]
#![feature(overlapping_marker_traits)]
#![feature(re_rebalance_coherence)]
trait MyTrait {}
struct TestType<T>(::std::marker::PhantomData<T>);
unsafe impl<T: MyTrait+'static> Send for TestType<T> {}
impl<T: MyTrait> !Send for TestType<T> {}
//~^ ERROR conflicting implementations of trait `std::marker::Send`
unsafe impl<T:'static> Send for TestType<T> {}
impl !Send for TestType<i32> {}
//~^ ERROR conflicting implementations of trait `std::marker::Send`
fn main() {}

View File

@ -0,0 +1,21 @@
error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType<_>`:
--> $DIR/coherence-conflicting-negative-trait-impl.rs:21:1
|
LL | unsafe impl<T: MyTrait+'static> Send for TestType<T> {}
| ---------------------------------------------------- first implementation here
LL |
LL | impl<T: MyTrait> !Send for TestType<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>`
error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType<i32>`:
--> $DIR/coherence-conflicting-negative-trait-impl.rs:26:1
|
LL | unsafe impl<T:'static> Send for TestType<T> {}
| ------------------------------------------- first implementation here
LL |
LL | impl !Send for TestType<i32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<i32>`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0119`.

View File

@ -0,0 +1,12 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-cow.rs:28:1
|
LL | impl<T> Remote for Pair<T,Cover<T>> { } //[a]~ ERROR E0117
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error: aborting due to previous error
For more information about this error, try `rustc --explain E0117`.

View File

@ -0,0 +1,12 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-cow.rs:31:1
|
LL | impl<T> Remote for Pair<Cover<T>,T> { } //[b]~ ERROR E0117
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error: aborting due to previous error
For more information about this error, try `rustc --explain E0117`.

View File

@ -0,0 +1,12 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-cow.rs:34:1
|
LL | impl<T,U> Remote for Pair<Cover<T>,U> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error: aborting due to previous error
For more information about this error, try `rustc --explain E0117`.

View File

@ -0,0 +1,37 @@
// 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(re_rebalance_coherence)]
// revisions: a b c
// aux-build:coherence_lib.rs
// Test that the `Pair` type reports an error if it contains type
// parameters, even when they are covered by local types. This test
// was originally intended to test the opposite, but the rules changed
// with RFC 1023 and this became illegal.
extern crate coherence_lib as lib;
use lib::{Remote,Pair};
pub struct Cover<T>(T);
#[cfg(a)]
impl<T> Remote for Pair<T,Cover<T>> { } //[a]~ ERROR E0117
#[cfg(b)]
impl<T> Remote for Pair<Cover<T>,T> { } //[b]~ ERROR E0117
#[cfg(c)]
impl<T,U> Remote for Pair<Cover<T>,U> { }
//[c]~^ ERROR E0117
fn main() { }

View File

@ -0,0 +1,26 @@
// 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(re_rebalance_coherence)]
// The error here is strictly due to orphan rules; the impl here
// generalizes the one upstream
// aux-build:trait_impl_conflict.rs
extern crate trait_impl_conflict;
use trait_impl_conflict::Foo;
impl<A> Foo for A {
//~^ ERROR type parameter `A` must be used as the type parameter for some local type
//~| ERROR conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize`
}
fn main() {
}

View File

@ -0,0 +1,21 @@
error[E0119]: conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize`:
--> $DIR/coherence-cross-crate-conflict.rs:20:1
|
LL | impl<A> Foo for A {
| ^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `trait_impl_conflict`:
- impl trait_impl_conflict::Foo for isize;
error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g. `MyStruct<A>`)
--> $DIR/coherence-cross-crate-conflict.rs:20:1
|
LL | impl<A> Foo for A {
| ^^^^^^^^^^^^^^^^^ type parameter `A` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter
error: aborting due to 2 previous errors
Some errors occurred: E0119, E0210.
For more information about an error, try `rustc --explain E0119`.

View File

@ -0,0 +1,26 @@
// 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)]
#![feature(re_rebalance_coherence)]
auto trait MySafeTrait {}
struct Foo;
unsafe impl MySafeTrait for Foo {}
//~^ ERROR implementing the trait `MySafeTrait` is not unsafe
unsafe auto trait MyUnsafeTrait {}
impl MyUnsafeTrait for Foo {}
//~^ ERROR the trait `MyUnsafeTrait` requires an `unsafe impl` declaration
fn main() {}

View File

@ -0,0 +1,16 @@
error[E0199]: implementing the trait `MySafeTrait` is not unsafe
--> $DIR/coherence-default-trait-impl.rs:18:1
|
LL | unsafe impl MySafeTrait for Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0200]: the trait `MyUnsafeTrait` requires an `unsafe impl` declaration
--> $DIR/coherence-default-trait-impl.rs:23:1
|
LL | impl MyUnsafeTrait for Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
Some errors occurred: E0199, E0200.
For more information about an error, try `rustc --explain E0199`.

View File

@ -0,0 +1,27 @@
// Copyright 2016 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(re_rebalance_coherence)]
// check that error types in coherence do not cause error cascades.
trait Foo {}
impl Foo for i8 {}
impl Foo for i16 {}
impl Foo for i32 {}
impl Foo for i64 {}
impl Foo for DoesNotExist {} //~ ERROR cannot find type `DoesNotExist` in this scope
impl Foo for u8 {}
impl Foo for u16 {}
impl Foo for u32 {}
impl Foo for u64 {}
fn main() {}

View File

@ -0,0 +1,9 @@
error[E0412]: cannot find type `DoesNotExist` in this scope
--> $DIR/coherence-error-suppression.rs:21:14
|
LL | impl Foo for DoesNotExist {} //~ ERROR cannot find type `DoesNotExist` in this scope
| ^^^^^^^^^^^^ not found in this scope
error: aborting due to previous error
For more information about this error, try `rustc --explain E0412`.

View File

@ -0,0 +1,21 @@
// 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(re_rebalance_coherence)]
// Test that we give suitable error messages when the user attempts to
// impl a trait `Trait` for its own object type.
// 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 E0038
fn main() { }

View File

@ -0,0 +1,11 @@
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:19:6
|
LL | impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038
| ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
|
= note: method `eq` references the `Self` type in its arguments or return type
error: aborting due to previous error
For more information about this error, try `rustc --explain E0038`.

View File

@ -0,0 +1,29 @@
// 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(re_rebalance_coherence)]
// Test that we give suitable error messages when the user attempts to
// impl a trait `Trait` for its own object type.
trait Foo { fn dummy(&self) { } }
trait Bar: Foo { }
trait Baz: Bar { }
// Supertraits of Baz are not legal:
impl Foo for Baz { } //~ ERROR E0371
impl Bar for Baz { } //~ ERROR E0371
impl Baz for Baz { } //~ ERROR E0371
// But other random traits are:
trait Other { }
impl Other for Baz { } // OK, Other not a supertrait of Baz
fn main() { }

View File

@ -0,0 +1,21 @@
error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo`
--> $DIR/coherence-impl-trait-for-trait.rs:21:1
|
LL | impl Foo for Baz { } //~ ERROR E0371
| ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo`
error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Bar`
--> $DIR/coherence-impl-trait-for-trait.rs:22:1
|
LL | impl Bar for Baz { } //~ ERROR E0371
| ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar`
error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Baz`
--> $DIR/coherence-impl-trait-for-trait.rs:23:1
|
LL | impl Baz for Baz { } //~ ERROR E0371
| ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0371`.

View File

@ -0,0 +1,54 @@
// 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)]
#![feature(re_rebalance_coherence)]
use std::marker::Copy;
impl Copy for i32 {}
//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `i32`:
//~| ERROR only traits defined in the current crate can be implemented for arbitrary types
enum TestE {
A
}
struct MyType;
struct NotSync;
impl !Sync for NotSync {}
impl Copy for TestE {}
impl Clone for TestE { fn clone(&self) -> Self { *self } }
impl Copy for MyType {}
impl Copy for &'static mut MyType {}
//~^ ERROR the trait `Copy` may not be implemented for this type
impl Clone for MyType { fn clone(&self) -> Self { *self } }
impl Copy for (MyType, MyType) {}
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| ERROR only traits defined in the current crate can be implemented for arbitrary types
impl Copy for &'static NotSync {}
//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&NotSync`:
impl Copy for [MyType] {}
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| ERROR only traits defined in the current crate can be implemented for arbitrary types
impl Copy for &'static [NotSync] {}
//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`:
//~| ERROR only traits defined in the current crate can be implemented for arbitrary types
fn main() {
}

View File

@ -0,0 +1,87 @@
error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `i32`:
--> $DIR/coherence-impls-copy.rs:16:1
|
LL | impl Copy for i32 {}
| ^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl std::marker::Copy for i32;
error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&NotSync`:
--> $DIR/coherence-impls-copy.rs:42:1
|
LL | impl Copy for &'static NotSync {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<T> std::marker::Copy for &T
where T: ?Sized;
error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`:
--> $DIR/coherence-impls-copy.rs:49:1
|
LL | impl Copy for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<T> std::marker::Copy for &T
where T: ?Sized;
error[E0206]: the trait `Copy` may not be implemented for this type
--> $DIR/coherence-impls-copy.rs:34:15
|
LL | impl Copy for &'static mut MyType {}
| ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration
error[E0206]: the trait `Copy` may not be implemented for this type
--> $DIR/coherence-impls-copy.rs:38:15
|
LL | impl Copy for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^ type is not a structure or enumeration
error[E0206]: the trait `Copy` may not be implemented for this type
--> $DIR/coherence-impls-copy.rs:45:15
|
LL | impl Copy for [MyType] {}
| ^^^^^^^^ type is not a structure or enumeration
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-copy.rs:16:1
|
LL | impl Copy for i32 {}
| ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-copy.rs:38:1
|
LL | impl Copy for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-copy.rs:45:1
|
LL | impl Copy for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-copy.rs:49:1
|
LL | impl Copy for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error: aborting due to 10 previous errors
Some errors occurred: E0117, E0119, E0206.
For more information about an error, try `rustc --explain E0117`.

View File

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

View File

@ -0,0 +1,37 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-send.rs:28:1
|
LL | unsafe impl Send for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `&'static NotSync`
--> $DIR/coherence-impls-send.rs:31:1
|
LL | unsafe impl Send for &'static NotSync {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-send.rs:34:1
|
LL | unsafe impl Send for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-send.rs:37:1
|
LL | unsafe impl Send for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error: aborting due to 4 previous errors
Some errors occurred: E0117, E0321.
For more information about an error, try `rustc --explain E0117`.

View File

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

View File

@ -0,0 +1,67 @@
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:25:1
|
LL | impl Sized for TestE {} //~ ERROR E0322
| ^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:28:1
|
LL | impl Sized for MyType {} //~ ERROR E0322
| ^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:31:1
|
LL | impl Sized for (MyType, MyType) {} //~ ERROR E0322
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:35:1
|
LL | impl Sized for &'static NotSync {} //~ ERROR E0322
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:38:1
|
LL | impl Sized for [MyType] {} //~ ERROR E0322
| ^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:42:1
|
LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-sized.rs:31:1
|
LL | impl Sized for (MyType, MyType) {} //~ ERROR E0322
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-sized.rs:38:1
|
LL | impl Sized for [MyType] {} //~ ERROR E0322
| ^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-sized.rs:42:1
|
LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error: aborting due to 9 previous errors
Some errors occurred: E0117, E0322.
For more information about an error, try `rustc --explain E0117`.

View File

@ -0,0 +1,35 @@
// 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.
// Formerly this ICEd with the following message:
// Tried to project an inherited associated type during coherence checking,
// which is currently not supported.
//
// No we expect to run into a more user-friendly cycle error instead.
#![feature(specialization)]
#![feature(re_rebalance_coherence)]
trait Trait<T> { type Assoc; }
//~^ cycle detected
impl<T> Trait<T> for Vec<T> {
type Assoc = ();
}
impl Trait<u8> for Vec<u8> {}
impl<T> Trait<T> for String {
type Assoc = ();
}
impl Trait<<Vec<u8> as Trait<u8>>::Assoc> for String {}
fn main() {}

View File

@ -0,0 +1,16 @@
error[E0391]: cycle detected when processing `Trait`
--> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:20:1
|
LL | trait Trait<T> { type Assoc; }
| ^^^^^^^^^^^^^^
|
= note: ...which again requires processing `Trait`, completing the cycle
note: cycle used when coherence checking all impls of trait `Trait`
--> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:20:1
|
LL | trait Trait<T> { type Assoc; }
| ^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0391`.

View File

@ -0,0 +1,21 @@
// 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(re_rebalance_coherence)]
// aux-build:coherence_lib.rs
extern crate coherence_lib as lib;
use lib::Remote;
impl<T> Remote for T { }
//~^ ERROR type parameter `T` must be used as the type parameter for some local type
fn main() { }

View File

@ -0,0 +1,11 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct<T>`)
--> $DIR/coherence-lone-type-parameter.rs:18:1
|
LL | impl<T> Remote for T { }
| ^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter
error: aborting due to previous error
For more information about this error, try `rustc --explain E0210`.

View File

@ -0,0 +1,21 @@
// 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)]
#![feature(re_rebalance_coherence)]
use std::marker::Send;
struct TestType;
unsafe impl !Send for TestType {}
//~^ ERROR negative impls cannot be unsafe
fn main() {}

View File

@ -0,0 +1,9 @@
error[E0198]: negative impls cannot be unsafe
--> $DIR/coherence-negative-impls-safe.rs:18:1
|
LL | unsafe impl !Send for TestType {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0198`.

View File

@ -0,0 +1,20 @@
// 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(re_rebalance_coherence)]
// Test that you cannot *directly* dispatch on lifetime requirements
trait MyTrait { fn foo() {} }
impl<T> MyTrait for T {}
impl<T: 'static> MyTrait for T {} //~ ERROR E0119
fn main() {}

View File

@ -0,0 +1,11 @@
error[E0119]: conflicting implementations of trait `MyTrait`:
--> $DIR/coherence-no-direct-lifetime-dispatch.rs:18:1
|
LL | impl<T> MyTrait for T {}
| --------------------- first implementation here
LL | impl<T: 'static> MyTrait for T {} //~ ERROR E0119
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View File

@ -0,0 +1,32 @@
// 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.
// aux-build:coherence_orphan_lib.rs
#![feature(optin_builtin_traits)]
#![feature(re_rebalance_coherence)]
extern crate coherence_orphan_lib as lib;
use lib::TheTrait;
struct TheType;
impl TheTrait<usize> for isize { }
//~^ ERROR E0117
impl TheTrait<TheType> for isize { }
impl TheTrait<isize> for TheType { }
impl !Send for Vec<isize> { }
//~^ ERROR E0117
fn main() { }

View File

@ -0,0 +1,21 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-orphan.rs:22:1
|
LL | impl TheTrait<usize> for isize { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-orphan.rs:29:1
|
LL | impl !Send for Vec<isize> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0117`.

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(re_rebalance_coherence)]
// Check that we detect an overlap here in the case where:
//
// for some type X:
// T = (X,)
// T11 = X, U11 = X
//
// Seems pretty basic, but then there was issue #24241. :)
trait From<U> {
fn foo() {}
}
impl <T> From<T> for T {
}
impl <T11, U11> From<(U11,)> for (T11,) { //~ ERROR E0119
}
fn main() { }

View File

@ -0,0 +1,12 @@
error[E0119]: conflicting implementations of trait `From<(_,)>` for type `(_,)`:
--> $DIR/coherence-overlap-all-t-and-tuple.rs:28:1
|
LL | impl <T> From<T> for T {
| ---------------------- first implementation here
...
LL | impl <T11, U11> From<(U11,)> for (T11,) { //~ ERROR E0119
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_,)`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View File

@ -0,0 +1,29 @@
// 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(re_rebalance_coherence)]
// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even
// though no impls are found.
struct Sweet<X>(X);
pub trait Sugar {}
pub trait Fruit {}
impl<T:Sugar> Sweet<T> { fn dummy(&self) { } }
//~^ ERROR E0592
impl<T:Fruit> Sweet<T> { fn dummy(&self) { } }
trait Bar<X> {}
struct A<T, X>(T, X);
impl<X, T> A<T, X> where T: Bar<X> { fn f(&self) {} }
//~^ ERROR E0592
impl<X> A<i32, X> { fn f(&self) {} }
fn main() {}

View File

@ -0,0 +1,23 @@
error[E0592]: duplicate definitions with name `dummy`
--> $DIR/coherence-overlap-downstream-inherent.rs:19:26
|
LL | impl<T:Sugar> Sweet<T> { fn dummy(&self) { } }
| ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
LL | //~^ ERROR E0592
LL | impl<T:Fruit> Sweet<T> { fn dummy(&self) { } }
| ------------------- other definition for `dummy`
error[E0592]: duplicate definitions with name `f`
--> $DIR/coherence-overlap-downstream-inherent.rs:25:38
|
LL | impl<X, T> A<T, X> where T: Bar<X> { fn f(&self) {} }
| ^^^^^^^^^^^^^^ duplicate definitions for `f`
LL | //~^ ERROR E0592
LL | impl<X> A<i32, X> { fn f(&self) {} }
| -------------- other definition for `f`
|
= note: downstream crates may implement trait `Bar<_>` for type `i32`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0592`.

View File

@ -0,0 +1,29 @@
// 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(re_rebalance_coherence)]
// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even
// though no impls are found.
pub trait Sugar {}
pub trait Fruit {}
pub trait Sweet {}
impl<T:Sugar> Sweet for T { }
impl<T:Fruit> Sweet for T { }
//~^ ERROR E0119
pub trait Foo<X> {}
pub trait Bar<X> {}
impl<X, T> Foo<X> for T where T: Bar<X> {}
impl<X> Foo<X> for i32 {}
//~^ ERROR E0119
fn main() { }

View File

@ -0,0 +1,21 @@
error[E0119]: conflicting implementations of trait `Sweet`:
--> $DIR/coherence-overlap-downstream.rs:20:1
|
LL | impl<T:Sugar> Sweet for T { }
| ------------------------- first implementation here
LL | impl<T:Fruit> Sweet for T { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
error[E0119]: conflicting implementations of trait `Foo<_>` for type `i32`:
--> $DIR/coherence-overlap-downstream.rs:26:1
|
LL | impl<X, T> Foo<X> for T where T: Bar<X> {}
| --------------------------------------- first implementation here
LL | impl<X> Foo<X> for i32 {}
| ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32`
|
= note: downstream crates may implement trait `Bar<_>` for type `i32`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0119`.

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.
#![feature(re_rebalance_coherence)]
// Tests that we consider `Box<U>: !Sugar` to be ambiguous, even
// though we see no impl of `Sugar` for `Box`. Therefore, an overlap
// error is reported for the following pair of impls (#23516).
pub trait Sugar {}
struct Cake<X>(X);
impl<T:Sugar> Cake<T> { fn dummy(&self) { } }
//~^ ERROR E0592
impl<U:Sugar> Cake<Box<U>> { fn dummy(&self) { } }
fn main() { }

View File

@ -0,0 +1,14 @@
error[E0592]: duplicate definitions with name `dummy`
--> $DIR/coherence-overlap-issue-23516-inherent.rs:21:25
|
LL | impl<T:Sugar> Cake<T> { fn dummy(&self) { } }
| ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
LL | //~^ ERROR E0592
LL | impl<U:Sugar> Cake<Box<U>> { fn dummy(&self) { } }
| ------------------- other definition for `dummy`
|
= note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0592`.

View File

@ -0,0 +1,23 @@
// 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(re_rebalance_coherence)]
// Tests that we consider `Box<U>: !Sugar` to be ambiguous, even
// though we see no impl of `Sugar` for `Box`. Therefore, an overlap
// error is reported for the following pair of impls (#23516).
pub trait Sugar { fn dummy(&self) { } }
pub trait Sweet { fn dummy(&self) { } }
impl<T:Sugar> Sweet for T { }
impl<U:Sugar> Sweet for Box<U> { }
//~^ ERROR E0119
fn main() { }

View File

@ -0,0 +1,13 @@
error[E0119]: conflicting implementations of trait `Sweet` for type `std::boxed::Box<_>`:
--> $DIR/coherence-overlap-issue-23516.rs:20:1
|
LL | impl<T:Sugar> Sweet for T { }
| ------------------------- first implementation here
LL | impl<U:Sugar> Sweet for Box<U> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::boxed::Box<_>`
|
= note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View File

@ -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.
#![feature(re_rebalance_coherence)]
trait Foo { fn foo() {} }
impl<T> Foo for T {}
impl<U> Foo for U {} //~ ERROR conflicting implementations of trait `Foo`:
trait Bar { fn bar() {} }
impl<T> Bar for (T, u8) {}
impl<T> Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`:
trait Baz<T> { fn baz() {} }
impl<T> Baz<u8> for T {}
impl<T> Baz<T> for u8 {} //~ ERROR conflicting implementations of trait `Baz<u8>` for type `u8`:
trait Quux<U, V> { fn quux() {} }
impl<T, U, V> Quux<U, V> for T {}
impl<T, U> Quux<U, U> for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`:
impl<T, V> Quux<T, V> for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`:
fn main() {}

View File

@ -0,0 +1,44 @@
error[E0119]: conflicting implementations of trait `Foo`:
--> $DIR/coherence-overlap-messages.rs:16:1
|
LL | impl<T> Foo for T {}
| ----------------- first implementation here
LL | impl<U> Foo for U {} //~ ERROR conflicting implementations of trait `Foo`:
| ^^^^^^^^^^^^^^^^^ conflicting implementation
error[E0119]: conflicting implementations of trait `Bar` for type `(u8, u8)`:
--> $DIR/coherence-overlap-messages.rs:21:1
|
LL | impl<T> Bar for (T, u8) {}
| ----------------------- first implementation here
LL | impl<T> Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`:
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(u8, u8)`
error[E0119]: conflicting implementations of trait `Baz<u8>` for type `u8`:
--> $DIR/coherence-overlap-messages.rs:26:1
|
LL | impl<T> Baz<u8> for T {}
| --------------------- first implementation here
LL | impl<T> Baz<T> for u8 {} //~ ERROR conflicting implementations of trait `Baz<u8>` for type `u8`:
| ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8`
error[E0119]: conflicting implementations of trait `Quux<_, _>`:
--> $DIR/coherence-overlap-messages.rs:31:1
|
LL | impl<T, U, V> Quux<U, V> for T {}
| ------------------------------ first implementation here
LL | impl<T, U> Quux<U, U> for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`:
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
error[E0119]: conflicting implementations of trait `Quux<_, _>`:
--> $DIR/coherence-overlap-messages.rs:32:1
|
LL | impl<T, U, V> Quux<U, V> for T {}
| ------------------------------ first implementation here
LL | impl<T, U> Quux<U, U> for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`:
LL | impl<T, V> Quux<T, V> for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`:
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0119`.

View File

@ -0,0 +1,27 @@
// 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(re_rebalance_coherence)]
// Tests that we consider `i16: Remote` to be ambiguous, even
// though the upstream crate doesn't implement it for now.
// aux-build:coherence_lib.rs
extern crate coherence_lib;
use coherence_lib::Remote;
struct A<X>(X);
impl<T> A<T> where T: Remote { fn dummy(&self) { } }
//~^ ERROR E0592
impl A<i16> { fn dummy(&self) { } }
fn main() {}

View File

@ -0,0 +1,14 @@
error[E0592]: duplicate definitions with name `dummy`
--> $DIR/coherence-overlap-upstream-inherent.rs:23:32
|
LL | impl<T> A<T> where T: Remote { fn dummy(&self) { } }
| ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
LL | //~^ ERROR E0592
LL | impl A<i16> { fn dummy(&self) { } }
| ------------------- other definition for `dummy`
|
= note: upstream crates may add new impl of trait `coherence_lib::Remote` for type `i16` in future versions
error: aborting due to previous error
For more information about this error, try `rustc --explain E0592`.

View File

@ -0,0 +1,27 @@
// 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(re_rebalance_coherence)]
// Tests that we consider `i16: Remote` to be ambiguous, even
// though the upstream crate doesn't implement it for now.
// aux-build:coherence_lib.rs
extern crate coherence_lib;
use coherence_lib::Remote;
trait Foo {}
impl<T> Foo for T where T: Remote {}
impl Foo for i16 {}
//~^ ERROR E0119
fn main() {}

View File

@ -0,0 +1,13 @@
error[E0119]: conflicting implementations of trait `Foo` for type `i16`:
--> $DIR/coherence-overlap-upstream.rs:24:1
|
LL | impl<T> Foo for T where T: Remote {}
| --------------------------------- first implementation here
LL | impl Foo for i16 {}
| ^^^^^^^^^^^^^^^^ conflicting implementation for `i16`
|
= note: upstream crates may add new impl of trait `coherence_lib::Remote` for type `i16` in future versions
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View File

@ -0,0 +1,23 @@
// 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(re_rebalance_coherence)]
// aux-build:coherence_lib.rs
extern crate coherence_lib as lib;
use lib::Remote;
struct Foo;
impl<T> Remote for lib::Pair<T,Foo> { }
//~^ ERROR E0117
fn main() { }

View File

@ -0,0 +1,12 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-overlapping-pairs.rs:20:1
|
LL | impl<T> Remote for lib::Pair<T,Foo> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error: aborting due to previous error
For more information about this error, try `rustc --explain E0117`.

View File

@ -0,0 +1,25 @@
// 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(re_rebalance_coherence)]
// Test that the same coverage rules apply even if the local type appears in the
// list of type parameters, not the self type.
// aux-build:coherence_lib.rs
extern crate coherence_lib as lib;
use lib::{Remote1, Pair};
pub struct Local<T>(T);
impl<T, U> Remote1<Pair<T, Local<U>>> for i32 { }
fn main() { }

View File

@ -0,0 +1,12 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-pair-covered-uncovered-1.rs:23:1
|
LL | impl<T, U> Remote1<Pair<T, Local<U>>> for i32 { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error: aborting due to previous error
For more information about this error, try `rustc --explain E0117`.

View File

@ -0,0 +1,23 @@
// 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(re_rebalance_coherence)]
// aux-build:coherence_lib.rs
extern crate coherence_lib as lib;
use lib::{Remote, Pair};
struct Local<T>(T);
impl<T,U> Remote for Pair<T,Local<U>> { }
//~^ ERROR E0117
fn main() { }

View File

@ -0,0 +1,12 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-pair-covered-uncovered.rs:20:1
|
LL | impl<T,U> Remote for Pair<T,Local<U>> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error: aborting due to previous error
For more information about this error, try `rustc --explain E0117`.

View File

@ -0,0 +1,29 @@
// Copyright 2016 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(rustc_attrs)]
#![feature(re_rebalance_coherence)]
// Here we expect a coherence conflict because, even though `i32` does
// not implement `Iterator`, we cannot rely on that negative reasoning
// due to the orphan rules. Therefore, `A::Item` may yet turn out to
// be `i32`.
pub trait Foo<P> { fn foo() {} }
pub trait Bar {
type Output: 'static;
}
impl Foo<i32> for i32 { }
impl<A:Iterator> Foo<A::Item> for A { } //~ ERROR E0119
fn main() {}

View File

@ -0,0 +1,14 @@
error[E0119]: conflicting implementations of trait `Foo<i32>` for type `i32`:
--> $DIR/coherence-projection-conflict-orphan.rs:27:1
|
LL | impl Foo<i32> for i32 { }
| --------------------- first implementation here
LL |
LL | impl<A:Iterator> Foo<A::Item> for A { } //~ ERROR E0119
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32`
|
= note: upstream crates may add new impl of trait `std::iter::Iterator` for type `i32` in future versions
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View File

@ -0,0 +1,24 @@
// Copyright 2016 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(re_rebalance_coherence)]
// Coherence error results because we do not know whether `T: Foo<P>` or not
// for the second impl.
use std::marker::PhantomData;
pub trait Foo<P> { fn foo() {} }
impl <P, T: Foo<P>> Foo<P> for Option<T> {}
impl<T, U> Foo<T> for Option<U> { } //~ ERROR E0119
fn main() {}

View File

@ -0,0 +1,12 @@
error[E0119]: conflicting implementations of trait `Foo<_>` for type `std::option::Option<_>`:
--> $DIR/coherence-projection-conflict-ty-param.rs:22:1
|
LL | impl <P, T: Foo<P>> Foo<P> for Option<T> {}
| ---------------------------------------- first implementation here
LL |
LL | impl<T, U> Foo<T> for Option<U> { } //~ ERROR E0119
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::option::Option<_>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

Some files were not shown because too many files have changed in this diff Show More