Auto merge of #56145 - weiznich:re_rebalance_coherence, r=nikomatsakis

Implement the Re-rebalance coherence RFC

This is the first time I touch anything in the compiler so just tell me if I got something wrong.

Big thanks to @sgrif for the pointers where to look for those things.
cc #55437
This commit is contained in:
bors 2019-01-05 00:49:12 +00:00
commit 244b05db12
179 changed files with 1652 additions and 271 deletions

View file

@ -0,0 +1,23 @@
# `re_rebalance_coherence`
The tracking issue for this feature is: [#55437]
[#55437]: https://github.com/rust-lang/rust/issues/55437
------------------------
The `re_rebalance_coherence` feature tweaks the rules regarding which trait
impls are allowed in crates.
The following rule is used:
Given `impl<P1..=Pn> Trait<T1..=Tn> for T0`, an impl is valid only if at
least one of the following is true:
- `Trait` is a local trait
- All of
- At least one of the types `T0..=Tn` must be a local type. Let `Ti` be the
first such type.
- No uncovered type parameters `P1..=Pn` may appear in `T0..Ti` (excluding
`Ti`)
See the [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2451-re-rebalancing-coherence.md) for details.

View file

@ -371,43 +371,68 @@ fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_, '_>,
trait_ref);
}
// First, create an ordered iterator over all the type parameters to the trait, with the self
// type appearing first.
// Find the first input type that either references a type parameter OR
// some local type.
for input_ty in trait_ref.input_types() {
if ty_is_local(tcx, input_ty, in_crate) {
debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty);
if tcx.features().re_rebalance_coherence {
// Given impl<P1..=Pn> Trait<T1..=Tn> for T0, an impl is valid only
// if at least one of the following is true:
//
// - Trait is a local trait
// (already checked in orphan_check prior to calling this function)
// - All of
// - At least one of the types T0..=Tn must be a local type.
// Let Ti be the first such type.
// - No uncovered type parameters P1..=Pn may appear in T0..Ti (excluding Ti)
//
for input_ty in trait_ref.input_types() {
debug!("orphan_check_trait_ref: check ty `{:?}`", input_ty);
if ty_is_local(tcx, input_ty, in_crate) {
debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty);
return Ok(());
} else if let ty::Param(_) = input_ty.sty {
debug!("orphan_check_trait_ref: uncovered ty: `{:?}`", input_ty);
return Err(OrphanCheckErr::UncoveredTy(input_ty))
}
}
// If we exit above loop, never found a local type.
debug!("orphan_check_trait_ref: no local type");
Err(OrphanCheckErr::NoLocalInputType)
} else {
// First, create an ordered iterator over all the type
// parameters to the trait, with the self type appearing
// first. Find the first input type that either references a
// type parameter OR some local type.
for input_ty in trait_ref.input_types() {
if ty_is_local(tcx, input_ty, in_crate) {
debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty);
// First local input type. Check that there are no
// uncovered type parameters.
let uncovered_tys = uncovered_tys(tcx, input_ty, in_crate);
for uncovered_ty in uncovered_tys {
if let Some(param) = uncovered_ty.walk()
.find(|t| is_possibly_remote_type(t, in_crate))
{
debug!("orphan_check_trait_ref: uncovered type `{:?}`", param);
return Err(OrphanCheckErr::UncoveredTy(param));
// First local input type. Check that there are no
// uncovered type parameters.
let uncovered_tys = uncovered_tys(tcx, input_ty, in_crate);
for uncovered_ty in uncovered_tys {
if let Some(param) = uncovered_ty.walk()
.find(|t| is_possibly_remote_type(t, in_crate))
{
debug!("orphan_check_trait_ref: uncovered type `{:?}`", param);
return Err(OrphanCheckErr::UncoveredTy(param));
}
}
// OK, found local type, all prior types upheld invariant.
return Ok(());
}
// OK, found local type, all prior types upheld invariant.
return Ok(());
}
// Otherwise, enforce invariant that there are no type
// parameters reachable.
if let Some(param) = input_ty.walk()
.find(|t| is_possibly_remote_type(t, in_crate))
{
debug!("orphan_check_trait_ref: uncovered type `{:?}`", param);
return Err(OrphanCheckErr::UncoveredTy(param));
// Otherwise, enforce invariant that there are no type
// parameters reachable.
if let Some(param) = input_ty.walk()
.find(|t| is_possibly_remote_type(t, in_crate))
{
debug!("orphan_check_trait_ref: uncovered type `{:?}`", param);
return Err(OrphanCheckErr::UncoveredTy(param));
}
}
// If we exit above loop, never found a local type.
debug!("orphan_check_trait_ref: no local type");
Err(OrphanCheckErr::NoLocalInputType)
}
// If we exit above loop, never found a local type.
debug!("orphan_check_trait_ref: no local type");
return Err(OrphanCheckErr::NoLocalInputType);
}
fn uncovered_tys<'tcx>(tcx: TyCtxt<'_, '_, '_>, ty: Ty<'tcx>, in_crate: InCrate)

