diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2016-06-22 09:51:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-22 09:51:08 +0100 |
| commit | c295a1c7c28e6ff0b83967c065cc00a13f373aa1 (patch) | |
| tree | ec321c6bc148ce6d5e2c4d95d402ff81ce4bf0f3 /src | |
| parent | 0c94e902334c8ad47c44dc725ad5109050a1470e (diff) | |
| parent | 0de72bba3634efb9d7b637b274c8f2ec1a335bf4 (diff) | |
| download | rust-c295a1c7c28e6ff0b83967c065cc00a13f373aa1.tar.gz rust-c295a1c7c28e6ff0b83967c065cc00a13f373aa1.zip | |
Rollup merge of #34394 - oli-obk:const_cast_false_positive, r=eddyb
don't warn on casting byte strs to slices r? @durka
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_const_eval/eval.rs | 1 | ||||
| -rw-r--r-- | src/test/run-pass/const-byte-str-cast.rs | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index 7551bc5c234..34dce440048 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -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), diff --git a/src/test/run-pass/const-byte-str-cast.rs b/src/test/run-pass/const-byte-str-cast.rs new file mode 100644 index 00000000000..2f265b9112b --- /dev/null +++ b/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]; +} |
