From 1aa23b8e1cd8611d02aceb86b69ec3559b8d4c2c Mon Sep 17 00:00:00 2001 From: Jakub Wieczorek Date: Sat, 5 Jul 2014 16:22:21 +0200 Subject: [PATCH] Fix #15453 --- src/librustc/middle/check_match.rs | 1 + src/test/run-pass/byte-literals.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 8b5c7061a149f..abc4212dbb247 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -563,6 +563,7 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: ty::t) -> ty::ty_rptr(_, ty::mt { ty: ty, .. }) => match ty::get(ty).sty { ty::ty_vec(_, None) => match *ctor { Slice(length) => length, + ConstantValue(_) => 0u, _ => unreachable!() }, ty::ty_str => 0u, diff --git a/src/test/run-pass/byte-literals.rs b/src/test/run-pass/byte-literals.rs index 1e28c44206ffc..ac470268d319f 100644 --- a/src/test/run-pass/byte-literals.rs +++ b/src/test/run-pass/byte-literals.rs @@ -46,6 +46,13 @@ pub fn main() { _ => fail!(), } + let buf = vec!(97u8, 98, 99, 100); + assert_eq!(match buf.slice(0, 3) { + b"def" => 1u, + b"abc" => 2u, + _ => 3u + }, 2); + assert_eq!(BAZ, &[97u8, 92u8, 110u8]); assert_eq!(br"a\n", &[97u8, 92u8, 110u8]); assert_eq!(br"a\n", b"a\\n");