about summary refs log tree commit diff
path: root/tests/ui/generics
diff options
context:
space:
mode:
authorKivooeo <Kivooeo123@gmail.com>2025-06-08 19:09:38 +0500
committerKivooeo <tea@Kivooeos-MacBook-Air.local>2025-06-23 18:53:56 +0500
commit793607059bcd49cbafc3d75f8438b496cd793970 (patch)
tree851a41f888373b2c99bc57361e08436aabe4dab6 /tests/ui/generics
parent8072811356a178dbdf8ca09b1635cfafd4661971 (diff)
downloadrust-793607059bcd49cbafc3d75f8438b496cd793970.tar.gz
rust-793607059bcd49cbafc3d75f8438b496cd793970.zip
cleaned up some tests
Diffstat (limited to 'tests/ui/generics')
-rw-r--r--tests/ui/generics/default-type-params-well-formedness.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/ui/generics/default-type-params-well-formedness.rs b/tests/ui/generics/default-type-params-well-formedness.rs
new file mode 100644
index 00000000000..22b8f5011f7
--- /dev/null
+++ b/tests/ui/generics/default-type-params-well-formedness.rs
@@ -0,0 +1,50 @@
+//! Test for well-formedness checking of default type parameters.
+//!
+//! Regression Test for: https://github.com/rust-lang/rust/issues/49344
+
+//@ run-pass
+
+#![allow(dead_code)]
+
+trait Trait<T> {}
+struct Foo<U, V = i32>(U, V)
+where
+    U: Trait<V>;
+
+trait Marker {}
+struct TwoParams<T, U>(T, U);
+impl Marker for TwoParams<i32, i32> {}
+
+// Clauses with more than 1 param are not checked.
+struct IndividuallyBogus<T = i32, U = i32>(TwoParams<T, U>)
+where
+    TwoParams<T, U>: Marker;
+
+struct BogusTogether<T = u32, U = i32>(T, U)
+where
+    TwoParams<T, U>: Marker;
+
+// Clauses with non-defaulted params are not checked.
+struct NonDefaultedInClause<T, U = i32>(TwoParams<T, U>)
+where
+    TwoParams<T, U>: Marker;
+
+struct DefaultedLhs<U, V = i32>(U, V)
+where
+    V: Trait<U>;
+
+// Dependent defaults are not checked.
+struct Dependent<T, U = T>(T, U)
+where
+    U: Copy;
+
+trait SelfBound<T: Copy = Self> {}
+
+// Not even for well-formedness.
+struct WellFormedProjection<A, T = <A as Iterator>::Item>(A, T);
+
+// Issue #49344, predicates with lifetimes should not be checked.
+trait Scope<'a> {}
+struct Request<'a, S: Scope<'a> = i32>(S, &'a ());
+
+fn main() {}