Note link between apply/specialize/arity functions

This commit is contained in:
Nadrieril 2019-11-07 12:09:05 +00:00
parent ce36ab2b06
commit c75685bef6

View file

@ -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)`