Skip to content

Commit ca1885d

Browse files
committed
Update some tests involving Self
1 parent 99ab45b commit ca1885d

6 files changed

+51
-2
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// run-rustfix
2+
#![allow(unused_variables)]
3+
4+
trait Get {
5+
type Value;
6+
fn get(&self) -> <Self as Get>::Value;
7+
}
8+
9+
trait Other {
10+
fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get{}
11+
//~^ ERROR the trait bound `Self: Get` is not satisfied
12+
}
13+
14+
fn main() {
15+
}

src/test/ui/associated-types/associated-types-for-unimpl-trait.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// run-rustfix
2+
#![allow(unused_variables)]
3+
14
trait Get {
25
type Value;
36
fn get(&self) -> <Self as Get>::Value;

src/test/ui/associated-types/associated-types-for-unimpl-trait.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `Self: Get` is not satisfied
2-
--> $DIR/associated-types-for-unimpl-trait.rs:7:5
2+
--> $DIR/associated-types-for-unimpl-trait.rs:10:5
33
|
44
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// run-rustfix
2+
// Check that we get an error when you use `<Self as Get>::Value` in
3+
// the trait definition even if there is no default method.
4+
5+
trait Get {
6+
type Value;
7+
}
8+
9+
trait Other {
10+
fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get;
11+
//~^ ERROR E0277
12+
}
13+
14+
impl Get for () {
15+
type Value = f32;
16+
}
17+
18+
impl Get for f64 {
19+
type Value = u32;
20+
}
21+
22+
impl Other for () {
23+
fn okay<U:Get>(&self, _foo: U, _bar: <Self as Get>::Value) { }
24+
}
25+
26+
impl Other for f64 {
27+
fn okay<U:Get>(&self, _foo: U, _bar: <Self as Get>::Value) { }
28+
}
29+
30+
fn main() { }

src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// run-rustfix
12
// Check that we get an error when you use `<Self as Get>::Value` in
23
// the trait definition even if there is no default method.
34

src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `Self: Get` is not satisfied
2-
--> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:9:5
2+
--> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:10:5
33
|
44
LL | fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-

0 commit comments

Comments
 (0)