about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorJana Dönszelmann <jonathan@donsz.nl>2025-09-17 20:29:35 +0200
committerGitHub <noreply@github.com>2025-09-17 20:29:35 +0200
commit1c1d5c71e0ab458ba3d3ae215dfa79f8666070c3 (patch)
tree95ee15f6c9970f4ab23d68fc2cf39b218e53e115 /tests
parent802343fa47c942ae75523c7e05360e0c88b37f7d (diff)
parent22aecd3001038d0ac00ecd06985e2b0abc57e6dc (diff)
downloadrust-1c1d5c71e0ab458ba3d3ae215dfa79f8666070c3.tar.gz
rust-1c1d5c71e0ab458ba3d3ae215dfa79f8666070c3.zip
Rollup merge of #146536 - omskscream:#133895/clean-ui-tests, r=davidtwco
clean up several trait related UI tests

Part of rust-lang/rust#133895
Cleaned up several `issue-xxxx` trait related tests from `/tests/ui/issues`, one commit per issue for review. Will squash them once approved.

Related issues:
rust-lang/rust#19479
rust-lang/rust#2284
rust-lang/rust#18088
rust-lang/rust#21950
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/issues/issue-18088.rs8
-rw-r--r--tests/ui/issues/issue-21950.rs12
-rw-r--r--tests/ui/issues/issue-2284.rs13
-rw-r--r--tests/ui/traits/associated_type_bound/assoc-type-via-another-trait-issue-19479.rs (renamed from tests/ui/issues/issue-19479.rs)6
-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
-rw-r--r--tests/ui/traits/core-marker-name-shadowing-issue-2284.rs21
-rw-r--r--tests/ui/traits/inheritance/supertrait-operator-issue-18088.rs13
8 files changed, 60 insertions, 34 deletions
diff --git a/tests/ui/issues/issue-18088.rs b/tests/ui/issues/issue-18088.rs
deleted file mode 100644
index ba198884c63..00000000000
--- a/tests/ui/issues/issue-18088.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-//@ check-pass
-
-pub trait Indexable<T>: std::ops::Index<usize, Output = T> {
-    fn index2(&self, i: usize) -> &T {
-        &self[i]
-    }
-}
-fn main() {}
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/issues/issue-2284.rs b/tests/ui/issues/issue-2284.rs
deleted file mode 100644
index 358331ecd9a..00000000000
--- a/tests/ui/issues/issue-2284.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-//@ run-pass
-#![allow(dead_code)]
-
-trait Send {
-    fn f(&self);
-}
-
-fn f<T:Send>(t: T) {
-    t.f();
-}
-
-pub fn main() {
-}
diff --git a/tests/ui/issues/issue-19479.rs b/tests/ui/traits/associated_type_bound/assoc-type-via-another-trait-issue-19479.rs
index ed586b76550..f17a89bcb5f 100644
--- a/tests/ui/issues/issue-19479.rs
+++ b/tests/ui/traits/associated_type_bound/assoc-type-via-another-trait-issue-19479.rs
@@ -1,5 +1,11 @@
 //@ check-pass
 
+//! Tests that it's possible to define an associated type in a trait
+//! using an associated type from type parameter bound trait in a blanket implementation.
+//!
+//! # Context
+//! Original issue: https://github.com/rust-lang/rust/issues/19479
+
 trait Base {
     fn dummy(&self) { }
 }
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
diff --git a/tests/ui/traits/core-marker-name-shadowing-issue-2284.rs b/tests/ui/traits/core-marker-name-shadowing-issue-2284.rs
new file mode 100644
index 00000000000..e5d083ac8c3
--- /dev/null
+++ b/tests/ui/traits/core-marker-name-shadowing-issue-2284.rs
@@ -0,0 +1,21 @@
+//@ run-pass
+#![allow(dead_code)]
+
+//! Tests that user-defined trait is prioritized in compile time over
+//! the core::marker trait with the same name, allowing shadowing core traits.
+//!
+//! # Context
+//! Original issue: https://github.com/rust-lang/rust/issues/2284
+//! Original fix pull request: https://github.com/rust-lang/rust/pull/3792
+
+
+trait Send {
+    fn f(&self);
+}
+
+fn f<T:Send>(t: T) {
+    t.f();
+}
+
+pub fn main() {
+}
diff --git a/tests/ui/traits/inheritance/supertrait-operator-issue-18088.rs b/tests/ui/traits/inheritance/supertrait-operator-issue-18088.rs
new file mode 100644
index 00000000000..8bd45cd54a4
--- /dev/null
+++ b/tests/ui/traits/inheritance/supertrait-operator-issue-18088.rs
@@ -0,0 +1,13 @@
+//@ check-pass
+
+//! Tests that operators from supertrait are available directly on `self` for an inheritor trait.
+//!
+//! # Context
+//! Original issue: https://github.com/rust-lang/rust/issues/18088
+
+pub trait Indexable<T>: std::ops::Index<usize, Output = T> {
+    fn index2(&self, i: usize) -> &T {
+        &self[i]
+    }
+}
+fn main() {}