about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorthe8472 <the8472@users.noreply.github.com>2021-09-21 22:54:08 +0200
committerGitHub <noreply@github.com>2021-09-21 22:54:08 +0200
commita3e6c19acf12d5995407220721f4fe28452e51da (patch)
tree273157418d6ab67dbd8f0835a1d6b2ba4f6ce25d /src
parentaca790b3d62784ae6399ac2337a1147ea9aab9b8 (diff)
parent999888c086446c4c43bd5e99d8a0d2a1a7ee0404 (diff)
downloadrust-a3e6c19acf12d5995407220721f4fe28452e51da.tar.gz
rust-a3e6c19acf12d5995407220721f4fe28452e51da.zip
Rollup merge of #89147 - b-naber:refs_in_check_const_value_eq, r=oli-obk
add case for checking const refs in check_const_value_eq

Previously in `check_const_value_eq` we destructured `ConstValue::ByRef` instances, this didn't account for `ty::Ref`s however, which led to an ICE.

Fixes https://github.com/rust-lang/rust/issues/88876
Fixes https://github.com/rust-lang/rust/issues/88384

r? `@oli-obk`
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/consts/refs_check_const_eq-issue-88384.rs25
-rw-r--r--src/test/ui/consts/refs_check_const_eq-issue-88384.stderr11
-rw-r--r--src/test/ui/consts/refs_check_const_value_eq-issue-88876.rs12
3 files changed, 48 insertions, 0 deletions
diff --git a/src/test/ui/consts/refs_check_const_eq-issue-88384.rs b/src/test/ui/consts/refs_check_const_eq-issue-88384.rs
new file mode 100644
index 00000000000..204d18ea25d
--- /dev/null
+++ b/src/test/ui/consts/refs_check_const_eq-issue-88384.rs
@@ -0,0 +1,25 @@
+// check-pass
+
+#![feature(fn_traits)]
+#![feature(adt_const_params)]
+//~^ WARNING the feature `adt_const_params` is incomplete
+
+#[derive(PartialEq, Eq)]
+struct CompileTimeSettings{
+    hooks: &'static[fn()],
+}
+
+struct Foo<const T: CompileTimeSettings>;
+
+impl<const T: CompileTimeSettings> Foo<T> {
+    fn call_hooks(){
+    }
+}
+
+fn main(){
+    const SETTINGS: CompileTimeSettings = CompileTimeSettings{
+        hooks: &[],
+    };
+
+    Foo::<SETTINGS>::call_hooks();
+}
diff --git a/src/test/ui/consts/refs_check_const_eq-issue-88384.stderr b/src/test/ui/consts/refs_check_const_eq-issue-88384.stderr
new file mode 100644
index 00000000000..55928b495b2
--- /dev/null
+++ b/src/test/ui/consts/refs_check_const_eq-issue-88384.stderr
@@ -0,0 +1,11 @@
+warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/refs_check_const_eq-issue-88384.rs:4:12
+   |
+LL | #![feature(adt_const_params)]
+   |            ^^^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+   = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/consts/refs_check_const_value_eq-issue-88876.rs b/src/test/ui/consts/refs_check_const_value_eq-issue-88876.rs
new file mode 100644
index 00000000000..6ce9da43668
--- /dev/null
+++ b/src/test/ui/consts/refs_check_const_value_eq-issue-88876.rs
@@ -0,0 +1,12 @@
+// check-pass
+
+#![allow(incomplete_features)]
+#![feature(adt_const_params)]
+
+struct FooConst<const ARRAY: &'static [&'static str]> {}
+
+const FOO_ARR: &[&'static str; 2] = &["Hello", "Friend"];
+
+fn main() {
+    let _ = FooConst::<FOO_ARR> {};
+}