Skip to content

Commit c426bc8

Browse files
committed
Auto merge of #2607 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 64757ed + 47e5d8f commit c426bc8

File tree

4 files changed

+43
-23
lines changed

4 files changed

+43
-23
lines changed

bench-cargo-miri/serde2/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use serde::Deserialize;
55
use std::thread;
66

77
#[derive(Deserialize)]
8+
#[allow(unused)]
89
struct DeriveStruct {
910
buffer: Vec<i16>,
1011
}

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
edabf59ca4646b3fc1a961c26431215001043f6a
1+
b1ab3b738ac718da74cd4aa0bb7f362d0adbdf84

src/shims/windows/foreign_items.rs

+20-15
Original file line numberDiff line numberDiff line change
@@ -343,16 +343,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
343343
// FIXME: we should set last_error, but to what?
344344
this.write_null(dest)?;
345345
}
346-
"GetConsoleMode" => {
347-
// Windows "isatty" (in libtest) needs this, so we fake it.
348-
let [console, mode] =
349-
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
350-
this.read_scalar(console)?.to_machine_isize(this)?;
351-
this.deref_operand(mode)?;
352-
// Indicate an error.
353-
// FIXME: we should set last_error, but to what?
354-
this.write_null(dest)?;
355-
}
356346
"GetStdHandle" => {
357347
let [which] =
358348
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
@@ -404,14 +394,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
404394
let [] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
405395
// Just fake a HANDLE
406396
// It's fine to not use the Handle type here because its a stub
407-
this.write_scalar(Scalar::from_machine_isize(1, this), dest)?;
397+
this.write_int(1, dest)?;
408398
}
409399
"GetModuleHandleA" if this.frame_in_std() => {
410400
#[allow(non_snake_case)]
411401
let [_lpModuleName] =
412402
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
413403
// We need to return something non-null here to make `compat_fn!` work.
414-
this.write_scalar(Scalar::from_machine_isize(1, this), dest)?;
404+
this.write_int(1, dest)?;
415405
}
416406
"SetConsoleTextAttribute" if this.frame_in_std() => {
417407
#[allow(non_snake_case)]
@@ -420,24 +410,39 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
420410
// Pretend these does not exist / nothing happened, by returning zero.
421411
this.write_null(dest)?;
422412
}
413+
"GetConsoleMode" if this.frame_in_std() => {
414+
let [console, mode] =
415+
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
416+
this.read_scalar(console)?.to_machine_isize(this)?;
417+
this.deref_operand(mode)?;
418+
// Indicate an error.
419+
this.write_null(dest)?;
420+
}
421+
"GetFileInformationByHandleEx" if this.frame_in_std() => {
422+
#[allow(non_snake_case)]
423+
let [_hFile, _FileInformationClass, _lpFileInformation, _dwBufferSize] =
424+
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
425+
// Just make it fail.
426+
this.write_null(dest)?;
427+
}
423428
"AddVectoredExceptionHandler" if this.frame_in_std() => {
424429
#[allow(non_snake_case)]
425430
let [_First, _Handler] =
426431
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
427432
// Any non zero value works for the stdlib. This is just used for stack overflows anyway.
428-
this.write_scalar(Scalar::from_machine_usize(1, this), dest)?;
433+
this.write_int(1, dest)?;
429434
}
430435
"SetThreadStackGuarantee" if this.frame_in_std() => {
431436
#[allow(non_snake_case)]
432437
let [_StackSizeInBytes] =
433438
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
434439
// Any non zero value works for the stdlib. This is just used for stack overflows anyway.
435-
this.write_scalar(Scalar::from_u32(1), dest)?;
440+
this.write_int(1, dest)?;
436441
}
437442
"GetCurrentProcessId" if this.frame_in_std() => {
438443
let [] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
439444
let result = this.GetCurrentProcessId()?;
440-
this.write_scalar(Scalar::from_u32(result), dest)?;
445+
this.write_int(result, dest)?;
441446
}
442447
// this is only callable from std because we know that std ignores the return value
443448
"SwitchToThread" if this.frame_in_std() => {

tests/pass-dep/shims/fs.rs

+21-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#![feature(io_error_more)]
55
#![feature(io_error_uncategorized)]
66

7-
use std::ffi::CString;
7+
use std::collections::HashMap;
8+
use std::ffi::{CString, OsString};
89
use std::fs::{
910
create_dir, read_dir, read_link, remove_dir, remove_dir_all, remove_file, rename, File,
1011
OpenOptions,
@@ -394,21 +395,34 @@ fn test_directory() {
394395
// Creating a directory when it already exists should fail.
395396
assert_eq!(ErrorKind::AlreadyExists, create_dir(&dir_path).unwrap_err().kind());
396397

397-
// Create some files inside the directory
398+
// Create some files and dirs inside the directory
398399
let path_1 = dir_path.join("test_file_1");
399400
drop(File::create(&path_1).unwrap());
400401
let path_2 = dir_path.join("test_file_2");
401402
drop(File::create(&path_2).unwrap());
402-
// Test that the files are present inside the directory
403-
let dir_iter = read_dir(&dir_path).unwrap();
404-
let mut file_names = dir_iter.map(|e| e.unwrap().file_name()).collect::<Vec<_>>();
405-
file_names.sort_unstable();
406-
assert_eq!(file_names, vec!["test_file_1", "test_file_2"]);
403+
let dir_1 = dir_path.join("test_dir_1");
404+
create_dir(&dir_1).unwrap();
405+
// Test that read_dir metadata calls succeed
406+
assert_eq!(
407+
HashMap::from([
408+
(OsString::from("test_file_1"), true),
409+
(OsString::from("test_file_2"), true),
410+
(OsString::from("test_dir_1"), false)
411+
]),
412+
read_dir(&dir_path)
413+
.unwrap()
414+
.map(|e| {
415+
let e = e.unwrap();
416+
(e.file_name(), e.metadata().unwrap().is_file())
417+
})
418+
.collect::<HashMap<_, _>>()
419+
);
407420
// Deleting the directory should fail, since it is not empty.
408421
assert_eq!(ErrorKind::DirectoryNotEmpty, remove_dir(&dir_path).unwrap_err().kind());
409422
// Clean up the files in the directory
410423
remove_file(&path_1).unwrap();
411424
remove_file(&path_2).unwrap();
425+
remove_dir(&dir_1).unwrap();
412426
// Now there should be nothing left in the directory.
413427
let dir_iter = read_dir(&dir_path).unwrap();
414428
let file_names = dir_iter.map(|e| e.unwrap().file_name()).collect::<Vec<_>>();

0 commit comments

Comments
 (0)