Skip to content

Commit 43714ed

Browse files
committed
Fix doc links
1 parent 79806f1 commit 43714ed

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

compiler/rustc_pattern_analysis/src/constructor.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
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
22
//! fields. This file defines a `Constructor` enum and various operations to manipulate them.
33
//!
44
//! There are two important bits of core logic in this file: constructor inclusion and constructor
55
//! splitting. Constructor inclusion, i.e. whether a constructor is included in/covered by another,
66
//! is straightforward and defined in [`Constructor::is_covered_by`].
77
//!
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
99
//! precisely here.
1010
//!
1111
//!
1212
//!
1313
//! # Constructor grouping and splitting
1414
//!
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
1616
//! we need to group together constructors that have the same effect when they are used to
1717
//! specialize the matrix.
1818
//!
@@ -28,7 +28,7 @@
2828
//! In this example we can restrict specialization to 5 cases: `0..50`, `50..=100`, `101..=150`,
2929
//! `151..=200` and `200..`.
3030
//!
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
3232
//! now relax this restriction: we allow `specialize` to take constructors like `0..50` as long as
3333
//! we're careful to only do that with constructors that make sense. For example, `specialize(0..50,
3434
//! (0..=100, true))` is sensible, but `specialize(50..=200, (0..=100, true))` is not.
@@ -40,9 +40,9 @@
4040
//! - That have no non-trivial intersection with any of the constructors in the column (i.e. they're
4141
//! each either disjoint with or covered by any given column constructor).
4242
//!
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
4646
//! [`ConstructorSet::split`] is described in [`SplitConstructorSet`].
4747
//!
4848
//! Constructor splitting has two interesting special cases: integer range splitting (see
@@ -71,10 +71,10 @@
7171
//! `Wildcard`.
7272
//!
7373
//! 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`).
7575
//!
7676
//! We choose whether to specialize with `Missing` in
77-
//! `super::usefulness::compute_exhaustiveness_and_reachability`.
77+
//! `crate::usefulness::compute_exhaustiveness_and_usefulness`.
7878
//!
7979
//!
8080
//!
@@ -88,7 +88,7 @@
8888
//! `exhaustive_patterns` feature is turned on, in which case we do treat them as empty. And also
8989
//! except if the type has no constructors (like `enum Void {}` but not like `Result<!, !>`), we
9090
//! 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.
9292
//!
9393
//! The second thing is that regardless of the above, it is always allowed to use all the
9494
//! constructors of a type. For example, all the following is ok:
@@ -136,8 +136,8 @@
136136
//! the algorithm can't distinguish them from a nonempty constructor. The only known case where this
137137
//! could happen is the `[..]` pattern on `[!; N]` with `N > 0` so we must take care to not emit it.
138138
//!
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.
141141
//!
142142
//!
143143
//!

compiler/rustc_pattern_analysis/src/lints.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ use crate::MatchArm;
1818

1919
/// A column of patterns in the matrix, where a column is the intuitive notion of "subpatterns that
2020
/// inspect the same subvalue/place".
21-
/// This is used to traverse patterns column-by-column for lints. Despite similarities with
22-
/// [`compute_exhaustiveness_and_usefulness`], this does a different traversal. Notably this is
23-
/// linear in the depth of patterns, whereas `compute_exhaustiveness_and_usefulness` is worst-case
24-
/// exponential (exhaustiveness is NP-complete). The core difference is that we treat sub-columns
25-
/// separately.
21+
/// This is used to traverse patterns column-by-column for lints. Despite similarities with the
22+
/// algorithm in [`crate::usefulness`], this does a different traversal. Notably this is linear in
23+
/// the depth of patterns, whereas `compute_exhaustiveness_and_usefulness` is worst-case exponential
24+
/// (exhaustiveness is NP-complete). The core difference is that we treat sub-columns separately.
2625
///
2726
/// This must not contain an or-pattern. `specialize` takes care to expand them.
2827
///

compiler/rustc_pattern_analysis/src/usefulness.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@
9797
//! - `matches!([v0], [p0, .., p1]) := false` (incompatible lengths)
9898
//! - `matches!([v0, v1, v2], [p0, .., p1]) := matches!(v0, p0) && matches!(v2, p1)`
9999
//!
100-
//! Constructors, fields and relevant operations are defined in the [`super::deconstruct_pat`]
101-
//! module. The question of whether a constructor is matched by another one is answered by
100+
//! Constructors and relevant operations are defined in the [`crate::constructor`] module. A
101+
//! representation of patterns that uses constructors is available in [`crate::pat`]. The question
102+
//! of whether a constructor is matched by another one is answered by
102103
//! [`Constructor::is_covered_by`].
103104
//!
104105
//! Note 1: variable bindings (like the `x` in `Some(x)`) match anything, so we treat them as wildcards.
@@ -241,8 +242,8 @@
241242
//! Therefore `usefulness(tp_1, tp_2, tq)` returns the single witness-tuple `[Variant2(Some(true), 0)]`.
242243
//!
243244
//!
244-
//! Computing the set of constructors for a type is done in [`ConstructorSet::for_ty`]. See the
245-
//! following sections for more accurate versions of the algorithm and corresponding links.
245+
//! Computing the set of constructors for a type is done in [`MatchCheckCtxt::ctors_for_ty`]. See
246+
//! the following sections for more accurate versions of the algorithm and corresponding links.
246247
//!
247248
//!
248249
//!
@@ -295,7 +296,7 @@
295296
//! the same reasoning, we only need to try two cases: `North`, and "everything else".
296297
//!
297298
//! We call _constructor splitting_ the operation that computes such a minimal set of cases to try.
298-
//! This is done in [`ConstructorSet::split`] and explained in [`super::deconstruct_pat`].
299+
//! This is done in [`ConstructorSet::split`] and explained in [`crate::constructor`].
299300
//!
300301
//!
301302
//!

0 commit comments

Comments
 (0)