about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-11-12 00:59:11 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-11-17 23:40:00 +0000
commitbb37e5d3cd4aace7141f5dfce401f6532cdb4d87 (patch)
tree816f7b671de666dec2d5034246cc1acef182228b
parentf1772d57399272f69fa69ad10ae21d380efc2e7e (diff)
downloadrust-bb37e5d3cd4aace7141f5dfce401f6532cdb4d87.tar.gz
rust-bb37e5d3cd4aace7141f5dfce401f6532cdb4d87.zip
review comments
-rw-r--r--compiler/rustc_middle/src/thir.rs7
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/check_match.rs4
2 files changed, 5 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs
index f37c8486df5..d50d2e19f2d 100644
--- a/compiler/rustc_middle/src/thir.rs
+++ b/compiler/rustc_middle/src/thir.rs
@@ -789,11 +789,14 @@ pub enum PatKind<'tcx> {
     },
 
     /// Inline or named constant found while lowering a pattern.
+    ///
+    /// We only mark patterns referencing constants when they are bare names that could have been
+    /// new bindings if the `const` didn't exist.
     ExpandedConstant {
         /// [DefId] of the constant, we need this so that we have a
         /// reference that can be used by unsafety checking to visit nested
-        /// unevaluated constants. If the `DefId` doesn't correspond to a local
-        /// crate, it points at the `const` item.
+        /// unevaluated constants and for diagnostics. If the `DefId` doesn't
+        /// correspond to a local crate, it points at the `const` item.
         def_id: DefId,
         /// If `false`, then `def_id` points at a `const` item, otherwise it
         /// corresponds to a local inline const.
diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
index 1cab055864d..db0f8a28293 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
@@ -696,10 +696,6 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
                 misc_suggestion = Some(MiscPatternSuggestion::AttemptedIntegerLiteral {
                     start_span: pat.span.shrink_to_lo(),
                 });
-            } else if snippet.chars().all(|c| c.is_alphanumeric() || c == '_') {
-                interpreted_as_const = Some(pat.span);
-                interpreted_as_const_sugg =
-                    Some(InterpretedAsConst { span: pat.span, variable: snippet });
             }
         }