Auto merge of #65879 - ohadravid:stabilize-re-rebalance-coherence, r=nikomatsakis

Stabilize the `re_rebalance_coherence` feature

This PR stabilizes [RFC 2451](https://rust-lang.github.io/rfcs/2451-re-rebalancing-coherence.html), re-rebalance coherence.

Changes include removing the attribute from tests which tested both the old and new behavior, moving the feature to `accepted` and removing the old logic.

I'll also open a [PR](https://github.com/rust-lang-nursery/reference/pull/703) against the reference, updating it with the content of the RFC.

Closes #63599

r? @nikomatsakis
This commit is contained in:
bors
2019-11-09 05:57:14 +00:00
229 changed files with 272 additions and 1643 deletions
@@ -1,23 +0,0 @@
# `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.
+12 -15
View File
@@ -205,11 +205,12 @@ pub trait AsMut<T: ?Sized> {
/// A value-to-value conversion that consumes the input value. The
/// opposite of [`From`].
///
/// One should only implement [`Into`] if a conversion to a type outside the current crate is
/// required. Otherwise one should always prefer implementing [`From`] over [`Into`] because
/// implementing [`From`] automatically provides one with a implementation of [`Into`] thanks to
/// the blanket implementation in the standard library. [`From`] cannot do these type of
/// conversions because of Rust's orphaning rules.
/// One should avoid implementing [`Into`] and implement [`From`] instead.
/// Implementing [`From`] automatically provides one with an implementation of [`Into`]
/// thanks to the blanket implementation in the standard library.
///
/// Prefer using [`Into`] over [`From`] when specifying trait bounds on a generic function
/// to ensure that types that only implement [`Into`] can be used as well.
///
/// **Note: This trait must not fail**. If the conversion can fail, use [`TryInto`].
///
@@ -218,13 +219,13 @@ pub trait AsMut<T: ?Sized> {
/// - [`From`]`<T> for U` implies `Into<U> for T`
/// - [`Into`] is reflexive, which means that `Into<T> for T` is implemented
///
/// # Implementing [`Into`] for conversions to external types
/// # Implementing [`Into`] for conversions to external types in old versions of Rust
///
/// If the destination type is not part of the current crate
/// then you can't implement [`From`] directly.
/// Prior to Rust 1.40, if the destination type was not part of the current crate
/// then you couldn't implement [`From`] directly.
/// For example, take this code:
///
/// ```compile_fail
/// ```
/// struct Wrapper<T>(Vec<T>);
/// impl<T> From<Wrapper<T>> for Vec<T> {
/// fn from(w: Wrapper<T>) -> Vec<T> {
@@ -232,9 +233,8 @@ pub trait AsMut<T: ?Sized> {
/// }
/// }
/// ```
/// This will fail to compile because we cannot implement a trait for a type
/// if both the trait and the type are not defined by the current crate.
/// This is due to Rust's orphaning rules. To bypass this, you can implement [`Into`] directly:
/// This will fail to compile in older versions of the language because Rust's orphaning rules
/// used to be a little bit more strict. To bypass this, you could implement [`Into`] directly:
///
/// ```
/// struct Wrapper<T>(Vec<T>);
@@ -249,9 +249,6 @@ pub trait AsMut<T: ?Sized> {
/// (as [`From`] does with [`Into`]). Therefore, you should always try to implement [`From`]
/// and then fall back to [`Into`] if [`From`] can't be implemented.
///
/// Prefer using [`Into`] over [`From`] when specifying trait bounds on a generic function
/// to ensure that types that only implement [`Into`] can be used as well.
///
/// # Examples
///
/// [`String`] implements [`Into`]`<`[`Vec`]`<`[`u8`]`>>`:
+43 -109
View File
@@ -367,118 +367,52 @@ fn orphan_check_trait_ref<'tcx>(
trait_ref);
}
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)
//
fn uncover_fundamental_ty<'tcx>(
tcx: TyCtxt<'tcx>,
ty: Ty<'tcx>,
in_crate: InCrate,
) -> Vec<Ty<'tcx>> {
if fundamental_ty(ty) && ty_is_non_local(tcx, ty, in_crate).is_some() {
ty.walk_shallow().flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate)).collect()
} else {
vec![ty]
// 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)
//
fn uncover_fundamental_ty<'tcx>(
tcx: TyCtxt<'tcx>,
ty: Ty<'tcx>,
in_crate: InCrate,
) -> Vec<Ty<'tcx>> {
if fundamental_ty(ty) && ty_is_non_local(tcx, ty, in_crate).is_some() {
ty.walk_shallow().flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate)).collect()
} else {
vec![ty]
}
}
let mut non_local_spans = vec![];
for (i, input_ty) in trait_ref
.input_types()
.flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate))
.enumerate()
{
debug!("orphan_check_trait_ref: check ty `{:?}`", input_ty);
let non_local_tys = ty_is_non_local(tcx, input_ty, in_crate);
if non_local_tys.is_none() {
debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty);
return Ok(());
} else if let ty::Param(_) = input_ty.kind {
debug!("orphan_check_trait_ref: uncovered ty: `{:?}`", input_ty);
return Err(OrphanCheckErr::UncoveredTy(input_ty))
}
if let Some(non_local_tys) = non_local_tys {
for input_ty in non_local_tys {
non_local_spans.push((input_ty, i == 0));
}
}
let mut non_local_spans = vec![];
for (i, input_ty) in trait_ref
.input_types()
.flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate))
.enumerate()
{
debug!("orphan_check_trait_ref: check ty `{:?}`", input_ty);
let non_local_tys = ty_is_non_local(tcx, input_ty, in_crate);
if non_local_tys.is_none() {
debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty);
return Ok(());
} else if let ty::Param(_) = input_ty.kind {
debug!("orphan_check_trait_ref: uncovered ty: `{:?}`", input_ty);
return Err(OrphanCheckErr::UncoveredTy(input_ty))
}
if let Some(non_local_tys) = non_local_tys {
for input_ty in non_local_tys {
non_local_spans.push((input_ty, i == 0));
}
}
}
// If we exit above loop, never found a local type.
debug!("orphan_check_trait_ref: no local type");
Err(OrphanCheckErr::NonLocalInputType(non_local_spans))
} else {
let mut non_local_spans = vec![];
// 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 (i, input_ty) in trait_ref.input_types().enumerate() {
let non_local_tys = ty_is_non_local(tcx, input_ty, in_crate);
if non_local_tys.is_none() {
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));
}
}
// 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));
}
if let Some(non_local_tys) = non_local_tys {
for input_ty in non_local_tys {
non_local_spans.push((input_ty, i == 0));
}
}
}
// If we exit above loop, never found a local type.
debug!("orphan_check_trait_ref: no local type");
Err(OrphanCheckErr::NonLocalInputType(non_local_spans))
}
}
fn uncovered_tys<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec<Ty<'tcx>> {
if ty_is_non_local_constructor(tcx, ty, in_crate).is_none() {
vec![]
} else if fundamental_ty(ty) {
ty.walk_shallow()
.flat_map(|t| uncovered_tys(tcx, t, in_crate))
.collect()
} else {
vec![ty]
}
}
fn is_possibly_remote_type(ty: Ty<'_>, _in_crate: InCrate) -> bool {
match ty.kind {
ty::Projection(..) | ty::Param(..) => true,
_ => false,
}
// If we exit above loop, never found a local type.
debug!("orphan_check_trait_ref: no local type");
Err(OrphanCheckErr::NonLocalInputType(non_local_spans))
}
fn ty_is_non_local<'t>(tcx: TyCtxt<'t>, ty: Ty<'t>, in_crate: InCrate) -> Option<Vec<Ty<'t>>> {
+3
View File
@@ -253,6 +253,9 @@ macro_rules! declare_features {
(accepted, const_constructor, "1.40.0", Some(61456), None),
/// Allows the use of `#[cfg(doctest)]`, set when rustdoc is collecting doctests.
(accepted, cfg_doctest, "1.40.0", Some(62210), None),
/// Allows relaxing the coherence rules such that
/// `impl<T> ForeignTrait<LocalType> for ForeignType<T>` is permitted.
(accepted, re_rebalance_coherence, "1.41.0", Some(55437), None),
// -------------------------------------------------------------------------
// feature-group-end: accepted features
-4
View File
@@ -466,10 +466,6 @@ pub fn set(&self, features: &mut Features, span: Span) {
/// Allows exhaustive integer pattern matching on `usize` and `isize`.
(active, precise_pointer_size_matching, "1.32.0", Some(56354), None),
/// Allows relaxing the coherence rules such that
/// `impl<T> ForeignTrait<LocalType> for ForeignType<T>` is permitted.
(active, re_rebalance_coherence, "1.32.0", Some(55437), None),
/// Allows using `#[ffi_returns_twice]` on foreign functions.
(active, ffi_returns_twice, "1.34.0", Some(58314), None),
@@ -1,11 +0,0 @@
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:6
|
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`.
@@ -1,13 +1,9 @@
// 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 { }
//[old]~^ ERROR E0210
//[re]~^^ ERROR E0210
//~^ ERROR E0210
fn main() { }
@@ -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:9:6
--> $DIR/coherence-all-remote.rs:6:6
|
LL | impl<T> Remote1<T> for isize { }
| ^ type parameter `T` must be used as the type parameter for some local type
@@ -1,8 +1,5 @@
// run-pass
// aux-build:coherence_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
// pretty-expanded FIXME #23616
@@ -1,11 +0,0 @@
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:6
|
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`.
@@ -1,7 +1,4 @@
// aux-build:coherence_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
extern crate coherence_lib as lib;
use lib::Remote1;
@@ -9,7 +6,6 @@
pub struct BigInt;
impl<T> Remote1<BigInt> for T { }
//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type
//[re]~^^ ERROR E0210
//~^ ERROR E0210
fn main() { }
@@ -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:11:6
--> $DIR/coherence-bigint-param.rs:8:6
|
LL | impl<T> Remote1<BigInt> for T { }
| ^ type parameter `T` must be used as the type parameter for some local type
@@ -1,8 +1,5 @@
// run-pass
// aux-build:coherence_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
// pretty-expanded FIXME #23616
@@ -1,12 +0,0 @@
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`.
@@ -1,7 +1,3 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
use std::fmt::Debug;
use std::default::Default;
@@ -26,8 +22,7 @@ fn get(&self) -> usize { 0 }
}
impl<T:Odd> MyTrait for T {
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
//~^ ERROR E0119
fn get(&self) -> usize { 0 }
}
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `MyTrait`:
--> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:28:1
--> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:24:1
|
LL | impl<T:Even> MyTrait for T {
| -------------------------- first implementation here
@@ -1,12 +0,0 @@
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`.
@@ -1,7 +1,3 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
use std::fmt::Debug;
use std::default::Default;
@@ -22,8 +18,7 @@ fn get(&self) -> usize { 0 }
}
impl<T:Odd> MyTrait for T {
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
//~^ ERROR E0119
fn get(&self) -> usize { 0 }
}
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `MyTrait`:
--> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:24:1
--> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:20:1
|
LL | impl<T:Even> MyTrait for T {
| -------------------------- first implementation here
@@ -1,13 +0,0 @@
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`.
@@ -1,7 +1,4 @@
// aux-build:go_trait.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
extern crate go_trait;
@@ -16,8 +13,7 @@ fn go(&self, arg: isize) { }
}
impl GoMut for MyThingy {
//[old]~^ ERROR conflicting implementations
//[re]~^^ ERROR E0119
//~^ ERROR E0119
fn go_mut(&mut self, arg: isize) { }
}
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `go_trait::GoMut` for type `MyThingy`:
--> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:18:1
--> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:15:1
|
LL | impl GoMut for MyThingy {
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -1,12 +0,0 @@
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`.
@@ -1,7 +1,3 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
use std::fmt::Debug;
use std::default::Default;
@@ -24,8 +20,7 @@ struct MyType {
}
impl MyTrait<MyType> for MyType {
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
//~^ ERROR E0119
fn get(&self) -> usize { (*self).clone() }
}
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `MyTrait<MyType>` for type `MyType`:
--> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:26:1
--> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:22:1
|
LL | impl<T> MyTrait<T> for T {
| ------------------------ first implementation here
@@ -1,12 +0,0 @@
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`.
@@ -1,10 +1,6 @@
// 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);
}
@@ -22,8 +18,7 @@ struct MyType {
}
impl MyTrait for MyType {
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
//~^ ERROR E0119
fn get(&self) -> usize { self.dummy }
}
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`:
--> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:24:1
--> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:20:1
|
LL | impl<T:OtherTrait> MyTrait for T {
| -------------------------------- first implementation here
@@ -1,12 +0,0 @@
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`.
@@ -1,7 +1,3 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
use std::fmt::Debug;
use std::default::Default;
@@ -21,8 +17,7 @@ struct MyType {
}
impl MyTrait for MyType {
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
//~^ ERROR E0119
fn get(&self) -> usize { self.dummy }
}
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`:
--> $DIR/coherence-blanket-conflicts-with-specific.rs:23:1
--> $DIR/coherence-blanket-conflicts-with-specific.rs:19:1
|
LL | impl<T> MyTrait for T {
| --------------------- first implementation here
@@ -1,9 +1,6 @@
// run-pass
#![allow(unused_imports)]
// aux-build:coherence_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
// pretty-expanded FIXME #23616
@@ -1,21 +0,0 @@
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`.
@@ -1,6 +1,3 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(optin_builtin_traits)]
#![feature(overlapping_marker_traits)]
@@ -11,13 +8,11 @@ trait MyTrait {}
unsafe impl<T: MyTrait+'static> Send for TestType<T> {}
impl<T: MyTrait> !Send for TestType<T> {}
//[old]~^ ERROR conflicting implementations of trait `std::marker::Send`
//[re]~^^ ERROR E0119
//~^ ERROR E0119
unsafe impl<T:'static> Send for TestType<T> {}
impl !Send for TestType<i32> {}
//[old]~^ ERROR conflicting implementations of trait `std::marker::Send`
//[re]~^^ ERROR E0119
//~^ ERROR E0119
fn main() {}
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType<_>`:
--> $DIR/coherence-conflicting-negative-trait-impl.rs:13:1
--> $DIR/coherence-conflicting-negative-trait-impl.rs:10: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:19:1
--> $DIR/coherence-conflicting-negative-trait-impl.rs:15:1
|
LL | unsafe impl<T:'static> Send for TestType<T> {}
| ------------------------------------------- first implementation here
@@ -1,9 +1,6 @@
// run-pass
#![allow(dead_code)]
// aux-build:coherence_lib.rs
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
// pretty-expanded FIXME #23616
@@ -1,11 +0,0 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/coherence-cow.rs:18:6
|
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
error: aborting due to previous error
For more information about this error, try `rustc --explain E0210`.
@@ -1,11 +0,0 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/coherence-cow.rs:23:6
|
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
error: aborting due to previous error
For more information about this error, try `rustc --explain E0210`.
@@ -1,11 +0,0 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/coherence-cow.rs:28:6
|
LL | impl<T,U> Remote for Pair<Cover<T>,U> { }
| ^ 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`.
@@ -1,5 +1,5 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-cow.rs:23:1
--> $DIR/coherence-cow.rs:22:1
|
LL | impl<T> Remote for Pair<Cover<T>,T> { }
| ^^^^^^^^^^^^^^^^^^^----------------
@@ -1,5 +1,5 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-cow.rs:28:1
--> $DIR/coherence-cow.rs:26:1
|
LL | impl<T,U> Remote for Pair<Cover<T>,U> { }
| ^^^^^^^^^^^^^^^^^^^^^----------------
+8 -11
View File
@@ -1,6 +1,6 @@
// revisions: a b c re_a re_b re_c
// revisions: re_a re_b re_c
#![cfg_attr(any(re_a, re_b, re_c), feature(re_rebalance_coherence))]
#![cfg_attr(any(), re_a, re_b, re_c)]
// aux-build:coherence_lib.rs
@@ -14,19 +14,16 @@
pub struct Cover<T>(T);
#[cfg(any(a, re_a))]
#[cfg(any(re_a))]
impl<T> Remote for Pair<T,Cover<T>> { }
//[a]~^ ERROR E0210
//[re_a]~^^ ERROR E0117
//[re_a]~^ ERROR E0117
#[cfg(any(b, re_b))]
#[cfg(any(re_b))]
impl<T> Remote for Pair<Cover<T>,T> { }
//[b]~^ ERROR E0210
//[re_b]~^^ ERROR E0117
//[re_b]~^ ERROR E0117
#[cfg(any(c, re_c))]
#[cfg(any(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
//[re_c]~^ ERROR E0117
fn main() { }
@@ -1,21 +0,0 @@
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:6
|
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 have detailed explanations: E0119, E0210.
For more information about an error, try `rustc --explain E0119`.
@@ -2,18 +2,13 @@
// 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 {
//[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
//~^ ERROR E0119
//~| ERROR E0210
}
fn main() {
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize`:
--> $DIR/coherence-cross-crate-conflict.rs:12:1
--> $DIR/coherence-cross-crate-conflict.rs:9: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:12:6
--> $DIR/coherence-cross-crate-conflict.rs:9:6
|
LL | impl<A> Foo for A {
| ^ type parameter `A` must be used as the type parameter for some local type
@@ -1,16 +0,0 @@
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 have detailed explanations: E0199, E0200.
For more information about an error, try `rustc --explain E0199`.
@@ -1,6 +1,3 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(optin_builtin_traits)]
auto trait MySafeTrait {}
@@ -8,13 +5,11 @@
struct Foo;
unsafe impl MySafeTrait for Foo {}
//[old]~^ ERROR implementing the trait `MySafeTrait` is not unsafe
//[re]~^^ ERROR E0199
//~^ ERROR E0199
unsafe auto trait MyUnsafeTrait {}
impl MyUnsafeTrait for Foo {}
//[old]~^ ERROR the trait `MyUnsafeTrait` requires an `unsafe impl` declaration
//[re]~^^ ERROR E0200
//~^ ERROR E0200
fn main() {}
@@ -1,11 +1,11 @@
error[E0199]: implementing the trait `MySafeTrait` is not unsafe
--> $DIR/coherence-default-trait-impl.rs:10:1
--> $DIR/coherence-default-trait-impl.rs:7: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
--> $DIR/coherence-default-trait-impl.rs:12:1
|
LL | impl MyUnsafeTrait for Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1,9 +0,0 @@
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`.
@@ -1,9 +1,5 @@
// 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 {}
@@ -11,8 +7,7 @@ impl Foo for i16 {}
impl Foo for i32 {}
impl Foo for i64 {}
impl Foo for DoesNotExist {}
//[old]~^ ERROR cannot find type `DoesNotExist` in this scope
//[re]~^^ ERROR E0412
//~^ ERROR E0412
impl Foo for u8 {}
impl Foo for u16 {}
impl Foo for u32 {}
@@ -1,5 +1,5 @@
error[E0412]: cannot find type `DoesNotExist` in this scope
--> $DIR/coherence-error-suppression.rs:13:14
--> $DIR/coherence-error-suppression.rs:9:14
|
LL | impl Foo for DoesNotExist {}
| ^^^^^^^^^^^^ not found in this scope
@@ -1,14 +0,0 @@
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> {}
| ^^^^^^^^^^^^^^----------------------
| | |
| | `dyn coherence_fundamental_trait_lib::Fundamental<Local>` is not defined in the current crate
| impl doesn't use only types from inside the current 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`.
@@ -3,9 +3,6 @@
// 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;
@@ -13,7 +10,6 @@
pub struct Local;
impl Misc for dyn Fundamental<Local> {}
//[old]~^ ERROR E0117
//[re]~^^ ERROR E0117
//~^ ERROR E0117
fn main() {}
@@ -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:15:1
--> $DIR/coherence-fundamental-trait-objects.rs:12:1
|
LL | impl Misc for dyn Fundamental<Local> {}
| ^^^^^^^^^^^^^^----------------------
@@ -1,7 +1,4 @@
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]
#![allow(non_camel_case_types)]
@@ -1,11 +0,0 @@
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6
|
LL | trait NotObjectSafe { fn eq(&self, other: Self); }
| -- method `eq` references the `Self` type in its parameters or return type
LL | impl NotObjectSafe for dyn NotObjectSafe { }
| ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
error: aborting due to previous error
For more information about this error, try `rustc --explain E0038`.
@@ -1,15 +1,10 @@
// 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 dyn NotObjectSafe { }
//[old]~^ ERROR E0038
//[re]~^^ ERROR E0038
//~^ ERROR E0038
fn main() { }
@@ -1,5 +1,5 @@
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:7:6
|
LL | trait NotObjectSafe { fn eq(&self, other: Self); }
| -- method `eq` references the `Self` type in its parameters or return type
@@ -1,21 +0,0 @@
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 dyn 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 dyn 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 dyn 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`.
@@ -1,24 +1,17 @@
// 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 dyn Baz { }
//[old]~^ ERROR E0371
//[re]~^^ ERROR E0371
//~^ ERROR E0371
impl Bar for dyn Baz { }
//[old]~^ ERROR E0371
//[re]~^^ ERROR E0371
//~^ ERROR E0371
impl Baz for dyn Baz { }
//[old]~^ ERROR E0371
//[re]~^^ ERROR E0371
//~^ ERROR E0371
// But other random traits are:
trait Other { }
@@ -1,17 +1,17 @@
error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo`
--> $DIR/coherence-impl-trait-for-trait.rs:13:1
--> $DIR/coherence-impl-trait-for-trait.rs:9:1
|
LL | impl Foo for dyn 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
--> $DIR/coherence-impl-trait-for-trait.rs:11:1
|
LL | impl Bar for dyn 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
--> $DIR/coherence-impl-trait-for-trait.rs:13:1
|
LL | impl Baz for dyn Baz { }
| ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz`
@@ -1,95 +0,0 @@
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 {}
| ^^^^^^^^^^^^^^---
| | |
| | `i32` is not defined in the current crate
| impl doesn't use only types from inside the current 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) {}
| ^^^^^^^^^^^^^^----------------
| | |
| | this is not defined in the current crate because tuples are always foreign
| impl doesn't use only types from inside the current 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] {}
| ^^^^^^^^^^^^^^--------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't use only types from inside the current 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] {}
| ^^^^^^^^^^^^^^------------------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't use only types from inside the current crate
|
= note: define and implement a trait or new type instead
error: aborting due to 10 previous errors
Some errors have detailed explanations: E0117, E0119, E0206.
For more information about an error, try `rustc --explain E0117`.
+10 -23
View File
@@ -1,15 +1,10 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(optin_builtin_traits)]
use std::marker::Copy;
impl Copy for i32 {}
//[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
//~^ ERROR E0119
//~| ERROR E0117
enum TestE {
A
}
@@ -25,27 +20,19 @@ impl Clone for TestE { fn clone(&self) -> Self { *self } }
impl Copy for MyType {}
impl Copy for &'static mut MyType {}
//[old]~^ ERROR the trait `Copy` may not be implemented for this type
//[re]~^^ ERROR E0206
//~^ ERROR E0206
impl Clone for MyType { fn clone(&self) -> Self { *self } }
impl Copy for (MyType, MyType) {}
//[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
//~^ ERROR E0206
//~| ERROR E0117
impl Copy for &'static NotSync {}
//[old]~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&NotSync`:
//[re]~^^ ERROR E0119
//~^ ERROR E0119
impl Copy for [MyType] {}
//[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
//~^ ERROR E0206
//~| ERROR E0117
impl Copy for &'static [NotSync] {}
//[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
//~^ ERROR E0119
//~| ERROR E0117
fn main() {
}
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `i32`:
--> $DIR/coherence-impls-copy.rs:8:1
--> $DIR/coherence-impls-copy.rs:5: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:37:1
--> $DIR/coherence-impls-copy.rs:29: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:45:1
--> $DIR/coherence-impls-copy.rs:34: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:27:15
--> $DIR/coherence-impls-copy.rs:22: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
--> $DIR/coherence-impls-copy.rs:26: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
--> $DIR/coherence-impls-copy.rs:31: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
--> $DIR/coherence-impls-copy.rs:5:1
|
LL | impl Copy for i32 {}
| ^^^^^^^^^^^^^^---
@@ -57,7 +57,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:32:1
--> $DIR/coherence-impls-copy.rs:26:1
|
LL | impl Copy for (MyType, MyType) {}
| ^^^^^^^^^^^^^^----------------
@@ -68,7 +68,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:40:1
--> $DIR/coherence-impls-copy.rs:31:1
|
LL | impl Copy for [MyType] {}
| ^^^^^^^^^^^^^^--------
@@ -79,7 +79,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:45:1
--> $DIR/coherence-impls-copy.rs:34:1
|
LL | impl Copy for &'static [NotSync] {}
| ^^^^^^^^^^^^^^------------------
@@ -1,43 +0,0 @@
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) {}
| ^^^^^^^^^^^^^^^^^^^^^----------------
| | |
| | this is not defined in the current crate because tuples are always foreign
| impl doesn't use only types from inside the current 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] {}
| ^^^^^^^^^^^^^^^^^^^^^--------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't use only types from inside the current 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] {}
| ^^^^^^^^^^^^^^^^^^^^^------------------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't use only types from inside the current crate
|
= note: define and implement a trait or new type instead
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0117, E0321.
For more information about an error, try `rustc --explain E0117`.
+4 -11
View File
@@ -1,6 +1,3 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(optin_builtin_traits)]
#![feature(overlapping_marker_traits)]
@@ -18,20 +15,16 @@ impl !Sync for NotSync {}
unsafe impl Send for TestE {}
unsafe impl Send for MyType {}
unsafe impl Send for (MyType, MyType) {}
//[old]~^ ERROR E0117
//[re]~^^ ERROR E0117
//~^ ERROR E0117
unsafe impl Send for &'static NotSync {}
//[old]~^ ERROR E0321
//[re]~^^ ERROR E0321
//~^ ERROR E0321
unsafe impl Send for [MyType] {}
//[old]~^ ERROR E0117
//[re]~^^ ERROR E0117
//~^ ERROR E0117
unsafe impl Send for &'static [NotSync] {}
//[old]~^ ERROR E0117
//[re]~^^ ERROR E0117
//~^ ERROR E0117
fn main() {
}
@@ -1,5 +1,5 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-send.rs:20:1
--> $DIR/coherence-impls-send.rs:17:1
|
LL | unsafe impl Send for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^----------------
@@ -10,13 +10,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:24:1
--> $DIR/coherence-impls-send.rs:20: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
--> $DIR/coherence-impls-send.rs:23:1
|
LL | unsafe impl Send for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^--------
@@ -27,7 +27,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:32:1
--> $DIR/coherence-impls-send.rs:26:1
|
LL | unsafe impl Send for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^------------------
@@ -1,73 +0,0 @@
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) {}
| ^^^^^^^^^^^^^^^----------------
| | |
| | this is not defined in the current crate because tuples are always foreign
| impl doesn't use only types from inside the current 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] {}
| ^^^^^^^^^^^^^^^--------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't use only types from inside the current 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] {}
| ^^^^^^^^^^^^^^^------------------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't use only types from inside the current crate
|
= note: define and implement a trait or new type instead
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0117, E0322.
For more information about an error, try `rustc --explain E0117`.
+9 -27
View File
@@ -1,6 +1,3 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(optin_builtin_traits)]
use std::marker::Copy;
@@ -15,40 +12,25 @@ enum TestE {
impl !Sync for NotSync {}
impl Sized for TestE {}
//[old]~^ ERROR E0322
//[old]~| impl of 'Sized' not allowed
//[re]~^^^ ERROR E0322
//~^ ERROR E0322
impl Sized for MyType {}
//[old]~^ ERROR E0322
//[old]~| impl of 'Sized' not allowed
//[re]~^^^ ERROR E0322
//~^ ERROR E0322
impl Sized for (MyType, MyType) {}
//[old]~^ ERROR E0322
//[old]~| impl of 'Sized' not allowed
//[old]~| ERROR E0117
//[re]~^^^^ ERROR E0322
//[re]~| ERROR E0117
//~^ ERROR E0322
//~| ERROR E0117
impl Sized for &'static NotSync {}
//[old]~^ ERROR E0322
//[old]~| impl of 'Sized' not allowed
//[re]~^^^ ERROR E0322
//~^ ERROR E0322
impl Sized for [MyType] {}
//[old]~^ ERROR E0322
//[old]~| impl of 'Sized' not allowed
//[old]~| ERROR E0117
//[re]~^^^^ ERROR E0322
//[re]~| ERROR E0117
//~^ ERROR E0322
//~| 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
//~^ ERROR E0322
//~| ERROR E0117
fn main() {
}
@@ -1,41 +1,41 @@
error[E0322]: explicit impls for the `Sized` trait are not permitted
--> $DIR/coherence-impls-sized.rs:17:1
--> $DIR/coherence-impls-sized.rs:14: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
--> $DIR/coherence-impls-sized.rs:17: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
--> $DIR/coherence-impls-sized.rs:20: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
--> $DIR/coherence-impls-sized.rs:24: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
--> $DIR/coherence-impls-sized.rs:27: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
--> $DIR/coherence-impls-sized.rs:31: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
--> $DIR/coherence-impls-sized.rs:20:1
|
LL | impl Sized for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^----------------
@@ -46,7 +46,7 @@ LL | impl Sized 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-sized.rs:39:1
--> $DIR/coherence-impls-sized.rs:27:1
|
LL | impl Sized for [MyType] {}
| ^^^^^^^^^^^^^^^--------
@@ -57,7 +57,7 @@ LL | impl Sized 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-sized.rs:46:1
--> $DIR/coherence-impls-sized.rs:31:1
|
LL | impl Sized for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^------------------
@@ -1,16 +0,0 @@
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`.
@@ -3,15 +3,10 @@
// which is currently not supported.
//
// 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; }
//[old]~^ cycle detected
//[re]~^^ ERROR E0391
//~^ ERROR E0391
impl<T> Trait<T> for Vec<T> {
type Assoc = ();
@@ -1,12 +1,12 @@
error[E0391]: cycle detected when processing `Trait`
--> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:12:1
--> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:8: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
--> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:8:1
|
LL | trait Trait<T> { type Assoc; }
| ^^^^^^^^^^^^^^
@@ -1,7 +1,4 @@
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]
// aux-build:coherence_lib.rs
@@ -1,7 +1,4 @@
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]
// aux-build:coherence_lib.rs
@@ -1,11 +0,0 @@
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:6
|
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`.
@@ -1,14 +1,10 @@
// 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 { }
//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type
//[re]~^^ ERROR E0210
//~^ ERROR E0210
fn main() { }
@@ -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:9:6
--> $DIR/coherence-lone-type-parameter.rs:6:6
|
LL | impl<T> Remote for T { }
| ^ type parameter `T` must be used as the type parameter for some local type
@@ -1,7 +1,4 @@
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(unused_imports)]
// pretty-expanded FIXME #23616
@@ -1,7 +1,4 @@
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]
// pretty-expanded FIXME #23616
@@ -1,9 +0,0 @@
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`.
@@ -1,6 +1,3 @@
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![feature(optin_builtin_traits)]
use std::marker::Send;
@@ -8,7 +5,6 @@
struct TestType;
unsafe impl !Send for TestType {}
//[old]~^ ERROR negative impls cannot be unsafe
//[re]~^^ ERROR E0198
//~^ ERROR E0198
fn main() {}
@@ -1,5 +1,5 @@
error[E0198]: negative impls cannot be unsafe
--> $DIR/coherence-negative-impls-safe.rs:10:1
--> $DIR/coherence-negative-impls-safe.rs:7:1
|
LL | unsafe impl !Send for TestType {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1,11 +0,0 @@
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`.
@@ -1,14 +1,9 @@
// 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 {}
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
//~^ ERROR E0119
fn main() {}
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `MyTrait`:
--> $DIR/coherence-no-direct-lifetime-dispatch.rs:10:1
--> $DIR/coherence-no-direct-lifetime-dispatch.rs:6:1
|
LL | impl<T> MyTrait for T {}
| --------------------- first implementation here
@@ -1,26 +0,0 @@
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 { }
| ^^^^^---------------^^^^^-----
| | | |
| | | `isize` is not defined in the current crate
| | `usize` is not defined in the current crate
| impl doesn't use only types from inside the current 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> { }
| ^^^^^^^^^^^^^^^----------
| | |
| | `std::vec::Vec` is not defined in the current crate
| impl doesn't use only types from inside the current 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`.
+2 -7
View File
@@ -1,7 +1,4 @@
// 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;
@@ -11,15 +8,13 @@
struct TheType;
impl TheTrait<usize> for isize { }
//[old]~^ ERROR E0117
//[re]~^^ ERROR E0117
//~^ ERROR E0117
impl TheTrait<TheType> for isize { }
impl TheTrait<isize> for TheType { }
impl !Send for Vec<isize> { }
//[old]~^ ERROR E0117
//[re]~^^ ERROR E0117
//~^ ERROR E0117
fn main() { }
@@ -1,5 +1,5 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-orphan.rs:13:1
--> $DIR/coherence-orphan.rs:10:1
|
LL | impl TheTrait<usize> for isize { }
| ^^^^^---------------^^^^^-----
@@ -11,7 +11,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:21:1
--> $DIR/coherence-orphan.rs:17:1
|
LL | impl !Send for Vec<isize> { }
| ^^^^^^^^^^^^^^^----------
@@ -1,12 +0,0 @@
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`.
@@ -6,10 +6,6 @@
//
// Seems pretty basic, but then there was issue #24241. :)
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
trait From<U> {
fn foo() {}
}
@@ -18,8 +14,7 @@ impl <T> From<T> for T {
}
impl <T11, U11> From<(U11,)> for (T11,) {
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
//~^ ERROR E0119
}
fn main() { }
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `From<(_,)>` for type `(_,)`:
--> $DIR/coherence-overlap-all-t-and-tuple.rs:20:1
--> $DIR/coherence-overlap-all-t-and-tuple.rs:16:1
|
LL | impl <T> From<T> for T {
| ---------------------- first implementation here
@@ -1,23 +0,0 @@
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`.
@@ -1,23 +1,17 @@
// 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) { } }
//[old]~^ ERROR E0592
//[re]~^^ ERROR E0592
//~^ 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) {} }
//[old]~^ ERROR E0592
//[re]~^^ ERROR E0592
//~^ ERROR E0592
impl<X> A<i32, X> { fn f(&self) {} }
fn main() {}
@@ -1,18 +1,18 @@
error[E0592]: duplicate definitions with name `dummy`
--> $DIR/coherence-overlap-downstream-inherent.rs:11:26
--> $DIR/coherence-overlap-downstream-inherent.rs:7:26
|
LL | impl<T:Sugar> Sweet<T> { fn dummy(&self) { } }
| ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
...
LL |
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
--> $DIR/coherence-overlap-downstream-inherent.rs:13:38
|
LL | impl<X, T> A<T, X> where T: Bar<X> { fn f(&self) {} }
| ^^^^^^^^^^^^^^ duplicate definitions for `f`
...
LL |
LL | impl<X> A<i32, X> { fn f(&self) {} }
| -------------- other definition for `f`
|
@@ -1,21 +0,0 @@
error[E0119]: conflicting implementations of trait `Sweet`:
--> $DIR/coherence-overlap-downstream.rs:12: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:19: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`.
@@ -1,23 +1,17 @@
// 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))]
pub trait Sugar {}
pub trait Fruit {}
pub trait Sweet {}
impl<T:Sugar> Sweet for T { }
impl<T:Fruit> Sweet for T { }
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
//~^ 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 {}
//[old]~^ ERROR E0119
//[re]~^^ ERROR E0119
//~^ ERROR E0119
fn main() { }
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `Sweet`:
--> $DIR/coherence-overlap-downstream.rs:12:1
--> $DIR/coherence-overlap-downstream.rs:8:1
|
LL | impl<T:Sugar> Sweet for T { }
| ------------------------- first implementation here
@@ -7,7 +7,7 @@ LL | impl<T:Fruit> Sweet for T { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
error[E0119]: conflicting implementations of trait `Foo<_>` for type `i32`:
--> $DIR/coherence-overlap-downstream.rs:19:1
--> $DIR/coherence-overlap-downstream.rs:14:1
|
LL | impl<X, T> Foo<X> for T where T: Bar<X> {}
| --------------------------------------- first implementation here
@@ -1,14 +0,0 @@
error[E0592]: duplicate definitions with name `dummy`
--> $DIR/coherence-overlap-issue-23516-inherent.rs:13:25
|
LL | impl<T:Sugar> Cake<T> { fn dummy(&self) { } }
| ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
...
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`.
@@ -2,17 +2,12 @@
// though we see no impl of `Sugar` for `Box`. Therefore, an overlap
// error is reported for the following pair of impls (#23516).
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
pub trait Sugar {}
struct Cake<X>(X);
impl<T:Sugar> Cake<T> { fn dummy(&self) { } }
//[old]~^ ERROR E0592
//[re]~^^ ERROR E0592
//~^ ERROR E0592
impl<U:Sugar> Cake<Box<U>> { fn dummy(&self) { } }
fn main() { }

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