Skip to content

Commit b6ef1f3

Browse files
committed
Auto merge of rust-lang#149158 - matthiaskrgr:rollup-qmtvboe, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#149033 (autodiff rlib handling) - rust-lang#149088 (Add missing trailing period to RustDoc for fn create_dir().) - rust-lang#149111 (fs: Run file lock tests on all platforms that support it) - rust-lang#149113 (sgx: avoid unnecessarily creating a slice) - rust-lang#149123 (std: sys: fs: uefi: Fix FileAttr size) - rust-lang#149133 (Remove an unused variable) - rust-lang#149139 (Enable host tools for aarch64-unknown-linux-ohos) - rust-lang#149144 (Reject `async fn` in `const impl` during AST validation) - rust-lang#149154 (Fix platform supports docs tiny typo) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 28ff18a + ce46679 commit b6ef1f3

4 files changed

Lines changed: 70 additions & 66 deletions

File tree

std/src/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2918,7 +2918,7 @@ pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
29182918
fs_imp::canonicalize(path.as_ref())
29192919
}
29202920

2921-
/// Creates a new, empty directory at the provided path
2921+
/// Creates a new, empty directory at the provided path.
29222922
///
29232923
/// # Platform-specific behavior
29242924
///

std/src/fs/tests.rs

Lines changed: 67 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
11
use rand::RngCore;
22

3-
#[cfg(any(
4-
windows,
5-
target_os = "freebsd",
6-
target_os = "linux",
7-
target_os = "netbsd",
8-
target_os = "illumos",
9-
target_vendor = "apple",
10-
))]
113
use crate::assert_matches::assert_matches;
12-
#[cfg(any(
13-
windows,
14-
target_os = "freebsd",
15-
target_os = "linux",
16-
target_os = "netbsd",
17-
target_os = "illumos",
18-
target_vendor = "apple",
19-
))]
20-
use crate::fs::TryLockError;
21-
use crate::fs::{self, File, FileTimes, OpenOptions};
4+
use crate::fs::{self, File, FileTimes, OpenOptions, TryLockError};
225
use crate::io::prelude::*;
236
use crate::io::{BorrowedBuf, ErrorKind, SeekFrom};
247
use crate::mem::MaybeUninit;
@@ -222,15 +205,22 @@ fn file_test_io_seek_and_write() {
222205
}
223206