View file

@ -479,6 +479,9 @@ declare_features! (
// Allows paths to enum variants on type aliases.
(active, type_alias_enum_variants, "1.31.0", Some(49683), None),
// Re-Rebalance coherence
(active, re_rebalance_coherence, "1.32.0", Some(55437), None),
);
declare_features! (

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

@ -1,5 +1,8 @@
// run-pass
// aux-build:coherence_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
// pretty-expanded FIXME #23616

View file

@ -1,5 +1,8 @@
// run-pass
// aux-build:coherence_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
// pretty-expanded FIXME #23616

View file

@ -1,6 +1,9 @@
// run-pass
#![allow(unused_imports)]
// aux-build:coherence_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
// pretty-expanded FIXME #23616

View file

@ -1,6 +1,9 @@
// run-pass
#![allow(dead_code)]
// aux-build:coherence_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
// pretty-expanded FIXME #23616

View file

@ -1,4 +1,7 @@
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]
#![allow(non_camel_case_types)]

View file

@ -1,4 +1,7 @@
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]
// aux-build:coherence_lib.rs

View file

@ -1,4 +1,7 @@
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]
// aux-build:coherence_lib.rs

View file

@ -1,4 +1,7 @@
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(unused_imports)]
// pretty-expanded FIXME #23616

View file

@ -1,4 +1,7 @@
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]
// pretty-expanded FIXME #23616

View file

@ -1,4 +1,7 @@
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
// check that trait matching can handle impls whose types are only
// constrained by a projection.

View file

@ -1,4 +1,8 @@
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
use std::fmt::Debug;
use std::default::Default;

View file

@ -1,4 +1,7 @@
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]
// Test that we are able to introduce a negative constraint that
// `MyType: !MyTrait` along with other "fundamental" wrappers.

View file

@ -0,0 +1,14 @@
#![allow(dead_code)]
#![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

