Skip to content

Commit

Permalink
don't warn on casting byte strs to slices
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jun 21, 2016
1 parent 4ba60ab commit 0de72bb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/librustc_const_eval/eval.rs
Expand Up @@ -1116,6 +1116,7 @@ fn cast_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, val: ConstVal, ty: ty::Ty)
ty::TyRawPtr(_) => {
Err(ErrKind::UnimplementedConstVal("casting a bytestr to a raw ptr"))
},
ty::TyRef(..) => Err(ErrKind::UnimplementedConstVal("casting a bytestr to slice")),
_ => Err(CannotCast),
},
_ => Err(CannotCast),
Expand Down
15 changes: 15 additions & 0 deletions src/test/run-pass/const-byte-str-cast.rs
@@ -0,0 +1,15 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[deny(warnings)]

pub fn main() {
let _ = b"x" as &[u8];
}

0 comments on commit 0de72bb

Please sign in to comment.