Skip to content

Commit 22aecd3

Browse files
committed
clean up issue-21950 (dyn trait cast without assoc type at the cast)
1 parent 8ee3a08 commit 22aecd3

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

tests/ui/issues/issue-21950.rs

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! Tests that compiler yields error E0191 when value with existing trait implementation
2+
//! is cast as same `dyn` trait without specifying associated type at the cast.
3+
//!
4+
//! # Context
5+
//! Original issue: https://github.com/rust-lang/rust/issues/21950
6+
7+
trait Add<Rhs=Self> {
8+
type Output;
9+
}
10+
11+
impl Add for i32 {
12+
type Output = i32;
13+
}
14+
15+
fn main() {
16+
let x = &10 as &dyn Add<i32, Output = i32>; //OK
17+
let x = &10 as &dyn Add;
18+
//~^ ERROR E0191
19+
}

tests/ui/issues/issue-21950.stderr renamed to tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0191]: the value of the associated type `Output` in `Add` must be specified
2-
--> $DIR/issue-21950.rs:10:25
2+
--> $DIR/cast-as-dyn-trait-wo-assoc-type-issue-21950.rs:17:25
33
|
44
LL | type Output;
55
| ----------- `Output` defined here

0 commit comments

Comments
 (0)