Skip to content

Commit 0de72bb

Browse files
committed
don't warn on casting byte strs to slices
1 parent 4ba60ab commit 0de72bb

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/librustc_const_eval/eval.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,7 @@ fn cast_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, val: ConstVal, ty: ty::Ty)
11161116
ty::TyRawPtr(_) => {
11171117
Err(ErrKind::UnimplementedConstVal("casting a bytestr to a raw ptr"))
11181118
},
1119+
ty::TyRef(..) => Err(ErrKind::UnimplementedConstVal("casting a bytestr to slice")),
11191120
_ => Err(CannotCast),
11201121
},
11211122
_ => Err(CannotCast),
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[deny(warnings)]
12+
13+
pub fn main() {
14+
let _ = b"x" as &[u8];
15+
}

0 commit comments

Comments
 (0)