summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs')
-rw-r--r--tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs57
1 files changed, 54 insertions, 3 deletions
diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs
index 95f7aaba0..5ecb75094 100644
--- a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs
+++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs
@@ -1,7 +1,58 @@
#![feature(const_trait_impl)]
-#![feature(associated_type_bounds)]
-struct TildeQuestion<T: ~const ?Sized>(std::marker::PhantomData<T>);
-//~^ ERROR `~const` and `?` are mutually exclusive
+#[const_trait]
+trait Trait {}
+
+// Regression test for issue #90052.
+fn non_const_function<T: ~const Trait>() {} //~ ERROR `~const` is not allowed
+
+struct Struct<T: ~const Trait> { field: T } //~ ERROR `~const` is not allowed here
+struct TupleStruct<T: ~const Trait>(T); //~ ERROR `~const` is not allowed here
+struct UnitStruct<T: ~const Trait>; //~ ERROR `~const` is not allowed here
+
+enum Enum<T: ~const Trait> { Variant(T) } //~ ERROR `~const` is not allowed here
+
+union Union<T: ~const Trait> { field: T } //~ ERROR `~const` is not allowed here
+
+type Type<T: ~const Trait> = T; //~ ERROR `~const` is not allowed here
+
+const CONSTANT<T: ~const Trait>: () = (); //~ ERROR `~const` is not allowed here
+//~^ ERROR generic const items are experimental
+
+trait NonConstTrait {
+ type Type<T: ~const Trait>: ~const Trait;
+ //~^ ERROR `~const` is not allowed
+ //~| ERROR `~const` is not allowed
+ fn non_const_function<T: ~const Trait>(); //~ ERROR `~const` is not allowed
+ const CONSTANT<T: ~const Trait>: (); //~ ERROR `~const` is not allowed
+ //~^ ERROR generic const items are experimental
+}
+
+impl NonConstTrait for () {
+ type Type<T: ~const Trait> = (); //~ ERROR `~const` is not allowed
+ fn non_const_function<T: ~const Trait>() {} //~ ERROR `~const` is not allowed
+ const CONSTANT<T: ~const Trait>: () = (); //~ ERROR `~const` is not allowed
+ //~^ ERROR generic const items are experimental
+}
+
+struct Implementor;
+
+impl Implementor {
+ type Type<T: ~const Trait> = (); //~ ERROR `~const` is not allowed
+ //~^ ERROR inherent associated types are unstable
+ fn non_const_function<T: ~const Trait>() {} //~ ERROR `~const` is not allowed
+ const CONSTANT<T: ~const Trait>: () = (); //~ ERROR `~const` is not allowed
+ //~^ ERROR generic const items are experimental
+}
+
+// non-const traits
+trait Child0: ~const Trait {} //~ ERROR `~const` is not allowed
+trait Child1 where Self: ~const Trait {} //~ ERROR `~const` is not allowed
+
+// non-const impl
+impl<T: ~const Trait> Trait for T {} //~ ERROR `~const` is not allowed
+
+// inherent impl (regression test for issue #117004)
+impl<T: ~const Trait> Struct<T> {} //~ ERROR `~const` is not allowed
fn main() {}