Skip to content

Commit 712e232

Browse files
committed
---
yaml --- r: 224266 b: refs/heads/beta c: 19512be h: refs/heads/master v: v3
1 parent 42a8e47 commit 712e232

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
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: adfdbc4bd75f2581e9ad0151b26fb786b64475f8
26+
refs/heads/beta: 19512be11376a17f6c73fb28facad1f0d9f9cefb
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 938f5d7af401e2d8238522fed4a612943b6e77fd
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/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)