From b2f903c066185d32bdfc02ff6a35f4e50c54728d Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 7 Sep 2019 16:00:09 +0200 Subject: [PATCH] or-patterns: `hir::Arm::pats` -> `::pat` + `Arm::top_pats_hack`. --- src/librustc/hir/mod.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 2c8590aa4e3..1b32979eda5 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1259,21 +1259,32 @@ pub struct Local { } /// Represents a single arm of a `match` expression, e.g. -/// ` (if ) => `. +/// ` (if ) => `. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct Arm { #[stable_hasher(ignore)] pub hir_id: HirId, pub span: Span, pub attrs: HirVec, - /// Multiple patterns can be combined with `|` - pub pats: HirVec>, + /// If this pattern and the optional guard matches, then `body` is evaluated. + pub pat: P, /// Optional guard clause. pub guard: Option, /// The expression the arm evaluates to if this arm matches. pub body: P, } +impl Arm { + // HACK(or_patterns; Centril | dlrobertson): Remove this and + // correctly handle each case in which this method is used. + pub fn top_pats_hack(&self) -> &[P] { + match &self.pat.node { + PatKind::Or(pats) => pats, + _ => std::slice::from_ref(&self.pat), + } + } +} + #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] pub enum Guard { If(P), -- 2.44.0