about summary refs log tree commit diff
diff options
context:
space:
mode:
authoromskscream <golovkov93@gmail.com>2025-09-14 01:18:18 +0300
committeromskscream <golovkov93@gmail.com>2025-09-14 12:16:34 +0300
commit22aecd3001038d0ac00ecd06985e2b0abc57e6dc (patch)
treebe14b34dcc2b2f6705dccb7e5b7388dffda15f2b
parent8ee3a08b871f8b24075f67eda06330f7005cd435 (diff)
downloadrust-22aecd3001038d0ac00ecd06985e2b0abc57e6dc.tar.gz
rust-22aecd3001038d0ac00ecd06985e2b0abc57e6dc.zip
clean up issue-21950 (dyn trait cast without assoc type at the cast)
-rw-r--r--tests/ui/issues/issue-21950.rs12
-rw-r--r--tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.rs19
-rw-r--r--tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.stderr (renamed from tests/ui/issues/issue-21950.stderr)2
3 files changed, 20 insertions, 13 deletions
diff --git a/tests/ui/issues/issue-21950.rs b/tests/ui/issues/issue-21950.rs
deleted file mode 100644
index 7a85ac91bca..00000000000
--- a/tests/ui/issues/issue-21950.rs
+++ /dev/null
@@ -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
-}
diff --git a/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.rs b/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.rs
new file mode 100644
index 00000000000..3c381505450
--- /dev/null
+++ b/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.rs
@@ -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
+}
diff --git a/tests/ui/issues/issue-21950.stderr b/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.stderr
index 24230cfe17f..5f4974e6f23 100644
--- a/tests/ui/issues/issue-21950.stderr
+++ b/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.stderr
@@ -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