224207
#[test]
225-
#[cfg(any(
226-
windows,
227-
target_os = "freebsd",
228-
target_os = "linux",
229-
target_os = "netbsd",
230-
target_os = "solaris",
231-
target_os = "illumos",
232-
target_vendor = "apple",
233-
))]
208+
#[cfg_attr(
209+
not(any(
210+
windows,
211+
target_os = "aix",
212+
target_os = "cygwin",
213+
target_os = "freebsd",
214+
target_os = "fuchsia",
215+
target_os = "illumos",
216+
target_os = "linux",
217+
target_os = "netbsd",
218+
target_os = "openbsd",
219+
target_os = "solaris",
220+
target_vendor = "apple",
221+
)),
222+
should_panic
223+
)]
234224
fn file_lock_multiple_shared() {
235225
let tmpdir = tmpdir();
236226
let filename = &tmpdir.join("file_lock_multiple_shared_test.txt");
@@ -247,15 +237,22 @@ fn file_lock_multiple_shared() {
247237
}
248238

249239
#[test]
250-
#[cfg(any(
251-
windows,
252-
target_os = "freebsd",
253-
target_os = "linux",
254-
target_os = "netbsd",
255-
target_os = "solaris",
256-
target_os = "illumos",
257-
target_vendor = "apple",
258-
))]
240+
#[cfg_attr(
241+
not(any(
242+
windows,
243+
target_os = "aix",
244+
target_os = "cygwin",
245+
target_os = "freebsd",
246+
target_os = "fuchsia",
247+
target_os = "illumos",
248+
target_os = "linux",
249+
target_os = "netbsd",
250+
target_os = "openbsd",
251+
target_os = "solaris",
252+
target_vendor = "apple",
253+
)),
254+
should_panic
255+
)]
259256
fn file_lock_blocking() {
260257
let tmpdir = tmpdir();
261258
let filename = &tmpdir.join("file_lock_blocking_test.txt");
@@ -273,15 +270,22 @@ fn file_lock_blocking() {
273270
}
274271

275272
#[test]
276-
#[cfg(any(
277-
windows,
278-
target_os = "freebsd",
279-
target_os = "linux",
280-
target_os = "netbsd",
281-
target_os = "solaris",
282-
target_os = "illumos",
283-
target_vendor = "apple",
284-
))]
273+
#[cfg_attr(
274+
not(any(
275+
windows,
276+
target_os = "aix",
277+
target_os = "cygwin",
278+
target_os = "freebsd",
279+
target_os = "fuchsia",
280+
target_os = "illumos",
281+
target_os = "linux",
282+
target_os = "netbsd",
283+
target_os = "openbsd",
284+
target_os = "solaris",
285+
target_vendor = "apple",
286+
)),
287+
should_panic
288+
)]
285289
fn file_lock_drop() {
286290
let tmpdir = tmpdir();
287291
let filename = &tmpdir.join("file_lock_dup_test.txt");
@@ -296,15 +300,22 @@ fn file_lock_drop() {
296300
}
297301

298302
#[test]
299-
#[cfg(any(
300-
windows,
301-
target_os = "freebsd",
302-
target_os = "linux",
303-
target_os = "netbsd",
304-
target_os = "solaris",
305-
target_os = "illumos",
306-
target_vendor = "apple",
307-
))]
303+
#[cfg_attr(
304+
not(any(
305+
windows,
306+
target_os = "aix",
307+
target_os = "cygwin",
308+
target_os = "freebsd",
309+
target_os = "fuchsia",
310+
target_os = "illumos",
311+
target_os = "linux",
312+
target_os = "netbsd",
313+
target_os = "openbsd",
314+
target_os = "solaris",
315+
target_vendor = "apple",
316+
)),
317+
should_panic
318+
)]
308319
fn file_lock_dup() {
309320
let tmpdir = tmpdir();
310321
let filename = &tmpdir.join("file_lock_dup_test.txt");
@@ -1252,7 +1263,7 @@ fn readlink_not_symlink() {
12521263
}
12531264

12541265
#[test]
1255-
#[cfg_attr(target_os = "android", ignore)] // Android SELinux rules prevent creating hardlinks
1266+
#[cfg_attr(target_os = "android", ignore = "Android SELinux rules prevent creating hardlinks")]
12561267
fn links_work() {
12571268
let tmpdir = tmpdir();
12581269
let input = tmpdir.join("in.txt");
@@ -1748,7 +1759,7 @@ fn metadata_access_times() {
17481759

17491760
/// Test creating hard links to symlinks.
17501761
#[test]
1751-
#[cfg_attr(target_os = "android", ignore)] // Android SELinux rules prevent creating hardlinks
1762+
#[cfg_attr(target_os = "android", ignore = "Android SELinux rules prevent creating hardlinks")]
17521763
fn symlink_hard_link() {
17531764
let tmpdir = tmpdir();
17541765
if !got_symlink_permission(&tmpdir) {

std/src/sys/fs/uefi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl FileAttr {
8181
unsafe {
8282
Self {
8383
attr: (*info.as_ptr()).attribute,
84-
size: (*info.as_ptr()).size,
84+
size: (*info.as_ptr()).file_size,
8585
modified: uefi_fs::uefi_to_systemtime((*info.as_ptr()).modification_time),
8686
accessed: uefi_fs::uefi_to_systemtime((*info.as_ptr()).last_access_time),
8787
created: uefi_fs::uefi_to_systemtime((*info.as_ptr()).create_time),

std/src/sys/pal/sgx/abi/usercalls/alloc.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,6 @@ unsafe impl<T: UserSafeSized> UserSafe for [T] {
143143
align_of::<T>()
144144
}
145145

146-
/// # Safety
147-
/// Behavior is undefined if any of these conditions are violated:
148-
/// * `ptr` must be [valid] for writes of `size` many bytes, and it must be
149-
/// properly aligned.
150-
///
151-
/// [valid]: core::ptr#safety
152146
/// # Panics
153147
///
154148
/// This function panics if:
@@ -158,8 +152,7 @@ unsafe impl<T: UserSafeSized> UserSafe for [T] {
158152
let elem_size = size_of::<T>();
159153
assert_eq!(size % elem_size, 0);
160154
let len = size / elem_size;
161-
// SAFETY: The caller must uphold the safety contract for `from_raw_sized_unchecked`
162-
unsafe { slice::from_raw_parts_mut(ptr as _, len) }
155+
ptr::slice_from_raw_parts_mut(ptr as _, len)
163156
}
164157
}
165158

0 commit comments

Comments
 (0)