Update some tests involving Self

This commit is contained in:
Esteban Küber 2019-10-08 16:13:05 -07:00
parent 99ab45b91d
commit ca1885de41
6 changed files with 51 additions and 2 deletions

View file

@ -0,0 +1,15 @@
// run-rustfix
#![allow(unused_variables)]
trait Get {
type Value;
fn get(&self) -> <Self as Get>::Value;
}
trait Other {
fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get{}
//~^ ERROR the trait bound `Self: Get` is not satisfied
}
fn main() {
}

View file

@ -1,3 +1,6 @@
// run-rustfix
#![allow(unused_variables)]
trait Get {
type Value;
fn get(&self) -> <Self as Get>::Value;

View file

@ -1,5 +1,5 @@
error[E0277]: the trait bound `Self: Get` is not satisfied
--> $DIR/associated-types-for-unimpl-trait.rs:7:5
--> $DIR/associated-types-for-unimpl-trait.rs:10:5
|
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^

View file

@ -0,0 +1,30 @@
// run-rustfix
// Check that we get an error when you use `<Self as Get>::Value` in
// the trait definition even if there is no default method.
trait Get {
type Value;
}
trait Other {
fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get;
//~^ ERROR E0277
}
impl Get for () {
type Value = f32;
}
impl Get for f64 {
type Value = u32;
}
impl Other for () {
fn okay<U:Get>(&self, _foo: U, _bar: <Self as Get>::Value) { }
}
impl Other for f64 {
fn okay<U:Get>(&self, _foo: U, _bar: <Self as Get>::Value) { }
}
fn main() { }

View file

@ -1,3 +1,4 @@
// run-rustfix
// Check that we get an error when you use `<Self as Get>::Value` in
// the trait definition even if there is no default method.

View file

@ -1,5 +1,5 @@
error[E0277]: the trait bound `Self: Get` is not satisfied
--> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:9:5
--> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:10:5
|
LL | fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-