Skip to content

Commit

Permalink
Auto merge of #1374 - divergentdave:InvalidUndefBytes, r=RalfJung
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed May 22, 2020
2 parents 2bb96ff + 58bc218 commit f7170a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c60b675e280fedded8d8487acd051cd342e486f2
a9ca1ec9280ca1e5020edd699917c3367a30a798
18 changes: 11 additions & 7 deletions src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,17 @@ pub fn report_error<'tcx, 'mir>(
report_msg(ecx, &format!("{}: {}", title, msg), msg, helps, true);

// Extra output to help debug specific issues.
if let UndefinedBehavior(UndefinedBehaviorInfo::InvalidUninitBytes(Some(ptr))) = e.kind {
eprintln!(
"Uninitialized read occurred at offset 0x{:x} into this allocation:",
ptr.offset.bytes(),
);
ecx.memory.dump_alloc(ptr.alloc_id);
eprintln!();
match e.kind {
UndefinedBehavior(UndefinedBehaviorInfo::InvalidUninitBytes(Some(access))) => {
eprintln!(
"Uninitialized read occurred at offsets 0x{:x}..0x{:x} into this allocation:",
access.uninit_ptr.offset.bytes(),
access.uninit_ptr.offset.bytes() + access.uninit_size.bytes(),
);
ecx.memory.dump_alloc(access.uninit_ptr.alloc_id);
eprintln!();
}
_ => {}
}

None
Expand Down
2 changes: 1 addition & 1 deletion tests/compile-fail/uninit_buffer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// error-pattern: reading uninitialized memory
// error-pattern: 12 bytes are uninitialized

use std::alloc::{alloc, dealloc, Layout};
use std::slice::from_raw_parts;
Expand Down

0 comments on commit f7170a6

Please sign in to comment.