Skip to content

Commit af175e0

Browse files
Nadrierilmark-i-m
authored andcommitted
Document Fields a bit
1 parent 9d9d3c9 commit af175e0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/librustc_mir_build/hair/pattern/_match.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,13 @@ impl Slice {
755755
}
756756
}
757757

758+
/// A value can be decomposed into a constructor applied to some fields. This struct represents
759+
/// the constructor. See also `Fields`.
760+
///
761+
/// `pat_constructor` retrieves the constructor corresponding to a pattern.
762+
/// `specialize_one_pattern` returns the list of fields corresponding to a pattern, given a
763+
/// constructor. `Constructor::apply` reconstructs the pattern from a pair of `Constructor` and
764+
/// `Fields`.
758765
#[derive(Clone, Debug, PartialEq)]
759766
enum Constructor<'tcx> {
760767
/// The constructor for patterns that have a single constructor, like tuples, struct patterns
@@ -1107,8 +1114,14 @@ impl<'p, 'tcx> StructFields<'p, 'tcx> {
11071114
}
11081115
}
11091116

1110-
/// A value can be decomposed into a Constructor applied to some Fields. This struct represents
1111-
/// those fields, generalized to allow patterns in each field.
1117+
/// A value can be decomposed into a constructor applied to some fields. This struct represents
1118+
/// those fields, generalized to allow patterns in each field. See also `Constructor`.
1119+
///
1120+
/// In some special cases of uninhabited types, we filter out those fields in the matrix so that
1121+
/// the code can't observe they are uninhabited. But we do need to handle the full list of fields
1122+
/// when going to/from a `Pat`, hence the distinction between filtered and unfiltered fields. As a
1123+
/// rule, when going to/from the matrix, use the filtered fields; when going to/from `Pat`, use the
1124+
/// full fields.
11121125
#[derive(Debug, Clone)]
11131126
enum Fields<'p, 'tcx> {
11141127
/// Fields of a struct, with special handling of uninhabited types.

0 commit comments

Comments
 (0)