Skip to content

Commit fbf0831

Browse files
committed
Auto merge of #3224 - rust-lang:rustup-2023-12-14, r=saethlin
Automatic Rustup
2 parents 2f14e10 + 6be3bc3 commit fbf0831

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e2a3c9b3f0895c866c104bd2fff2a8bf16eaf964
1+
e6d1b0ec9859e6f5c29aaa3b6525fb625bf354ad

src/bin/miri.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
144144
// Otherwise it may cause unexpected behaviours and ICEs
145145
// (https://github.com/rust-lang/rust/issues/86261).
146146
let is_reachable_non_generic = matches!(
147-
tcx.hir().get(tcx.local_def_id_to_hir_id(local_def_id)),
147+
tcx.hir_node_by_def_id(local_def_id),
148148
Node::Item(&hir::Item {
149149
kind: hir::ItemKind::Static(..) | hir::ItemKind::Fn(..),
150150
..
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#![feature(extern_types)]
2+
3+
extern "C" {
4+
type Opaque;
5+
}
6+
7+
struct Newtype(Opaque);
8+
9+
struct S {
10+
i: i32,
11+
j: i32,
12+
a: Newtype,
13+
}
14+
15+
fn main() {
16+
let buf = [0i32; 4];
17+
18+
let x: &Newtype = unsafe { &*(&buf as *const _ as *const Newtype) };
19+
// Projecting to the newtype works, because it is always at offset 0.
20+
let _field = &x.0;
21+
22+
let x: &S = unsafe { &*(&buf as *const _ as *const S) };
23+
// Accessing sized fields is perfectly fine, even at non-zero offsets.
24+
let _field = &x.i;
25+
let _field = &x.j;
26+
// This needs to compute the field offset, but we don't know the type's alignment,
27+
// so this panics.
28+
let _field = &x.a; //~ERROR: does not have a known offset
29+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: unsupported operation: `extern type` does not have a known offset
2+
--> $DIR/extern-type-field-offset.rs:LL:CC
3+
|
4+
LL | let _field = &x.a;
5+
| ^^^^ `extern type` does not have a known offset
6+
|
7+
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
8+
= note: BACKTRACE:
9+
= note: inside `main` at $DIR/extern-type-field-offset.rs:LL:CC
10+
11+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
12+
13+
error: aborting due to 1 previous error
14+

0 commit comments

Comments
 (0)