Skip to content

Commit 66bb978

Browse files
committed
improve hir::PatKind::Slice docs
1 parent d848ce0 commit 66bb978

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: src/librustc/hir/mod.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1048,8 +1048,15 @@ pub enum PatKind {
10481048
/// A range pattern (e.g., `1..=2` or `1..2`).
10491049
Range(P<Expr>, P<Expr>, RangeEnd),
10501050

1051-
/// `[a, b, ..i, y, z]` is represented as:
1052-
/// `PatKind::Slice(box [a, b], Some(i), box [y, z])`.
1051+
/// A slice pattern, `[before_0, ..., before_n, (slice, after_0, ..., after_n)?]`.
1052+
///
1053+
/// Here, `slice` is lowered from the syntax `($binding_mode $ident @)? ..`.
1054+
/// If `slice` exists, then `after` can be non-empty.
1055+
///
1056+
/// The representation for e.g., `[a, b, .., c, d]` is:
1057+
/// ```
1058+
/// PatKind::Slice([Binding(a), Binding(b)], Some(Wild), [Binding(c), Binding(d)])
1059+
/// ```
10531060
Slice(HirVec<P<Pat>>, Option<P<Pat>>, HirVec<P<Pat>>),
10541061
}
10551062

0 commit comments

Comments
 (0)