diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-11-06 21:28:26 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-11-17 23:40:00 +0000 |
| commit | 6dc79f6133d24100cecbcb24e256b9f149d2b47a (patch) | |
| tree | 048ff29e80fe93d338fa602a8c2119010d5b787c /compiler/rustc_mir_build/src | |
| parent | c25b44bee96e4489dab8f44409ba347bfeb328b9 (diff) | |
| download | rust-6dc79f6133d24100cecbcb24e256b9f149d2b47a.tar.gz rust-6dc79f6133d24100cecbcb24e256b9f149d2b47a.zip | |
Use `item_name` instead of a span snippet when talking about const pattern
Diffstat (limited to 'compiler/rustc_mir_build/src')
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/pattern/check_match.rs | 5 |
1 files changed, 2 insertions, 3 deletions
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 f3cfc8b1a22..a8830b346ae 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -675,13 +675,12 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> { subpattern: box Pat { kind: PatKind::Constant { opt_def: Some(def_id), .. }, .. }, .. } = pat.kind - && let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(pat.span) { let span = self.tcx.def_span(def_id); + let variable = self.tcx.item_name(def_id).to_string(); // When we encounter a constant as the binding name, point at the `const` definition. interpreted_as_const = Some(span); - interpreted_as_const_sugg = - Some(InterpretedAsConst { span: pat.span, variable: snippet }); + interpreted_as_const_sugg = Some(InterpretedAsConst { span: pat.span, variable }); } else if let PatKind::Constant { .. } | PatKind::AscribeUserType { subpattern: box Pat { kind: PatKind::Constant { .. }, .. }, |
