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:
commit
c295a1c7c2
2 changed files with 16 additions and 0 deletions
|
|
@ -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),
|
||||
|
|
|
|||
15
src/test/run-pass/const-byte-str-cast.rs
Normal file
15
src/test/run-pass/const-byte-str-cast.rs
Normal 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];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue