|
1 | | -//! As explained in [`super::usefulness`], values and patterns are made from constructors applied to |
| 1 | +//! As explained in [`crate::usefulness`], values and patterns are made from constructors applied to |
2 | 2 | //! fields. This file defines a `Constructor` enum and various operations to manipulate them. |
3 | 3 | //! |
4 | 4 | //! There are two important bits of core logic in this file: constructor inclusion and constructor |
5 | 5 | //! splitting. Constructor inclusion, i.e. whether a constructor is included in/covered by another, |
6 | 6 | //! is straightforward and defined in [`Constructor::is_covered_by`]. |
7 | 7 | //! |
8 | | -//! Constructor splitting is mentioned in [`super::usefulness`] but not detailed. We describe it |
| 8 | +//! Constructor splitting is mentioned in [`crate::usefulness`] but not detailed. We describe it |
9 | 9 | //! precisely here. |
10 | 10 | //! |
11 | 11 | //! |
12 | 12 | //! |
13 | 13 | //! # Constructor grouping and splitting |
14 | 14 | //! |
15 | | -//! As explained in the corresponding section in [`super::usefulness`], to make usefulness tractable |
| 15 | +//! As explained in the corresponding section in [`crate::usefulness`], to make usefulness tractable |
16 | 16 | //! we need to group together constructors that have the same effect when they are used to |
17 | 17 | //! specialize the matrix. |
18 | 18 | //! |
|
28 | 28 | //! In this example we can restrict specialization to 5 cases: `0..50`, `50..=100`, `101..=150`, |
29 | 29 | //! `151..=200` and `200..`. |
30 | 30 | //! |
31 | | -//! In [`super::usefulness`], we had said that `specialize` only takes value-only constructors. We |
| 31 | +//! In [`crate::usefulness`], we had said that `specialize` only takes value-only constructors. We |
32 | 32 | //! now relax this restriction: we allow `specialize` to take constructors like `0..50` as long as |
33 | 33 | //! we're careful to only do that with constructors that make sense. For example, `specialize(0..50, |
34 | 34 | //! (0..=100, true))` is sensible, but `specialize(50..=200, (0..=100, true))` is not. |
|
40 | 40 | //! - That have no non-trivial intersection with any of the constructors in the column (i.e. they're |
41 | 41 | //! each either disjoint with or covered by any given column constructor). |
42 | 42 | //! |
43 | | -//! We compute this in two steps: first [`ConstructorSet::for_ty`] determines the set of all |
44 | | -//! possible constructors for the type. Then [`ConstructorSet::split`] looks at the column of |
45 | | -//! constructors and splits the set into groups accordingly. The precise invariants of |
| 43 | +//! We compute this in two steps: first [`crate::cx::MatchCheckCtxt::ctors_for_ty`] determines the |
| 44 | +//! set of all possible constructors for the type. Then [`ConstructorSet::split`] looks at the |
| 45 | +//! column of constructors and splits the set into groups accordingly. The precise invariants of |
46 | 46 | //! [`ConstructorSet::split`] is described in [`SplitConstructorSet`]. |
47 | 47 | //! |
48 | 48 | //! Constructor splitting has two interesting special cases: integer range splitting (see |
|
71 | 71 | //! `Wildcard`. |
72 | 72 | //! |
73 | 73 | //! The only place where we care about which constructors `Missing` represents is in diagnostics |
74 | | -//! (see `super::usefulness::WitnessMatrix::apply_constructor`). |
| 74 | +//! (see `crate::usefulness::WitnessMatrix::apply_constructor`). |
75 | 75 | //! |
76 | 76 | //! We choose whether to specialize with `Missing` in |
77 | | -//! `super::usefulness::compute_exhaustiveness_and_reachability`. |
| 77 | +//! `crate::usefulness::compute_exhaustiveness_and_usefulness`. |
78 | 78 | //! |
79 | 79 | //! |
80 | 80 | //! |
|
88 | 88 | //! `exhaustive_patterns` feature is turned on, in which case we do treat them as empty. And also |
89 | 89 | //! except if the type has no constructors (like `enum Void {}` but not like `Result<!, !>`), we |
90 | 90 | //! specifically allow `match void {}` to be exhaustive. There are additionally considerations of |
91 | | -//! place validity that are handled in `super::usefulness`. Yes this is a bit tricky. |
| 91 | +//! place validity that are handled in `crate::usefulness`. Yes this is a bit tricky. |
92 | 92 | //! |
93 | 93 | //! The second thing is that regardless of the above, it is always allowed to use all the |
94 | 94 | //! constructors of a type. For example, all the following is ok: |
|
136 | 136 | //! the algorithm can't distinguish them from a nonempty constructor. The only known case where this |
137 | 137 | //! could happen is the `[..]` pattern on `[!; N]` with `N > 0` so we must take care to not emit it. |
138 | 138 | //! |
139 | | -//! This is all handled by [`ConstructorSet::for_ty`] and [`ConstructorSet::split`]. The invariants |
140 | | -//! of [`SplitConstructorSet`] are also of interest. |
| 139 | +//! This is all handled by [`crate::cx::MatchCheckCtxt::ctors_for_ty`] and |
| 140 | +//! [`ConstructorSet::split`]. The invariants of [`SplitConstructorSet`] are also of interest. |
141 | 141 | //! |
142 | 142 | //! |
143 | 143 | //! |
|
0 commit comments