Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more coherence tests #65417

Merged
merged 2 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {}
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() {}
17 changes: 17 additions & 0 deletions src/test/ui/coherence/impl[t]-foreign[local]-for-foreign[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
// check-pass

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

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

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

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![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<Local> for Box<Rc<T>> {}
impl<T, S> Remote1<Local1<S>> for Box<Rc<T>> {}
impl<T> Remote1<Box<Local>> for Box<Rc<T>> {}
impl<T, S> Remote1<Box<Local1<S>>> for Box<Rc<T>> {}

fn main() {}