Skip to content

Commit 4c0cab7

Browse files
committed
auto merge of #15454 : jakub-/rust/15453, r=huonw
I forget we now have byte string literals.
2 parents b7c4493 + 1aa23b8 commit 4c0cab7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/librustc/middle/check_match.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: ty::t) ->
563563
ty::ty_rptr(_, ty::mt { ty: ty, .. }) => match ty::get(ty).sty {
564564
ty::ty_vec(_, None) => match *ctor {
565565
Slice(length) => length,
566+
ConstantValue(_) => 0u,
566567
_ => unreachable!()
567568
},
568569
ty::ty_str => 0u,

src/test/run-pass/byte-literals.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ pub fn main() {
4646
_ => fail!(),
4747
}
4848

49+
let buf = vec!(97u8, 98, 99, 100);
50+
assert_eq!(match buf.slice(0, 3) {
51+
b"def" => 1u,
52+
b"abc" => 2u,
53+
_ => 3u
54+
}, 2);
55+
4956
assert_eq!(BAZ, &[97u8, 92u8, 110u8]);
5057
assert_eq!(br"a\n", &[97u8, 92u8, 110u8]);
5158
assert_eq!(br"a\n", b"a\\n");

0 commit comments

Comments
 (0)