about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-12-07 15:39:08 +0100
committerGitHub <noreply@github.com>2022-12-07 15:39:08 +0100
commitb23419b03da767954ad0fb92ac3be729417cf381 (patch)
treee38f7917b8012e35f7be1aca9e2d46e1f02769b2
parent52cec8c99fd65ff5cf6f2d8b3b19b1300500acbd (diff)
parent9f438bef0b0a1f9249525fc8a1230eaf78753362 (diff)
downloadrust-b23419b03da767954ad0fb92ac3be729417cf381.tar.gz
rust-b23419b03da767954ad0fb92ac3be729417cf381.zip
Rollup merge of #105400 - BoxyUwU:braced_param_evaluatability, r=oli-obk
normalize before handling simple checks for evaluatability of `ty::Const`

`{{{{{{{ N }}}}}}}` is desugared into a `ConstKind::Unevaluated` for an anonymous `const` item so when calling `is_const_evaluatable` on it we skip the `ConstKind::Param(_) => Ok(())` arm which is incorrect.
-rw-r--r--compiler/rustc_trait_selection/src/traits/const_evaluatable.rs2
-rw-r--r--src/test/ui/const-generics/generic_const_exprs/normed_to_param_is_evaluatable.rs12
2 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs
index 7cc0999478a..7c9fde27420 100644
--- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs
+++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs
@@ -30,7 +30,7 @@ pub fn is_const_evaluatable<'tcx>(
     span: Span,
 ) -> Result<(), NotConstEvaluatable> {
     let tcx = infcx.tcx;
-    match unexpanded_ct.kind() {
+    match tcx.expand_abstract_consts(unexpanded_ct).kind() {
         ty::ConstKind::Unevaluated(_) | ty::ConstKind::Expr(_) => (),
         ty::ConstKind::Param(_)
         | ty::ConstKind::Bound(_, _)
diff --git a/src/test/ui/const-generics/generic_const_exprs/normed_to_param_is_evaluatable.rs b/src/test/ui/const-generics/generic_const_exprs/normed_to_param_is_evaluatable.rs
new file mode 100644
index 00000000000..b37b354ae21
--- /dev/null
+++ b/src/test/ui/const-generics/generic_const_exprs/normed_to_param_is_evaluatable.rs
@@ -0,0 +1,12 @@
+// check-pass
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features, unused_braces)]
+
+#[rustfmt::skip]
+fn foo<const N: usize>() {
+    bar::<{{{{{{ N }}}}}}>();
+}
+
+fn bar<const N: usize>() {}
+
+fn main() {}