about summary refs log tree commit diff
path: root/tests/ui/generic-const-items
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2023-12-18 17:55:55 +0100
committerLeón Orell Valerian Liehr <me@fmease.dev>2023-12-27 12:51:32 +0100
commit3eb48a35c8ae8335da66dc2bdb4f60e6ae22e1dd (patch)
treeeadb378f48629728c106252798e74f8faf1bf745 /tests/ui/generic-const-items
parent2fe50cd72c476ebacdedb14893e9632b4de961c2 (diff)
downloadrust-3eb48a35c8ae8335da66dc2bdb4f60e6ae22e1dd.tar.gz
rust-3eb48a35c8ae8335da66dc2bdb4f60e6ae22e1dd.zip
Introduce `const Trait` (always-const trait bounds)
Diffstat (limited to 'tests/ui/generic-const-items')
-rw-r--r--tests/ui/generic-const-items/const-trait-impl.rs18
-rw-r--r--tests/ui/generic-const-items/const-trait-impl.stderr12
2 files changed, 13 insertions, 17 deletions
diff --git a/tests/ui/generic-const-items/const-trait-impl.rs b/tests/ui/generic-const-items/const-trait-impl.rs
index 43cdf818c46..04c3f3eb434 100644
--- a/tests/ui/generic-const-items/const-trait-impl.rs
+++ b/tests/ui/generic-const-items/const-trait-impl.rs
@@ -1,14 +1,12 @@
-// known-bug: #110395
-// FIXME check-pass
+// check-pass
 
 // Test that we can call methods from const trait impls inside of generic const items.
 
-#![feature(generic_const_items, const_trait_impl)]
+#![feature(generic_const_items, const_trait_impl, effects)]
 #![allow(incomplete_features)]
 #![crate_type = "lib"]
 
-// FIXME(generic_const_items, effects): Introduce `const` bounds to make this work.
-const CREATE<T: Create>: T = T::create();
+const CREATE<T: const Create>: T = T::create();
 
 pub const K0: i32 = CREATE::<i32>;
 pub const K1: i32 = CREATE; // arg inferred
@@ -23,3 +21,13 @@ impl const Create for i32 {
         4096
     }
 }
+
+trait Mod { // doesn't need to be a `#[const_trait]`
+    const CREATE<T: const Create>: T;
+}
+
+impl Mod for () {
+    const CREATE<T: const Create>: T = T::create();
+}
+
+pub const K2: i32 = <() as Mod>::CREATE::<i32>;
diff --git a/tests/ui/generic-const-items/const-trait-impl.stderr b/tests/ui/generic-const-items/const-trait-impl.stderr
deleted file mode 100644
index cdcd24eceff..00000000000
--- a/tests/ui/generic-const-items/const-trait-impl.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0015]: cannot call non-const fn `<T as Create>::create` in constants
-  --> $DIR/const-trait-impl.rs:11:30
-   |
-LL | const CREATE<T: Create>: T = T::create();
-   |                              ^^^^^^^^^^^
-   |
-   = note: calls in constants are limited to constant functions, tuple structs and tuple variants
-   = help: add `#![feature(effects)]` to the crate attributes to enable
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0015`.