Rollup merge of #34394 - oli-obk:const_cast_false_positive, r=eddyb

don't warn on casting byte strs to slices

r? @durka
This commit is contained in:
Manish Goregaokar 2016-06-22 09:51:08 +01:00 committed by GitHub
commit c295a1c7c2
2 changed files with 16 additions and 0 deletions

View file

@ -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),

View file

@ -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];
}