Skip to content

Commit f0f0395

Browse files
committed
Auto merge of #3197 - RalfJung:rustup, r=RalfJung
Rustup also move some fail tests into suitable subdirectories
2 parents 277fec7 + 1497e2e commit f0f0395

19 files changed

+56
-38
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
48cfbe0cdfbc812a9bd8ce0b3bf6ca003bd12e6a
1+
c52b8763bf36027f24baabe1f97cab3d3571c9e5

src/shims/unix/fs.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ pub trait FileDescriptor: std::fmt::Debug + Any {
6666
fn is_tty(&self, _communicate_allowed: bool) -> bool {
6767
false
6868
}
69-
70-
#[cfg(unix)]
71-
fn as_unix_host_fd(&self) -> Option<i32> {
72-
None
73-
}
7469
}
7570

7671
impl dyn FileDescriptor {
@@ -150,12 +145,6 @@ impl FileDescriptor for FileHandle {
150145
Ok(Box::new(FileHandle { file: duplicated, writable: self.writable }))
151146
}
152147

153-
#[cfg(unix)]
154-
fn as_unix_host_fd(&self) -> Option<i32> {
155-
use std::os::unix::io::AsRawFd;
156-
Some(self.file.as_raw_fd())
157-
}
158-
159148
fn is_tty(&self, communicate_allowed: bool) -> bool {
160149
communicate_allowed && self.file.is_terminal()
161150
}
@@ -183,11 +172,6 @@ impl FileDescriptor for io::Stdin {
183172
Ok(Box::new(io::stdin()))
184173
}
185174

186-
#[cfg(unix)]
187-
fn as_unix_host_fd(&self) -> Option<i32> {
188-
Some(libc::STDIN_FILENO)
189-
}
190-
191175
fn is_tty(&self, communicate_allowed: bool) -> bool {
192176
communicate_allowed && self.is_terminal()
193177
}
@@ -220,11 +204,6 @@ impl FileDescriptor for io::Stdout {
220204
Ok(Box::new(io::stdout()))
221205
}
222206

223-
#[cfg(unix)]
224-
fn as_unix_host_fd(&self) -> Option<i32> {
225-
Some(libc::STDOUT_FILENO)
226-
}
227-
228207
fn is_tty(&self, communicate_allowed: bool) -> bool {
229208
communicate_allowed && self.is_terminal()
230209
}
@@ -250,11 +229,6 @@ impl FileDescriptor for io::Stderr {
250229
Ok(Box::new(io::stderr()))
251230
}
252231

253-
#[cfg(unix)]
254-
fn as_unix_host_fd(&self) -> Option<i32> {
255-
Some(libc::STDERR_FILENO)
256-
}
257-
258232
fn is_tty(&self, communicate_allowed: bool) -> bool {
259233
communicate_allowed && self.is_terminal()
260234
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![feature(core_intrinsics)]
2+
#![feature(custom_mir)]
3+
4+
use std::intrinsics::mir::*;
5+
use std::ptr;
6+
7+
#[repr(C)]
8+
struct S(u8, u16);
9+
10+
#[custom_mir(dialect = "runtime", phase = "optimized")]
11+
fn main() {
12+
mir! {
13+
let s: S;
14+
let sptr;
15+
let sptr2;
16+
let _val;
17+
{
18+
sptr = ptr::addr_of_mut!(s);
19+
sptr2 = sptr as *mut [u8; 4];
20+
*sptr2 = [0; 4];
21+
*sptr = S(0, 0); // should reset the padding
22+
_val = *sptr2; // should hence be UB
23+
//~^ERROR: encountered uninitialized memory
24+
Return()
25+
}
26+
}
27+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: constructing invalid value at [1]: encountered uninitialized memory, but expected an integer
2+
--> $DIR/uninit-after-aggregate-assign.rs:LL:CC
3+
|
4+
LL | _val = *sptr2; // should hence be UB
5+
| ^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized memory, but expected an integer
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at $DIR/uninit-after-aggregate-assign.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to 1 previous error
15+

tests/fail/uninit_buffer.rs renamed to tests/fail/uninit/uninit_alloc_diagnostic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@compile-flags: -Zmiri-disable-validation
12
//@error-in-other-file: memory is uninitialized at [0x4..0x10]
23

34
#![allow(dropping_copy_types)]

tests/fail/uninit_buffer.stderr renamed to tests/fail/uninit/uninit_alloc_diagnostic.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | let mut order = unsafe { compare_bytes(left.as_ptr(), right.as_ptr(
1010
= note: inside `<u8 as core::slice::cmp::SliceOrd>::compare` at RUSTLIB/core/src/slice/cmp.rs:LL:CC
1111
= note: inside `core::slice::cmp::<impl std::cmp::Ord for [u8]>::cmp` at RUSTLIB/core/src/slice/cmp.rs:LL:CC
1212
note: inside `main`
13-
--> $DIR/uninit_buffer.rs:LL:CC
13+
--> $DIR/uninit_alloc_diagnostic.rs:LL:CC
1414
|
1515
LL | drop(slice1.cmp(slice2));
1616
| ^^^^^^^^^^^^^^^^^^

tests/fail/uninit_buffer_with_provenance.rs renamed to tests/fail/uninit/uninit_alloc_diagnostic_with_provenance.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@compile-flags: -Zmiri-disable-validation
12
//@error-in-other-file: memory is uninitialized at [0x4..0x8]
23
//@normalize-stderr-test: "a[0-9]+" -> "ALLOC"
34
#![feature(strict_provenance)]

tests/fail/uninit_buffer_with_provenance.stderr renamed to tests/fail/uninit/uninit_alloc_diagnostic_with_provenance.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | let mut order = unsafe { compare_bytes(left.as_ptr(), right.as_ptr(
1010
= note: inside `<u8 as core::slice::cmp::SliceOrd>::compare` at RUSTLIB/core/src/slice/cmp.rs:LL:CC
1111
= note: inside `core::slice::cmp::<impl std::cmp::Ord for [u8]>::cmp` at RUSTLIB/core/src/slice/cmp.rs:LL:CC
1212
note: inside `main`
13-
--> $DIR/uninit_buffer_with_provenance.rs:LL:CC
13+
--> $DIR/uninit_alloc_diagnostic_with_provenance.rs:LL:CC
1414
|
1515
LL | drop(slice1.cmp(slice2));
1616
| ^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)