Skip to content

Commit 8ff4b42

Browse files
committed
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
2 parents c166b03 + 5258871 commit 8ff4b42

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

src/librustc_mir/interpret/eval_context.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -654,21 +654,24 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
654654
if self.type_is_fat_ptr(src.ty) {
655655
match (src.value, self.type_is_fat_ptr(dest_ty)) {
656656
(Value::ByRef { .. }, _) |
657+
// pointers to extern types
658+
(Value::ByVal(_),_) |
659+
// slices and trait objects to other slices/trait objects
657660
(Value::ByValPair(..), true) => {
658661
let valty = ValTy {
659662
value: src.value,
660663
ty: dest_ty,
661664
};
662665
self.write_value(valty, dest)?;
663666
}
667+
// slices and trait objects to thin pointers (dropping the metadata)
664668
(Value::ByValPair(data, _), false) => {
665669
let valty = ValTy {
666670
value: Value::ByVal(data),
667671
ty: dest_ty,
668672
};
669673
self.write_value(valty, dest)?;
670674
}
671-
(Value::ByVal(_), _) => bug!("expected fat ptr"),
672675
}
673676
} else {
674677
let src_layout = self.layout_of(src.ty)?;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-pass
12+
13+
#![feature(extern_types)]
14+
15+
extern {
16+
type Opaque;
17+
}
18+
19+
const FOO: *const u8 = &42 as *const _ as *const Opaque as *const u8;
20+
21+
fn main() {
22+
let _foo = FOO;
23+
}

src/tools/miri

Submodule miri updated from f48fed7 to e0e1bd7

0 commit comments

Comments
 (0)