Skip to content

Commit 3efddfc

Browse files
committed
---
yaml --- r: 235849 b: refs/heads/stable c: 19512be h: refs/heads/master i: 235847: 65cf906 v: v3
1 parent 0c98376 commit 3efddfc

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: adfdbc4bd75f2581e9ad0151b26fb786b64475f8
32+
refs/heads/stable: 19512be11376a17f6c73fb28facad1f0d9f9cefb
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/librustc/middle/check_match.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,12 +1016,8 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
10161016
fn check_local(cx: &mut MatchCheckCtxt, loc: &ast::Local) {
10171017
visit::walk_local(cx, loc);
10181018

1019-
let mut static_inliner = StaticInliner::new(cx.tcx, None);
1020-
is_refutable(cx, &*static_inliner.fold_pat(loc.pat.clone()), |pat| {
1021-
span_err!(cx.tcx.sess, loc.pat.span, E0005,
1022-
"refutable pattern in local binding: `{}` not covered", pat_to_string(pat)
1023-
);
1024-
});
1019+
let pat = StaticInliner::new(cx.tcx, None).fold_pat(loc.pat.clone());
1020+
check_irrefutable(cx, &pat, false);
10251021

10261022
// Check legality of move bindings and `@` patterns.
10271023
check_legality_of_move_bindings(cx, false, slice::ref_slice(&loc.pat));
@@ -1042,17 +1038,28 @@ fn check_fn(cx: &mut MatchCheckCtxt,
10421038
visit::walk_fn(cx, kind, decl, body, sp);
10431039

10441040
for input in &decl.inputs {
1045-
is_refutable(cx, &*input.pat, |pat| {
1046-
span_err!(cx.tcx.sess, input.pat.span, E0005,
1047-
"refutable pattern in function argument: `{}` not covered",
1048-
pat_to_string(pat)
1049-
);
1050-
});
1041+
check_irrefutable(cx, &input.pat, true);
10511042
check_legality_of_move_bindings(cx, false, slice::ref_slice(&input.pat));
10521043
check_legality_of_bindings_in_at_patterns(cx, &*input.pat);
10531044
}
10541045
}
10551046

1047+
fn check_irrefutable(cx: &MatchCheckCtxt, pat: &Pat, is_fn_arg: bool) {
1048+
let origin = if is_fn_arg {
1049+
"function argument"
1050+
} else {
1051+
"local binding"
1052+
};
1053+
1054+
is_refutable(cx, pat, |uncovered_pat| {
1055+
span_err!(cx.tcx.sess, pat.span, E0005,
1056+
"refutable pattern in {}: `{}` not covered",
1057+
origin,
1058+
pat_to_string(uncovered_pat),
1059+
);
1060+
});
1061+
}
1062+
10561063
fn is_refutable<A, F>(cx: &MatchCheckCtxt, pat: &Pat, refutable: F) -> Option<A> where
10571064
F: FnOnce(&Pat) -> A,
10581065
{

0 commit comments

Comments
 (0)