@ -1,5 +1,5 @@
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:6:1
--> $DIR/coherence-all-remote.rs:9:1
|
LL | impl<T> Remote1<T> for isize { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type

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:9: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

@ -1,9 +1,13 @@
// aux-build:coherence_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
extern crate coherence_lib as lib;
use lib::Remote1;
impl<T> Remote1<T> for isize { }
//~^ ERROR E0210
//[old]~^ ERROR E0210
//[re]~^^ ERROR E0210
fn main() { }

View file

@ -1,5 +1,5 @@
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:8:1
--> $DIR/coherence-bigint-param.rs:11:1
|
LL | impl<T> Remote1<BigInt> for T { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type

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:11: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

@ -1,4 +1,7 @@
// aux-build:coherence_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
extern crate coherence_lib as lib;
use lib::Remote1;
@ -6,6 +9,7 @@ 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
//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type
//[re]~^^ ERROR E0210
fn main() { }

View file

@ -1,10 +1,10 @@
error[E0119]: conflicting implementations of trait `MyTrait`:
--> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:24:1
--> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:28:1
|
LL | impl<T:Even> MyTrait for T {
| -------------------------- first implementation here
...
LL | impl<T:Odd> MyTrait for T { //~ ERROR E0119
LL | impl<T:Odd> MyTrait for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
error: aborting due to previous error

View file

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

View file

@ -1,3 +1,7 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
use std::fmt::Debug;
use std::default::Default;
@ -21,7 +25,10 @@ impl<T:Even> MyTrait for T {
fn get(&self) -> usize { 0 }
}
impl<T:Odd> MyTrait for T { //~ ERROR E0119
impl<T:Odd> MyTrait for T {
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
fn get(&self) -> usize { 0 }
}

View file

@ -1,10 +1,10 @@
error[E0119]: conflicting implementations of trait `MyTrait`:
--> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:20:1
--> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:24:1
|
LL | impl<T:Even> MyTrait for T {
| -------------------------- first implementation here
...
LL | impl<T:Odd> MyTrait for T { //~ ERROR E0119
LL | impl<T:Odd> MyTrait for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
error: aborting due to previous error

View file

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

View file

@ -1,3 +1,7 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
use std::fmt::Debug;
use std::default::Default;
@ -17,7 +21,9 @@ impl<T:Even> MyTrait for T {
fn get(&self) -> usize { 0 }
}
impl<T:Odd> MyTrait for T { //~ ERROR E0119
impl<T:Odd> MyTrait for T {
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
fn get(&self) -> usize { 0 }
}

View file

@ -1,7 +1,7 @@
error[E0119]: conflicting implementations of trait `go_trait::GoMut` for type `MyThingy`:
--> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:15:1
--> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:18:1
|
LL | impl GoMut for MyThingy { //~ ERROR conflicting implementations
LL | impl GoMut for MyThingy {
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `go_trait`:

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:18:1
|
LL | impl GoMut for MyThingy {
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= 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

@ -1,4 +1,7 @@
// aux-build:go_trait.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
extern crate go_trait;
@ -12,7 +15,9 @@ impl Go for MyThingy {
fn go(&self, arg: isize) { }
}
impl GoMut for MyThingy { //~ ERROR conflicting implementations
impl GoMut for MyThingy {
//[old]~^ ERROR conflicting implementations
//[re]~^^ ERROR E0119
fn go_mut(&mut self, arg: isize) { }
}

View file

@ -1,10 +1,10 @@
error[E0119]: conflicting implementations of trait `MyTrait<MyType>` for type `MyType`:
--> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:22:1
--> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:26:1
|
LL | impl<T> MyTrait<T> for T {
| ------------------------ first implementation here
...
LL | impl MyTrait<MyType> for MyType { //~ ERROR E0119
LL | impl MyTrait<MyType> for MyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType`
error: aborting due to previous error

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:26:1
|
LL | impl<T> MyTrait<T> for T {
| ------------------------ first implementation here
...
LL | impl MyTrait<MyType> for MyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View file

@ -1,3 +1,7 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
use std::fmt::Debug;
use std::default::Default;
@ -19,7 +23,9 @@ struct MyType {
dummy: usize
}
impl MyTrait<MyType> for MyType { //~ ERROR E0119
impl MyTrait<MyType> for MyType {
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
fn get(&self) -> usize { (*self).clone() }
}

View file

@ -1,10 +1,10 @@
error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`:
--> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:20:1
--> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:24:1
|
LL | impl<T:OtherTrait> MyTrait for T {
| -------------------------------- first implementation here
...
LL | impl MyTrait for MyType { //~ ERROR E0119
LL | impl MyTrait for MyType {
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType`
error: aborting due to previous error

View file

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

View file

@ -1,6 +1,10 @@
// Test that a blank impl for all T:PartialEq conflicts with an impl for some
// specific T when T:PartialEq.
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
trait OtherTrait {
fn noop(&self);
}
@ -17,7 +21,9 @@ struct MyType {
dummy: usize
}
impl MyTrait for MyType { //~ ERROR E0119
impl MyTrait for MyType {
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
fn get(&self) -> usize { self.dummy }
}

View file

@ -1,10 +1,10 @@
error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`:
--> $DIR/coherence-blanket-conflicts-with-specific.rs:19:1
--> $DIR/coherence-blanket-conflicts-with-specific.rs:23:1
|
LL | impl<T> MyTrait for T {
| --------------------- first implementation here
...
LL | impl MyTrait for MyType { //~ ERROR E0119
LL | impl MyTrait for MyType {
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType`
error: aborting due to previous error

View file

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

View file

@ -1,3 +1,7 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
use std::fmt::Debug;
use std::default::Default;
@ -16,7 +20,9 @@ struct MyType {
dummy: usize
}
impl MyTrait for MyType { //~ ERROR E0119
impl MyTrait for MyType {
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
fn get(&self) -> usize { self.dummy }
}

View file

@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType<_>`:
--> $DIR/coherence-conflicting-negative-trait-impl.rs:10:1
--> $DIR/coherence-conflicting-negative-trait-impl.rs:13:1
|
LL | unsafe impl<T: MyTrait+'static> Send for TestType<T> {}
| ---------------------------------------------------- first implementation here
@ -8,7 +8,7 @@ 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:15:1
--> $DIR/coherence-conflicting-negative-trait-impl.rs:19:1
|
LL | unsafe impl<T:'static> Send for TestType<T> {}
| ------------------------------------------- first implementation here

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:13: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:19: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

@ -1,3 +1,6 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(optin_builtin_traits)]
#![feature(overlapping_marker_traits)]
@ -8,11 +11,13 @@ 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`
//[old]~^ ERROR conflicting implementations of trait `std::marker::Send`
//[re]~^^ ERROR E0119
unsafe impl<T:'static> Send for TestType<T> {}
impl !Send for TestType<i32> {}
//~^ ERROR conflicting implementations of trait `std::marker::Send`
//[old]~^ ERROR conflicting implementations of trait `std::marker::Send`
//[re]~^^ ERROR E0119
fn main() {}

View file

@ -1,7 +1,7 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/coherence-cow.rs:16:1
--> $DIR/coherence-cow.rs:18:1
|
LL | impl<T> Remote for Pair<T,Cover<T>> { } //[a]~ ERROR E0210
LL | impl<T> Remote for Pair<T,Cover<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

View file

@ -1,7 +1,7 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/coherence-cow.rs:19:1
--> $DIR/coherence-cow.rs:23:1
|
LL | impl<T> Remote for Pair<Cover<T>,T> { } //[b]~ ERROR E0210
LL | impl<T> Remote for Pair<Cover<T>,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

View file

@ -1,5 +1,5 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/coherence-cow.rs:22:1
--> $DIR/coherence-cow.rs:28:1
|
LL | impl<T,U> Remote for Pair<Cover<T>,U> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type

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:18:1
|
LL | impl<T> Remote for Pair<T,Cover<T>> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:23:1
|
LL | impl<T> Remote for Pair<Cover<T>,T> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:28: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

@ -1,4 +1,6 @@
// revisions: a b c
// revisions: a b c re_a re_b re_c
#![cfg_attr(any(re_a, re_b, re_c), feature(re_rebalance_coherence))]
// aux-build:coherence_lib.rs
@ -12,14 +14,19 @@ use lib::{Remote,Pair};
pub struct Cover<T>(T);
#[cfg(a)]
impl<T> Remote for Pair<T,Cover<T>> { } //[a]~ ERROR E0210
#[cfg(any(a, re_a))]
impl<T> Remote for Pair<T,Cover<T>> { }
//[a]~^ ERROR E0210
//[re_a]~^^ ERROR E0117
#[cfg(b)]
impl<T> Remote for Pair<Cover<T>,T> { } //[b]~ ERROR E0210
#[cfg(any(b, re_b))]
impl<T> Remote for Pair<Cover<T>,T> { }
//[b]~^ ERROR E0210
//[re_b]~^^ ERROR E0117
#[cfg(c)]
#[cfg(any(c, re_c))]
impl<T,U> Remote for Pair<Cover<T>,U> { }
//[c]~^ ERROR type parameter `T` must be used as the type parameter for some local type
//[re_c]~^^ ERROR E0117
fn main() { }

View file

@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize`:
--> $DIR/coherence-cross-crate-conflict.rs:8:1
--> $DIR/coherence-cross-crate-conflict.rs:12:1
|
LL | impl<A> Foo for A {
| ^^^^^^^^^^^^^^^^^
@ -8,7 +8,7 @@ LL | impl<A> Foo for A {
- 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:8:1
--> $DIR/coherence-cross-crate-conflict.rs:12:1
|
LL | impl<A> Foo for A {
| ^^^^^^^^^^^^^^^^^ type parameter `A` must be used as the type parameter for some local type

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:12: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:12: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

@ -2,12 +2,18 @@
// generalizes the one upstream
// aux-build:trait_impl_conflict.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
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`
//[old]~^ ERROR type parameter `A` must be used as the type parameter for some local type
//[old]~| ERROR conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize`
//[re]~^^^ ERROR E0119
//[re]~| ERROR E0210
}
fn main() {

View file

@ -1,11 +1,11 @@
error[E0199]: implementing the trait `MySafeTrait` is not unsafe
--> $DIR/coherence-default-trait-impl.rs:7:1
--> $DIR/coherence-default-trait-impl.rs:10:1
|
LL | unsafe impl MySafeTrait for Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0200]: the trait `MyUnsafeTrait` requires an `unsafe impl` declaration
--> $DIR/coherence-default-trait-impl.rs:12:1
--> $DIR/coherence-default-trait-impl.rs:16:1
|
LL | impl MyUnsafeTrait for Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -0,0 +1,16 @@
error[E0199]: implementing the trait `MySafeTrait` is not unsafe
--> $DIR/coherence-default-trait-impl.rs:10:1
|
LL | unsafe impl MySafeTrait for Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0200]: the trait `MyUnsafeTrait` requires an `unsafe impl` declaration
--> $DIR/coherence-default-trait-impl.rs:16: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

@ -1,3 +1,6 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(optin_builtin_traits)]
auto trait MySafeTrait {}
@ -5,11 +8,13 @@ auto trait MySafeTrait {}
struct Foo;
unsafe impl MySafeTrait for Foo {}
//~^ ERROR implementing the trait `MySafeTrait` is not unsafe
//[old]~^ ERROR implementing the trait `MySafeTrait` is not unsafe
//[re]~^^ ERROR E0199
unsafe auto trait MyUnsafeTrait {}
impl MyUnsafeTrait for Foo {}
//~^ ERROR the trait `MyUnsafeTrait` requires an `unsafe impl` declaration
//[old]~^ ERROR the trait `MyUnsafeTrait` requires an `unsafe impl` declaration
//[re]~^^ ERROR E0200
fn main() {}

View file

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

View file

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

View file

@ -1,12 +1,18 @@
// check that error types in coherence do not cause error cascades.
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
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 DoesNotExist {}
//[old]~^ ERROR cannot find type `DoesNotExist` in this scope
//[re]~^^ ERROR E0412
impl Foo for u8 {}
impl Foo for u16 {}
impl Foo for u32 {}

View file

@ -1,5 +1,5 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-fundamental-trait-objects.rs:12:1
--> $DIR/coherence-fundamental-trait-objects.rs:15:1
|
LL | impl Misc for dyn Fundamental<Local> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate

View file

@ -0,0 +1,12 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-fundamental-trait-objects.rs:15:1
|
LL | impl Misc for dyn Fundamental<Local> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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

@ -3,6 +3,9 @@
// are distinct.
// aux-build:coherence_fundamental_trait_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
extern crate coherence_fundamental_trait_lib;
@ -10,6 +13,7 @@ use coherence_fundamental_trait_lib::{Fundamental, Misc};
pub struct Local;
impl Misc for dyn Fundamental<Local> {}
//~^ ERROR E0117
//[old]~^ ERROR E0117
//[re]~^^ ERROR E0117
fn main() {}

View file

@ -1,7 +1,7 @@
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:7:6
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6
|
LL | impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038
LL | impl NotObjectSafe for NotObjectSafe { }
| ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
|
= note: method `eq` references the `Self` type in its arguments or return type

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:11:6
|
LL | impl NotObjectSafe for NotObjectSafe { }
| ^^^^^^^^^^^^^ 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

@ -1,9 +1,15 @@
// Test that we give suitable error messages when the user attempts to
// impl a trait `Trait` for its own object type.
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
// 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
impl NotObjectSafe for NotObjectSafe { }
//[old]~^ ERROR E0038
//[re]~^^ ERROR E0038
fn main() { }

View file

@ -1,19 +1,19 @@
error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo`
--> $DIR/coherence-impl-trait-for-trait.rs:9:1
--> $DIR/coherence-impl-trait-for-trait.rs:13:1
|
LL | impl Foo for Baz { } //~ ERROR E0371
LL | impl Foo for Baz { }
| ^^^^^^^^^^^^^^^^ `(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:10:1
--> $DIR/coherence-impl-trait-for-trait.rs:16:1
|
LL | impl Bar for Baz { } //~ ERROR E0371
LL | impl Bar for Baz { }
| ^^^^^^^^^^^^^^^^ `(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:11:1
--> $DIR/coherence-impl-trait-for-trait.rs:19:1
|
LL | impl Baz for Baz { } //~ ERROR E0371
LL | impl Baz for Baz { }
| ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz`
error: aborting due to 3 previous errors

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:13:1
|
LL | impl Foo for Baz { }
| ^^^^^^^^^^^^^^^^ `(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:16:1
|
LL | impl Bar for Baz { }
| ^^^^^^^^^^^^^^^^ `(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:19:1
|
LL | impl Baz for Baz { }
| ^^^^^^^^^^^^^^^^ `(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

@ -1,14 +1,24 @@
// Test that we give suitable error messages when the user attempts to
// impl a trait `Trait` for its own object type.
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
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
impl Foo for Baz { }
//[old]~^ ERROR E0371
//[re]~^^ ERROR E0371
impl Bar for Baz { }
//[old]~^ ERROR E0371
//[re]~^^ ERROR E0371
impl Baz for Baz { }
//[old]~^ ERROR E0371
//[re]~^^ ERROR E0371
// But other random traits are:
trait Other { }

View file

@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `i32`:
--> $DIR/coherence-impls-copy.rs:5:1
--> $DIR/coherence-impls-copy.rs:8:1
|
LL | impl Copy for i32 {}
| ^^^^^^^^^^^^^^^^^
@ -8,7 +8,7 @@ LL | impl Copy for i32 {}
- impl std::marker::Copy for i32;
error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&NotSync`:
--> $DIR/coherence-impls-copy.rs:31:1
--> $DIR/coherence-impls-copy.rs:37:1
|
LL | impl Copy for &'static NotSync {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -18,7 +18,7 @@ LL | impl Copy for &'static NotSync {}
where T: ?Sized;
error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`:
--> $DIR/coherence-impls-copy.rs:38:1
--> $DIR/coherence-impls-copy.rs:45:1
|
LL | impl Copy for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -28,25 +28,25 @@ LL | impl Copy for &'static [NotSync] {}
where T: ?Sized;
error[E0206]: the trait `Copy` may not be implemented for this type
--> $DIR/coherence-impls-copy.rs:23:15
--> $DIR/coherence-impls-copy.rs:27: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:27:15
--> $DIR/coherence-impls-copy.rs:32: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:34:15
--> $DIR/coherence-impls-copy.rs:40: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:5:1
--> $DIR/coherence-impls-copy.rs:8:1
|
LL | impl Copy for i32 {}
| ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
@ -55,7 +55,7 @@ LL | impl Copy for i32 {}
= 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:27:1
--> $DIR/coherence-impls-copy.rs:32:1
|
LL | impl Copy for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
@ -64,7 +64,7 @@ LL | impl Copy for (MyType, MyType) {}
= 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:34:1
--> $DIR/coherence-impls-copy.rs:40:1
|
LL | impl Copy for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
@ -73,7 +73,7 @@ LL | impl Copy for [MyType] {}
= 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
--> $DIR/coherence-impls-copy.rs:45:1
|
LL | impl Copy for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate

View file

@ -0,0 +1,87 @@
error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `i32`:
--> $DIR/coherence-impls-copy.rs:8: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:37: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:45: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:27: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:32: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:40: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:8: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:32: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:40: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:45: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

@ -1,11 +1,15 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(optin_builtin_traits)]
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
//[old]~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `i32`:
//[old]~| ERROR only traits defined in the current crate can be implemented for arbitrary types
//[re]~^^^ ERROR E0119
//[re]~| ERROR E0117
enum TestE {
A
}
@ -21,23 +25,27 @@ 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
//[old]~^ ERROR the trait `Copy` may not be implemented for this type
//[re]~^^ ERROR E0206
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
//[old]~^ ERROR the trait `Copy` may not be implemented for this type
//[old]~| ERROR only traits defined in the current crate can be implemented for arbitrary types
//[re]~^^^ ERROR E0206
//[re]~| ERROR E0117
impl Copy for &'static NotSync {}
//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&NotSync`:
//[old]~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&NotSync`:
//[re]~^^ ERROR E0119
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
//[old]~^ ERROR the trait `Copy` may not be implemented for this type
//[old]~| ERROR only traits defined in the current crate can be implemented for arbitrary types
//[re]~^^^ ERROR E0206
//[re]~| ERROR E0117
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
//[old]~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`:
//[old]~| ERROR only traits defined in the current crate can be implemented for arbitrary types
//[re]~^^^ ERROR E0119
//[re]~| ERROR E0117
fn main() {
}

View file

@ -1,5 +1,5 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-send.rs:17:1
--> $DIR/coherence-impls-send.rs:20:1
|
LL | unsafe impl Send for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
@ -8,13 +8,13 @@ LL | unsafe impl Send for (MyType, MyType) {}
= 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:20:1
--> $DIR/coherence-impls-send.rs:24: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:23:1
--> $DIR/coherence-impls-send.rs:28:1
|
LL | unsafe impl Send for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
@ -23,7 +23,7 @@ LL | unsafe impl Send for [MyType] {}
= 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:26:1
--> $DIR/coherence-impls-send.rs:32:1
|
LL | unsafe impl Send for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate

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:20: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:24: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:28: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:32: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

@ -1,3 +1,6 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(optin_builtin_traits)]
#![feature(overlapping_marker_traits)]
@ -15,16 +18,20 @@ impl !Sync for NotSync {}
unsafe impl Send for TestE {}
unsafe impl Send for MyType {}
unsafe impl Send for (MyType, MyType) {}
//~^ ERROR E0117
//[old]~^ ERROR E0117
//[re]~^^ ERROR E0117
unsafe impl Send for &'static NotSync {}
//~^ ERROR E0321
//[old]~^ ERROR E0321
//[re]~^^ ERROR E0321
unsafe impl Send for [MyType] {}
//~^ ERROR E0117
//[old]~^ ERROR E0117
//[re]~^^ ERROR E0117
unsafe impl Send for &'static [NotSync] {}
//~^ ERROR E0117
//[old]~^ ERROR E0117
//[re]~^^ ERROR E0117
fn main() {
}

View file

@ -1,61 +1,61 @@
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:14: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:17:1
|
LL | impl Sized for MyType {} //~ ERROR E0322
LL | impl Sized for TestE {}
| ^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:22:1
|
LL | impl Sized for MyType {}
| ^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:20: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:24: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:27:1
|
LL | impl Sized for [MyType] {} //~ ERROR E0322
LL | impl Sized for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:34:1
|
LL | impl Sized for &'static NotSync {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:39:1
|
LL | impl Sized for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:31:1
--> $DIR/coherence-impls-sized.rs:46:1
|
LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322
LL | impl Sized for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:20:1
--> $DIR/coherence-impls-sized.rs:27:1
|
LL | impl Sized for (MyType, MyType) {} //~ ERROR E0322
LL | impl Sized 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-sized.rs:27:1
--> $DIR/coherence-impls-sized.rs:39:1
|
LL | impl Sized for [MyType] {} //~ ERROR E0322
LL | impl Sized 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-sized.rs:31:1
--> $DIR/coherence-impls-sized.rs:46:1
|
LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322
LL | impl Sized for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate

View file

@ -0,0 +1,67 @@
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:17:1
|
LL | impl Sized for TestE {}
| ^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:22:1
|
LL | impl Sized for MyType {}
| ^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:27:1
|
LL | impl Sized for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:34:1
|
LL | impl Sized for &'static NotSync {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:39:1
|
LL | impl Sized for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:46:1
|
LL | impl Sized for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:27:1
|
LL | impl Sized 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-sized.rs:39:1
|
LL | impl Sized 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-sized.rs:46:1
|
LL | impl Sized 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 9 previous errors
Some errors occurred: E0117, E0322.
For more information about an error, try `rustc --explain E0117`.

View file

@ -1,3 +1,6 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(optin_builtin_traits)]
use std::marker::Copy;
@ -11,26 +14,41 @@ struct MyType;
struct NotSync;
impl !Sync for NotSync {}
impl Sized for TestE {} //~ ERROR E0322
//~^ impl of 'Sized' not allowed
impl Sized for TestE {}
//[old]~^ ERROR E0322
//[old]~| impl of 'Sized' not allowed
//[re]~^^^ ERROR E0322
impl Sized for MyType {} //~ ERROR E0322
//~^ impl of 'Sized' not allowed
impl Sized for MyType {}
//[old]~^ ERROR E0322
//[old]~| impl of 'Sized' not allowed
//[re]~^^^ ERROR E0322
impl Sized for (MyType, MyType) {} //~ ERROR E0322
//~^ impl of 'Sized' not allowed
//~| ERROR E0117
impl Sized for (MyType, MyType) {}
//[old]~^ ERROR E0322
//[old]~| impl of 'Sized' not allowed
//[old]~| ERROR E0117
//[re]~^^^^ ERROR E0322
//[re]~| ERROR E0117
impl Sized for &'static NotSync {} //~ ERROR E0322
//~^ impl of 'Sized' not allowed
impl Sized for &'static NotSync {}
//[old]~^ ERROR E0322
//[old]~| impl of 'Sized' not allowed
//[re]~^^^ ERROR E0322
impl Sized for [MyType] {} //~ ERROR E0322
//~^ impl of 'Sized' not allowed
//~| ERROR E0117
impl Sized for [MyType] {}
//[old]~^ ERROR E0322
//[old]~| impl of 'Sized' not allowed
//[old]~| ERROR E0117
//[re]~^^^^ ERROR E0322
//[re]~| ERROR E0117
impl Sized for &'static [NotSync] {} //~ ERROR E0322
//~^ impl of 'Sized' not allowed
//~| ERROR E0117
impl Sized for &'static [NotSync] {}
//[old]~^ ERROR E0322
//[old]~| impl of 'Sized' not allowed
//[old]~| ERROR E0117
//[re]~^^^^ ERROR E0322
//[re]~| ERROR E0117
fn main() {
}

View file

@ -1,12 +1,12 @@
error[E0391]: cycle detected when processing `Trait`
--> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:9:1
--> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:12: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:9:1
--> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:12:1
|
LL | trait Trait<T> { type Assoc; }
| ^^^^^^^^^^^^^^

View file

@ -0,0 +1,16 @@
error[E0391]: cycle detected when processing `Trait`
--> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:12: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:12: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

@ -4,10 +4,14 @@
//
// No we expect to run into a more user-friendly cycle error instead.
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(specialization)]
trait Trait<T> { type Assoc; }
//~^ cycle detected
//[old]~^ cycle detected
//[re]~^^ ERROR E0391
impl<T> Trait<T> for Vec<T> {
type Assoc = ();

View file

@ -1,5 +1,5 @@
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:6:1
--> $DIR/coherence-lone-type-parameter.rs:9:1
|
LL | impl<T> Remote for T { }
| ^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type

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:9: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

@ -1,9 +1,14 @@
// aux-build:coherence_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
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
//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type
//[re]~^^ ERROR E0210
fn main() { }

View file

@ -1,5 +1,5 @@
error[E0198]: negative impls cannot be unsafe
--> $DIR/coherence-negative-impls-safe.rs:7:1
--> $DIR/coherence-negative-impls-safe.rs:10:1
|
LL | unsafe impl !Send for TestType {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -0,0 +1,9 @@
error[E0198]: negative impls cannot be unsafe
--> $DIR/coherence-negative-impls-safe.rs:10: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

@ -1,3 +1,6 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(optin_builtin_traits)]
use std::marker::Send;
@ -5,6 +8,7 @@ use std::marker::Send;
struct TestType;
unsafe impl !Send for TestType {}
//~^ ERROR negative impls cannot be unsafe
//[old]~^ ERROR negative impls cannot be unsafe
//[re]~^^ ERROR E0198
fn main() {}

View file

@ -1,9 +1,9 @@
error[E0119]: conflicting implementations of trait `MyTrait`:
--> $DIR/coherence-no-direct-lifetime-dispatch.rs:6:1
--> $DIR/coherence-no-direct-lifetime-dispatch.rs:10:1
|
LL | impl<T> MyTrait for T {}
| --------------------- first implementation here
LL | impl<T: 'static> MyTrait for T {} //~ ERROR E0119
LL | impl<T: 'static> MyTrait for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
error: aborting due to previous error

View file

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

View file

@ -1,8 +1,14 @@
// Test that you cannot *directly* dispatch on lifetime requirements
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
trait MyTrait { fn foo() {} }
impl<T> MyTrait for T {}
impl<T: 'static> MyTrait for T {} //~ ERROR E0119
impl<T: 'static> MyTrait for T {}
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-orphan.rs:11:1
--> $DIR/coherence-orphan.rs:13:1
|
LL | impl TheTrait<usize> for isize { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
@ -8,7 +8,7 @@ LL | impl TheTrait<usize> for isize { }
= 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:18:1
--> $DIR/coherence-orphan.rs:21:1
|
LL | impl !Send for Vec<isize> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate

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:13: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:21: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

@ -1,5 +1,7 @@
// aux-build:coherence_orphan_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(optin_builtin_traits)]
extern crate coherence_orphan_lib as lib;
@ -9,13 +11,15 @@ use lib::TheTrait;
struct TheType;
impl TheTrait<usize> for isize { }
//~^ ERROR E0117
//[old]~^ ERROR E0117
//[re]~^^ ERROR E0117
impl TheTrait<TheType> for isize { }
impl TheTrait<isize> for TheType { }
impl !Send for Vec<isize> { }
//~^ ERROR E0117
//[old]~^ ERROR E0117
//[re]~^^ ERROR E0117
fn main() { }

View file

@ -1,10 +1,10 @@
error[E0119]: conflicting implementations of trait `From<(_,)>` for type `(_,)`:
--> $DIR/coherence-overlap-all-t-and-tuple.rs:16:1
--> $DIR/coherence-overlap-all-t-and-tuple.rs:20:1
|
LL | impl <T> From<T> for T {
| ---------------------- first implementation here
...
LL | impl <T11, U11> From<(U11,)> for (T11,) { //~ ERROR E0119
LL | impl <T11, U11> From<(U11,)> for (T11,) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_,)`
error: aborting due to previous error

View file

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

View file

@ -6,6 +6,10 @@
//
// Seems pretty basic, but then there was issue #24241. :)
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
trait From<U> {
fn foo() {}
}
@ -13,7 +17,9 @@ trait From<U> {
impl <T> From<T> for T {
}
impl <T11, U11> From<(U11,)> for (T11,) { //~ ERROR E0119
impl <T11, U11> From<(U11,)> for (T11,) {
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
}
fn main() { }

View file

@ -1,18 +1,18 @@
error[E0592]: duplicate definitions with name `dummy`
--> $DIR/coherence-overlap-downstream-inherent.rs:7:26
--> $DIR/coherence-overlap-downstream-inherent.rs:11: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:13:38
--> $DIR/coherence-overlap-downstream-inherent.rs:18: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`
|

View file

@ -0,0 +1,23 @@
error[E0592]: duplicate definitions with name `dummy`
--> $DIR/coherence-overlap-downstream-inherent.rs:11:26
|
LL | impl<T:Sugar> Sweet<T> { fn dummy(&self) { } }
| ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
...
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:18:38
|
LL | impl<X, T> A<T, X> where T: Bar<X> { fn f(&self) {} }
| ^^^^^^^^^^^^^^ duplicate definitions for `f`
...
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

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

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