Skip to content

Commit

Permalink
Auto merge of #133770 - GuillaumeGomez:rollup-l62iyyx, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

Successful merges:

 - #131713 (Stabilize `const_maybe_uninit_write`)
 - #133535 (show forbidden_lint_groups in future-compat reports)
 - #133610 (Move `Const::{from_anon_const,try_from_lit}` to hir_ty_lowering)
 - #133701 (Use c"lit" for CStrings without unwrap)
 - #133704 (fix ICE when promoted has layout size overflow)
 - #133705 (add "profiler" and "optimized-compiler-builtins" option coverage for ci-rustc)
 - #133710 (Reducing `target_feature` check-cfg merge conflicts)
 - #133732 (Fix `-Zdump-mir-dataflow`)
 - #133746 (Change `AttrArgs::Eq` to a struct variant)
 - #133763 (Fix `f16::midpoint` const feature gate)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Dec 3, 2024
2 parents 80c2e8b + 1b46d2d commit 48fef73
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
3 changes: 1 addition & 2 deletions tests/pass-dep/libc/libc-fs-symlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ fn test_readlink() {
assert_eq!(res, small_buf.len() as isize);

// Test that we report a proper error for a missing path.
let bad_path = CString::new("MIRI_MISSING_FILE_NAME").unwrap();
let res = unsafe {
libc::readlink(bad_path.as_ptr(), small_buf.as_mut_ptr().cast(), small_buf.len())
libc::readlink(c"MIRI_MISSING_FILE_NAME".as_ptr(), small_buf.as_mut_ptr().cast(), small_buf.len())
};
assert_eq!(res, -1);
assert_eq!(Error::last_os_error().kind(), ErrorKind::NotFound);
Expand Down
4 changes: 1 addition & 3 deletions tests/pass-dep/libc/libc-fs-with-isolation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//@compile-flags: -Zmiri-isolation-error=warn-nobacktrace
//@normalize-stderr-test: "(stat(x)?)" -> "$$STAT"

use std::ffi::CString;
use std::fs;
use std::io::{Error, ErrorKind};

Expand All @@ -13,10 +12,9 @@ fn main() {
}

// test `readlink`
let symlink_c_str = CString::new("foo.txt").unwrap();
let mut buf = vec![0; "foo_link.txt".len() + 1];
unsafe {
assert_eq!(libc::readlink(symlink_c_str.as_ptr(), buf.as_mut_ptr(), buf.len()), -1);
assert_eq!(libc::readlink(c"foo.txt".as_ptr(), buf.as_mut_ptr(), buf.len()), -1);
assert_eq!(Error::last_os_error().raw_os_error(), Some(libc::EACCES));
}

Expand Down
10 changes: 5 additions & 5 deletions tests/pass-dep/libc/libc-mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ fn test_memcpy() {
}

fn test_strcpy() {
use std::ffi::{CStr, CString};
use std::ffi::CStr;

// case: src_size equals dest_size
unsafe {
let src = CString::new("rust").unwrap();
let size = src.as_bytes_with_nul().len();
let src = c"rust";
let size = src.to_bytes_with_nul().len();
let dest = libc::malloc(size);
libc::strcpy(dest as *mut libc::c_char, src.as_ptr());
assert_eq!(CStr::from_ptr(dest as *const libc::c_char), src.as_ref());
Expand All @@ -69,8 +69,8 @@ fn test_strcpy() {

// case: src_size is less than dest_size
unsafe {
let src = CString::new("rust").unwrap();
let size = src.as_bytes_with_nul().len();
let src = c"rust";
let size = src.to_bytes_with_nul().len();
let dest = libc::malloc(size + 1);
libc::strcpy(dest as *mut libc::c_char, src.as_ptr());
assert_eq!(CStr::from_ptr(dest as *const libc::c_char), src.as_ref());
Expand Down

0 comments on commit 48fef73

Please sign in to comment.