about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-30 22:36:40 +0200
committerGitHub <noreply@github.com>2025-04-30 22:36:40 +0200
commit372b15e55e5573e92ba2ff65d4df1821299fe998 (patch)
tree5262952c5c7a821fc1fb78d6b928f54c1e9d5412 /tests/ui
parent6769d323167954d2277fe20b9efc4d0e0912f165 (diff)
parentbe906131de0079173048194c368ebefaa5e426d4 (diff)
downloadrust-372b15e55e5573e92ba2ff65d4df1821299fe998.tar.gz
rust-372b15e55e5573e92ba2ff65d4df1821299fe998.zip
Rollup merge of #140467 - BoxyUwU:no_fcw_assoc_consts, r=lcnr
Don't FCW assoc consts in patterns

Fixes #140447

See comment in added test. We could also check that the anon const is a const arg by looking at the HIR. I'm not sure that's necessary though :thinking: The only consts that are evaluated "for the type system" are const args (which *should* get FCWs) and const patterns (which cant be anon consts afaik).
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/const-generics/const_eval_unchecked_doesnt_fire_patterns.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/const-generics/const_eval_unchecked_doesnt_fire_patterns.rs b/tests/ui/const-generics/const_eval_unchecked_doesnt_fire_patterns.rs
new file mode 100644
index 00000000000..fae2d16f430
--- /dev/null
+++ b/tests/ui/const-generics/const_eval_unchecked_doesnt_fire_patterns.rs
@@ -0,0 +1,23 @@
+//@ check-pass
+
+// Previously the `CONST_EVALUATABLE_UNCHECKED` FCW would fire on const evaluation of
+// associated consts. This is unnecessary as the FCW only needs to apply for repeat expr
+// counts which are anon consts with generic parameters provided. #140447
+
+pub struct Foo<const N: usize>;
+
+impl<const N: usize> Foo<N> {
+    const UNUSED_PARAM: usize = {
+        let _: [(); N];
+        3
+    };
+
+    pub fn bar() {
+        match 1 {
+            Self::UNUSED_PARAM => (),
+            _ => (),
+        }
+    }
+}
+
+fn main() {}