Skip to content

Commit c75685b

Browse files
committed
Note link between apply/specialize/arity functions
1 parent ce36ab2 commit c75685b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/librustc_mir/hair/pattern/_match.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,8 @@ impl<'tcx> Constructor<'tcx> {
786786
}
787787

788788
/// This returns one wildcard pattern for each argument to this constructor.
789+
///
790+
/// This must be consistent with `apply`, `specialize_one_pattern` and `arity`.
789791
fn wildcard_subpatterns<'a>(
790792
&self,
791793
cx: &MatchCheckCtxt<'a, 'tcx>,
@@ -862,6 +864,8 @@ impl<'tcx> Constructor<'tcx> {
862864
///
863865
/// For instance, a tuple pattern `(_, 42, Some([]))` has the arity of 3.
864866
/// A struct pattern's arity is the number of fields it contains, etc.
867+
///
868+
/// This must be consistent with `wildcard_subpatterns`, `specialize_one_pattern` and `apply`.
865869
fn arity<'a>(&self, cx: &MatchCheckCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> u64 {
866870
debug!("Constructor::arity({:#?}, {:?})", self, ty);
867871
match self {
@@ -883,6 +887,8 @@ impl<'tcx> Constructor<'tcx> {
883887
/// Apply a constructor to a list of patterns, yielding a new pattern. `pats`
884888
/// must have as many elements as this constructor's arity.
885889
///
890+
/// This must be consistent with `wildcard_subpatterns`, `specialize_one_pattern` and `arity`.
891+
///
886892
/// Examples:
887893
/// `self`: `Constructor::Single`
888894
/// `ty`: `(u32, u32, u32)`

0 commit comments

Comments
 (0)