Skip to content

Commit

Permalink
Add more coherence tests
Browse files Browse the repository at this point in the history
  • Loading branch information
weiznich committed Oct 14, 2019
1 parent 9249a73 commit 77f0aaf
Show file tree
Hide file tree
Showing 21 changed files with 402 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/ui/coherence/impl-foreign-for-foreign.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![feature(re_rebalance_coherence)]

// compile-flags:--crate-name=test
// aux-build:coherence_lib.rs

extern crate coherence_lib as lib;
use lib::*;
use std::rc::Rc;

struct Local;

impl Remote for i32 {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}

fn main() {}
12 changes: 12 additions & 0 deletions src/test/ui/coherence/impl-foreign-for-foreign.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/impl-foreign-for-foreign.rs:12:1
|
LL | impl Remote for i32 {
| ^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference only 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`.
25 changes: 25 additions & 0 deletions src/test/ui/coherence/impl-foreign-for-foreign[foreign].rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#![feature(re_rebalance_coherence)]

// compile-flags:--crate-name=test
// aux-build:coherence_lib.rs

extern crate coherence_lib as lib;
use lib::*;
use std::rc::Rc;

struct Local;

impl Remote1<Rc<i32>> for i32 {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}
impl Remote1<Rc<Local>> for f64 {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}
impl<T> Remote1<Rc<T>> for f32 {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}

fn main() {}
30 changes: 30 additions & 0 deletions src/test/ui/coherence/impl-foreign-for-foreign[foreign].stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/impl-foreign-for-foreign[foreign].rs:12:1
|
LL | impl Remote1<Rc<i32>> for i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference only 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/impl-foreign-for-foreign[foreign].rs:16:1
|
LL | impl Remote1<Rc<Local>> for f64 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference only 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/impl-foreign-for-foreign[foreign].rs:20:1
|
LL | impl<T> Remote1<Rc<T>> for f32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference only types defined in this crate
= note: define and implement a trait or new type instead

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0117`.
16 changes: 16 additions & 0 deletions src/test/ui/coherence/impl-foreign-for-foreign[local].rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#![feature(re_rebalance_coherence)]

// compile-flags:--crate-name=test
// aux-build:coherence_lib.rs
// check-pass

extern crate coherence_lib as lib;
use lib::*;
use std::rc::Rc;

struct Local<T>(Rc<T>);

impl Remote1<Local<i32>> for i32 {}
impl<T> Remote1<Local<T>> for f32 {}

fn main() {}
21 changes: 21 additions & 0 deletions src/test/ui/coherence/impl-foreign-for-fundamental[foreign].rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#![feature(re_rebalance_coherence)]

// compile-flags:--crate-name=test
// aux-build:coherence_lib.rs

extern crate coherence_lib as lib;
use lib::*;
use std::rc::Rc;

struct Local;

impl Remote for Box<i32> {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}
impl<T> Remote for Box<Rc<T>> {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}

fn main() {}
21 changes: 21 additions & 0 deletions src/test/ui/coherence/impl-foreign-for-fundamental[foreign].stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/impl-foreign-for-fundamental[foreign].rs:12:1
|
LL | impl Remote for Box<i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference only 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/impl-foreign-for-fundamental[foreign].rs:16:1
|
LL | impl<T> Remote for Box<Rc<T>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference only 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`.
17 changes: 17 additions & 0 deletions src/test/ui/coherence/impl-foreign-for-fundamental[local].rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![feature(re_rebalance_coherence)]

// compile-flags:--crate-name=test
// aux-build:coherence_lib.rs
// check-pass

extern crate coherence_lib as lib;
use lib::*;
use std::rc::Rc;

struct Local;
struct Local1<T>(Rc<T>);

impl Remote for Box<Local> {}
impl<T> Remote for Box<Local1<T>> {}

fn main() {}
15 changes: 15 additions & 0 deletions src/test/ui/coherence/impl-foreign-for-local.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![feature(re_rebalance_coherence)]

// compile-flags:--crate-name=test
// aux-build:coherence_lib.rs
// check-pass

extern crate coherence_lib as lib;
use lib::*;
use std::rc::Rc;

struct Local;

impl Remote for Local {}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#![feature(re_rebalance_coherence)]

// compile-flags:--crate-name=test
// aux-build:coherence_lib.rs

extern crate coherence_lib as lib;
use lib::*;
use std::rc::Rc;

struct Local;
struct Local1<T>(Rc<T>);

impl Remote1<Box<String>> for i32 {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}
impl Remote1<Box<Rc<i32>>> for f64 {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}
impl<T> Remote1<Box<Rc<T>>> for f32 {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/impl-foreign[fundemental[foreign]]-for-foreign.rs:13:1
|
LL | impl Remote1<Box<String>> for i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference only 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/impl-foreign[fundemental[foreign]]-for-foreign.rs:17:1
|
LL | impl Remote1<Box<Rc<i32>>> for f64 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference only 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/impl-foreign[fundemental[foreign]]-for-foreign.rs:21:1
|
LL | impl<T> Remote1<Box<Rc<T>>> for f32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference only types defined in this crate
= note: define and implement a trait or new type instead

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0117`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![feature(re_rebalance_coherence)]

// compile-flags:--crate-name=test
// aux-build:coherence_lib.rs
// check-pass

extern crate coherence_lib as lib;
use lib::*;
use std::rc::Rc;

struct Local;
struct Local1<T>(Rc<T>);

impl Remote1<Box<Local>> for i32 {}
impl Remote1<Box<Local1<i32>>> for f64 {}
impl<T> Remote1<Box<Local1<T>>> for f32 {}

fn main() {}
17 changes: 17 additions & 0 deletions src/test/ui/coherence/impl[t]-foreign-for-(local, t).rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![feature(re_rebalance_coherence)]

// compile-flags:--crate-name=test
// aux-build:coherence_lib.rs

extern crate coherence_lib as lib;
use lib::*;
use std::rc::Rc;

struct Local;

impl<T> Remote for (Local, T) {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}

fn main() {}
12 changes: 12 additions & 0 deletions src/test/ui/coherence/impl[t]-foreign-for-(local, t).stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/impl[t]-foreign-for-(local, t).rs:12:1
|
LL | impl<T> Remote for (Local, T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference only 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`.
23 changes: 23 additions & 0 deletions src/test/ui/coherence/impl[t]-foreign-for-foreign[t].rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![feature(re_rebalance_coherence)]

// compile-flags:--crate-name=test
// aux-build:coherence_lib.rs

extern crate coherence_lib as lib;
use lib::*;
use std::rc::Rc;
use std::sync::Arc;

struct Local;

impl Remote for Rc<Local> {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}

impl<T> Remote for Arc<T> {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}

fn main() {}
21 changes: 21 additions & 0 deletions src/test/ui/coherence/impl[t]-foreign-for-foreign[t].stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/impl[t]-foreign-for-foreign[t].rs:13:1
|
LL | impl Remote for Rc<Local> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference only 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/impl[t]-foreign-for-foreign[t].rs:18:1
|
LL | impl<T> Remote for Arc<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference only 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`.
17 changes: 17 additions & 0 deletions src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![feature(re_rebalance_coherence)]

// compile-flags:--crate-name=test
// aux-build:coherence_lib.rs

extern crate coherence_lib as lib;
use lib::*;
use std::rc::Rc;

struct Local;

impl<T> Remote for Box<T> {
//~^ ERROR type parameter `T` must be used as the type parameter for
// | some local type (e.g., `MyStruct<T>`)
}

fn main() {}
11 changes: 11 additions & 0 deletions src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].stderr
Original file line number Diff line number Diff line change
@@ -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/impl[t]-foreign-for-fundamental[t].rs:12:1
|
LL | impl<T> Remote for Box<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`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![feature(re_rebalance_coherence)]

// compile-flags:--crate-name=test
// aux-build:coherence_lib.rs
// check-pass

extern crate coherence_lib as lib;
use lib::*;
use std::rc::Rc;

struct Local;
struct Local1<S>(Rc<S>);

impl<T> Remote1<Box<Local>> for Rc<T> {}
impl<S, T> Remote1<Box<Local1<S>>> for Rc<T> {}

fn main() {}
Loading

0 comments on commit 77f0aaf

Please sign in to comment.