Skip to content

Commit 170e30b

Browse files
committed
Add coherence test
1 parent 51d265a commit 170e30b

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![allow(internal_features)]
2+
#![feature(staged_api)]
3+
#![feature(impl_stability)]
4+
#![allow(dead_code)]
5+
#![stable(feature = "a", since = "1.1.1" )]
6+
7+
#[stable(feature = "a", since = "1.1.1" )]
8+
pub trait Trait {}
9+
10+
#[unstable_feature_bound(foo)]
11+
#[unstable(feature = "foo", issue = "none" )]
12+
impl <T> Trait for T {}
13+
14+
fn main() {
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0119]: conflicting implementations of trait `Trait` for type `LocalTy`
2+
--> $DIR/unstable_impl_coherence.rs:12:1
3+
|
4+
LL | impl aux::Trait for LocalTy{}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: conflicting implementation in crate `unstable_impl_coherence_aux`:
8+
- impl<T> Trait for T
9+
where unstable feature: `foo`;
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0119`.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0119]: conflicting implementations of trait `Trait` for type `LocalTy`
2+
--> $DIR/unstable_impl_coherence.rs:12:1
3+
|
4+
LL | impl aux::Trait for LocalTy{}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: conflicting implementation in crate `unstable_impl_coherence_aux`:
8+
- impl<T> Trait for T
9+
where unstable feature: `foo`;
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0119`.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ aux-build:unstable_impl_coherence_aux.rs
2+
//@ revisions: enabled disabled
3+
4+
#![cfg_attr(enabled, feature(foo))]
5+
extern crate unstable_impl_coherence_aux as aux;
6+
use aux::Trait;
7+
8+
/// Coherence test for unstable impl.
9+
/// No matter feature `foo` is enabled or not, the impl
10+
/// for aux::Trait will be rejected by coherence checking.
11+
12+
struct LocalTy;
13+
14+
impl aux::Trait for LocalTy{}
15+
//~^ ERROR: conflicting implementations of trait `Trait` for type `LocalTy`
16+
17+
fn main(){}

0 commit comments

Comments
 (0)