diff options
| author | bors <bors@rust-lang.org> | 2018-05-08 17:20:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-05-08 17:20:01 +0000 |
| commit | 8ff4b42064b374bb62043f7729f84b6d979c7667 (patch) | |
| tree | d0a3eca86ebf257bdbfc8fe5597655165f26e4d6 | |
| parent | c166b0386888b253313e1e7e982a2a06cadaac8b (diff) | |
| parent | 5258871825965b8231b69c080a8c3a0e8c0b8376 (diff) | |
| download | rust-8ff4b42064b374bb62043f7729f84b6d979c7667.tar.gz rust-8ff4b42064b374bb62043f7729f84b6d979c7667.zip | |
Auto merge of #50530 - oli-obk:miri, r=kennytm
Fix thinning pointers to extern types in miri r? @kennytm as an alternative to disabling the miri build fixes #50495
| -rw-r--r-- | src/librustc_mir/interpret/eval_context.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/const-eval/extern_fat_pointer.rs | 23 | ||||
| m--------- | src/tools/miri | 37 |
3 files changed, 46 insertions, 19 deletions
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index f5fd14036c4..d8f13242065 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -654,6 +654,9 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M if self.type_is_fat_ptr(src.ty) { match (src.value, self.type_is_fat_ptr(dest_ty)) { (Value::ByRef { .. }, _) | + // pointers to extern types + (Value::ByVal(_),_) | + // slices and trait objects to other slices/trait objects (Value::ByValPair(..), true) => { let valty = ValTy { value: src.value, @@ -661,6 +664,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M }; self.write_value(valty, dest)?; } + // slices and trait objects to thin pointers (dropping the metadata) (Value::ByValPair(data, _), false) => { let valty = ValTy { value: Value::ByVal(data), @@ -668,7 +672,6 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M }; self.write_value(valty, dest)?; } - (Value::ByVal(_), _) => bug!("expected fat ptr"), } } else { let src_layout = self.layout_of(src.ty)?; diff --git a/src/test/ui/const-eval/extern_fat_pointer.rs b/src/test/ui/const-eval/extern_fat_pointer.rs new file mode 100644 index 00000000000..071311430a8 --- /dev/null +++ b/src/test/ui/const-eval/extern_fat_pointer.rs @@ -0,0 +1,23 @@ +// Copyright 2018 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. + +// compile-pass + +#![feature(extern_types)] + +extern { + type Opaque; +} + +const FOO: *const u8 = &42 as *const _ as *const Opaque as *const u8; + +fn main() { + let _foo = FOO; +} diff --git a/src/tools/miri b/src/tools/miri -Subproject f48fed70d4447445b586a35c4ae88683542ffc7 +Subproject e0e1bd7ff778e5913b566c9e03224faecc0eb48 |
