Skip to content

Commit f7170a6

Browse files
committed
Auto merge of #1374 - divergentdave:InvalidUndefBytes, r=RalfJung
InvalidUndefBytes: Update to match rustc changes This is a companion PR for rust-lang/rust#71610. This won't build yet, but we may need these changes in a future rustup.
2 parents 2bb96ff + 58bc218 commit f7170a6

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c60b675e280fedded8d8487acd051cd342e486f2
1+
a9ca1ec9280ca1e5020edd699917c3367a30a798

src/diagnostics.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,17 @@ pub fn report_error<'tcx, 'mir>(
118118
report_msg(ecx, &format!("{}: {}", title, msg), msg, helps, true);
119119

120120
// Extra output to help debug specific issues.
121-
if let UndefinedBehavior(UndefinedBehaviorInfo::InvalidUninitBytes(Some(ptr))) = e.kind {
122-
eprintln!(
123-
"Uninitialized read occurred at offset 0x{:x} into this allocation:",
124-
ptr.offset.bytes(),
125-
);
126-
ecx.memory.dump_alloc(ptr.alloc_id);
127-
eprintln!();
121+
match e.kind {
122+
UndefinedBehavior(UndefinedBehaviorInfo::InvalidUninitBytes(Some(access))) => {
123+
eprintln!(
124+
"Uninitialized read occurred at offsets 0x{:x}..0x{:x} into this allocation:",
125+
access.uninit_ptr.offset.bytes(),
126+
access.uninit_ptr.offset.bytes() + access.uninit_size.bytes(),
127+
);
128+
ecx.memory.dump_alloc(access.uninit_ptr.alloc_id);
129+
eprintln!();
130+
}
131+
_ => {}
128132
}
129133

130134
None

tests/compile-fail/uninit_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern: reading uninitialized memory
1+
// error-pattern: 12 bytes are uninitialized
22

33
use std::alloc::{alloc, dealloc, Layout};
44
use std::slice::from_raw_parts;

0 commit comments

Comments
 (0)