about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKalle Wachsmuth <kalle.wachsmuth@gmail.com>2024-02-19 18:16:11 +0100
committerKalle Wachsmuth <kalle.wachsmuth@gmail.com>2024-02-19 18:16:11 +0100
commit7fd7b47c1f79f1f478e71b6a22fc5e0824e2367c (patch)
treea25ff6e8131f3b30e1f5a179adffdf0705e16ed8
parente29a1530f670d66f617f7aac8601920a87263ac6 (diff)
downloadrust-7fd7b47c1f79f1f478e71b6a22fc5e0824e2367c.tar.gz
rust-7fd7b47c1f79f1f478e71b6a22fc5e0824e2367c.zip
regression test for #103369
-rw-r--r--tests/ui/coherence/const-errs-dont-conflict-103369.rs14
-rw-r--r--tests/ui/coherence/const-errs-dont-conflict-103369.stderr39
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/ui/coherence/const-errs-dont-conflict-103369.rs b/tests/ui/coherence/const-errs-dont-conflict-103369.rs
new file mode 100644
index 00000000000..c7d46a8000d
--- /dev/null
+++ b/tests/ui/coherence/const-errs-dont-conflict-103369.rs
@@ -0,0 +1,14 @@
+// #103369: don't complain about conflicting implementations with [const error]
+
+pub trait ConstGenericTrait<const N: u32> {}
+
+impl ConstGenericTrait<{my_fn(1)}> for () {}
+
+impl ConstGenericTrait<{my_fn(2)}> for () {}
+
+const fn my_fn(v: u32) -> u32 {
+    panic!("Some error occurred"); //~ ERROR E0080
+    //~| ERROR E0080
+}
+
+fn main() {}
diff --git a/tests/ui/coherence/const-errs-dont-conflict-103369.stderr b/tests/ui/coherence/const-errs-dont-conflict-103369.stderr
new file mode 100644
index 00000000000..22066d6b6bd
--- /dev/null
+++ b/tests/ui/coherence/const-errs-dont-conflict-103369.stderr
@@ -0,0 +1,39 @@
+error[E0080]: evaluation of constant value failed
+  --> $DIR/const-errs-dont-conflict-103369.rs:10:5
+   |
+LL |     panic!("Some error occurred");
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'Some error occurred', $DIR/const-errs-dont-conflict-103369.rs:10:5
+   |
+note: inside `my_fn`
+  --> $DIR/const-errs-dont-conflict-103369.rs:10:5
+   |
+LL |     panic!("Some error occurred");
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: inside `<() as ConstGenericTrait<{my_fn(1)}>>::{constant#0}`
+  --> $DIR/const-errs-dont-conflict-103369.rs:5:25
+   |
+LL | impl ConstGenericTrait<{my_fn(1)}> for () {}
+   |                         ^^^^^^^^
+   = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation of constant value failed
+  --> $DIR/const-errs-dont-conflict-103369.rs:10:5
+   |
+LL |     panic!("Some error occurred");
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'Some error occurred', $DIR/const-errs-dont-conflict-103369.rs:10:5
+   |
+note: inside `my_fn`
+  --> $DIR/const-errs-dont-conflict-103369.rs:10:5
+   |
+LL |     panic!("Some error occurred");
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: inside `<() as ConstGenericTrait<{my_fn(2)}>>::{constant#0}`
+  --> $DIR/const-errs-dont-conflict-103369.rs:7:25
+   |
+LL | impl ConstGenericTrait<{my_fn(2)}> for () {}
+   |                         ^^^^^^^^
+   = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0080`.