From 90339ef18919be0212543a1b1f376c9c62c1d365 Mon Sep 17 00:00:00 2001 From: Piotr Jawniak Date: Sat, 24 May 2014 19:30:25 +0200 Subject: [PATCH] Improve error message for range in match Range allows char and numeric types, but previous error message mentioned only numeric types. --- src/librustc/middle/typeck/check/_match.rs | 3 ++- src/test/compile-fail/match-range-fail.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index df774b21504..cb8de7502fd 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -460,7 +460,8 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) { { // no-op } else if !ty::type_is_numeric(b_ty) && !ty::type_is_char(b_ty) { - tcx.sess.span_err(pat.span, "non-numeric type used in range"); + tcx.sess.span_err(pat.span, + "only char and numeric types are allowed in range"); } else { match valid_range_bounds(fcx.ccx, begin, end) { Some(false) => { diff --git a/src/test/compile-fail/match-range-fail.rs b/src/test/compile-fail/match-range-fail.rs index dc7ebaefd01..5ac1eb8572f 100644 --- a/src/test/compile-fail/match-range-fail.rs +++ b/src/test/compile-fail/match-range-fail.rs @@ -9,7 +9,7 @@ // except according to those terms. //error-pattern: lower range bound -//error-pattern: non-numeric +//error-pattern: only char and numeric types //error-pattern: mismatched types fn main() {