Rollup merge of #65417 - weiznich:more_coherence_tests, r=nikomatsakis

Add more coherence tests

I've wrote the missing test cases listed in [this google doc](https://docs.google.com/spreadsheets/d/1WlroTEXE6qxxGvEOhICkUpqguYZP9YOZEvnmEtSNtM0/edit#gid=0)

> The other thing that might be useful is to rename the existing tests so they all fit the new naming scheme we were using.

I'm not entirely sure how to do this. If everything from the google sheet is covered could I just remove the remaining tests in `src/test/ui/coherence` or is there something in there that should remain?

cc #63599

r? @nikomatsakis
This commit is contained in:
Yuki Okushi 2019-10-23 17:14:31 +09:00 committed by GitHub
commit 557d27637d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 373 additions and 0 deletions

View File

@ -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() {}

View File

@ -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`.

View File

@ -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() {}

View File

@ -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`.

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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`.

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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`.

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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`.

View File

@ -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() {}

View File

@ -0,0 +1,11 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/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`.

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}