clean up issue-21950 (dyn trait cast without assoc type at the cast)

This commit is contained in:
omskscream 2025-09-14 01:18:18 +03:00
parent 8ee3a08b87
commit 22aecd3001
3 changed files with 20 additions and 13 deletions

View file

@ -1,12 +0,0 @@
trait Add<Rhs=Self> {
type Output;
}
impl Add for i32 {
type Output = i32;
}
fn main() {
let x = &10 as &dyn Add;
//~^ ERROR E0191
}

View file

@ -0,0 +1,19 @@
//! Tests that compiler yields error E0191 when value with existing trait implementation
//! is cast as same `dyn` trait without specifying associated type at the cast.
//!
//! # Context
//! Original issue: https://github.com/rust-lang/rust/issues/21950
trait Add<Rhs=Self> {
type Output;
}
impl Add for i32 {
type Output = i32;
}
fn main() {
let x = &10 as &dyn Add<i32, Output = i32>; //OK
let x = &10 as &dyn Add;
//~^ ERROR E0191
}

View file

@ -1,5 +1,5 @@
error[E0191]: the value of the associated type `Output` in `Add` must be specified
--> $DIR/issue-21950.rs:10:25
--> $DIR/cast-as-dyn-trait-wo-assoc-type-issue-21950.rs:17:25
|
LL | type Output;
| ----------- `Output` defined here