From c25b44bee96e4489dab8f44409ba347bfeb328b9 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Wed, 6 Nov 2024 21:10:31 +0000 Subject: Fold `PatKind::NamedConstant` into `PatKind::Constant` --- compiler/rustc_middle/src/thir.rs | 9 ++------- compiler/rustc_middle/src/thir/visit.rs | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'compiler/rustc_middle/src') diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 821f8c99704..84f5f3a4611 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -640,7 +640,6 @@ impl<'tcx> Pat<'tcx> { | Range(..) | Binding { subpattern: None, .. } | Constant { .. } - | NamedConstant { .. } | Error(_) => {} AscribeUserType { subpattern, .. } | Binding { subpattern: Some(subpattern), .. } @@ -787,12 +786,8 @@ pub enum PatKind<'tcx> { /// * `String`, if `string_deref_patterns` is enabled. Constant { value: mir::Const<'tcx>, - }, - - /// Same as `Constant`, but that came from a `const` that we can point at in diagnostics. - NamedConstant { - value: mir::Const<'tcx>, - span: Span, + /// The `const` item this constant came from, if any. + opt_def: Option, }, /// Inline constant found while lowering a pattern. diff --git a/compiler/rustc_middle/src/thir/visit.rs b/compiler/rustc_middle/src/thir/visit.rs index 759ed77dbcb..92c0add65ba 100644 --- a/compiler/rustc_middle/src/thir/visit.rs +++ b/compiler/rustc_middle/src/thir/visit.rs @@ -246,7 +246,7 @@ pub fn walk_pat<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>( visitor.visit_pat(&subpattern.pattern); } } - Constant { value: _ } | NamedConstant { value: _, span: _ } => {} + Constant { value: _, opt_def: _ } => {} InlineConstant { def: _, subpattern } => visitor.visit_pat(subpattern), Range(_) => {} Slice { prefix, slice, suffix } | Array { prefix, slice, suffix } => { -- cgit 1.4.1-3-g733a5