about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-05-11 09:24:45 +0000
committerbors <bors@rust-lang.org>2019-05-11 09:24:45 +0000
commitaf39a1fd73de7f4b9c895d3377e03f8fa3221449 (patch)
tree1dca4bf55864e9c2fc95391236b26b737a07d834 /src/test
parentb8e0d0a2aa4f18d76a701150fccb67533f377368 (diff)
parentb3207d531d01c1dc6c1f3d4e7b1c20a1546fe108 (diff)
downloadrust-af39a1fd73de7f4b9c895d3377e03f8fa3221449.tar.gz
rust-af39a1fd73de7f4b9c895d3377e03f8fa3221449.zip
Auto merge of #60717 - varkor:impl-const-generic, r=matthewjasper
Fix a bug preventing const parameters from being used in const generic impls

Fixes https://github.com/rust-lang/rust/issues/60712.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/const-generics/impl-const-generic-struct.rs16
-rw-r--r--src/test/ui/const-generics/impl-const-generic-struct.stderr6
2 files changed, 22 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/impl-const-generic-struct.rs b/src/test/ui/const-generics/impl-const-generic-struct.rs
new file mode 100644
index 00000000000..7a0c0f2be5d
--- /dev/null
+++ b/src/test/ui/const-generics/impl-const-generic-struct.rs
@@ -0,0 +1,16 @@
+// run-pass
+
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+struct S<const X: u32>;
+
+impl<const X: u32> S<{X}> {
+    fn x() -> u32 {
+        X
+    }
+}
+
+fn main() {
+    assert_eq!(S::<19>::x(), 19);
+}
diff --git a/src/test/ui/const-generics/impl-const-generic-struct.stderr b/src/test/ui/const-generics/impl-const-generic-struct.stderr
new file mode 100644
index 00000000000..d443e060a97
--- /dev/null
+++ b/src/test/ui/const-generics/impl-const-generic-struct.stderr
@@ -0,0 +1,6 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/impl-const-generic-struct.rs:3:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+