Skip to content

Commit 10fbdbf

Browse files
committed
Update documentation comment
1 parent 486ecc5 commit 10fbdbf

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/librustc_typeck/check/_match.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,23 @@ use std::cmp;
2020
use super::report_unexpected_variant_def;
2121

2222
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
23-
/// The `is_arg` argument indicates whether this pattern is the
24-
/// *outermost* pattern in an argument (e.g., in `fn foo(&x:
25-
/// &u32)`, it is true for the `&x` pattern but not `x`). This is
26-
/// used to tailor error reporting.
23+
/// `match_discrim_span` argument having a `Span` indicates that this pattern is part of
24+
/// a match expression arm guard, and it points to the match discriminant to add context
25+
/// in type errors. In the folloowing example, `match_discrim_span` corresponds to the
26+
/// `a + b` expression:
27+
///
28+
/// ```text
29+
/// error[E0308]: mismatched types
30+
/// --> src/main.rs:5:9
31+
/// |
32+
/// 4 | let temp: usize = match a + b {
33+
/// | ----- this expression has type `usize`
34+
/// 5 | Ok(num) => num,
35+
/// | ^^^^^^^ expected usize, found enum `std::result::Result`
36+
/// |
37+
/// = note: expected type `usize`
38+
/// found type `std::result::Result<_, _>`
39+
/// ```
2740
pub fn check_pat_walk(
2841
&self,
2942
pat: &'gcx hir::Pat,

0 commit comments

Comments
 (0)