From c75685bef621a062a44110bed52b95cf7ce1beb7 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 7 Nov 2019 12:09:05 +0000 Subject: [PATCH] Note link between apply/specialize/arity functions --- src/librustc_mir/hair/pattern/_match.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 84a3923c7b29..c7607ae95811 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -786,6 +786,8 @@ impl<'tcx> Constructor<'tcx> { } /// This returns one wildcard pattern for each argument to this constructor. + /// + /// This must be consistent with `apply`, `specialize_one_pattern` and `arity`. fn wildcard_subpatterns<'a>( &self, cx: &MatchCheckCtxt<'a, 'tcx>, @@ -862,6 +864,8 @@ impl<'tcx> Constructor<'tcx> { /// /// For instance, a tuple pattern `(_, 42, Some([]))` has the arity of 3. /// A struct pattern's arity is the number of fields it contains, etc. + /// + /// This must be consistent with `wildcard_subpatterns`, `specialize_one_pattern` and `apply`. fn arity<'a>(&self, cx: &MatchCheckCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> u64 { debug!("Constructor::arity({:#?}, {:?})", self, ty); match self { @@ -883,6 +887,8 @@ impl<'tcx> Constructor<'tcx> { /// Apply a constructor to a list of patterns, yielding a new pattern. `pats` /// must have as many elements as this constructor's arity. /// + /// This must be consistent with `wildcard_subpatterns`, `specialize_one_pattern` and `arity`. + /// /// Examples: /// `self`: `Constructor::Single` /// `ty`: `(u32, u32, u32)`