Skip to content

Commit 3ea711f

Browse files
committed
Auto merge of rust-lang#138279 - matthiaskrgr:rollup-ndnoipr, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#122790 (Apply dllimport in ThinLTO) - rust-lang#137650 (Move `fs` into `sys`) - rust-lang#138228 (Use `disjoint_bitor` inside `borrowing_sub`) - rust-lang#138233 (Windows: Don't link std (and run-make) against advapi32, except on win7) - rust-lang#138253 (Continue to check attr if meet empty repr for adt) - rust-lang#138263 (Fix `repr128-dwarf` test) - rust-lang#138276 (Lazy load NtOpenFile for UWP) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 385970f + 33530e4 commit 3ea711f

File tree

43 files changed

+160
-115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+160
-115
lines changed

compiler/rustc_codegen_llvm/src/consts.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use rustc_middle::mir::mono::MonoItem;
1616
use rustc_middle::ty::Instance;
1717
use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf};
1818
use rustc_middle::{bug, span_bug};
19-
use rustc_session::config::Lto;
2019
use tracing::{debug, instrument, trace};
2120

2221
use crate::common::{AsCCharPtr, CodegenCx};
@@ -344,11 +343,11 @@ impl<'ll> CodegenCx<'ll, '_> {
344343
// Local definitions can never be imported, so we must not apply
345344
// the DLLImport annotation.
346345
&& !dso_local
347-
// ThinLTO can't handle this workaround in all cases, so we don't
348-
// emit the attrs. Instead we make them unnecessary by disallowing
349-
// dynamic linking when linker plugin based LTO is enabled.
350-
&& !self.tcx.sess.opts.cg.linker_plugin_lto.enabled()
351-
&& self.tcx.sess.lto() != Lto::Thin;
346+
// Linker plugin ThinLTO doesn't create the self-dllimport Rust uses for rlibs
347+
// as the code generation happens out of process. Instead we assume static linkage
348+
// and disallow dynamic linking when linker plugin based LTO is enabled.
349+
// Regular in-process ThinLTO doesn't need this workaround.
350+
&& !self.tcx.sess.opts.cg.linker_plugin_lto.enabled();
352351

353352
// If this assertion triggers, there's something wrong with commandline
354353
// argument validation.

compiler/rustc_passes/src/check_attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
19981998
// catch `repr()` with no arguments, applied to an item (i.e. not `#![repr()]`)
19991999
if item.is_some() {
20002000
match target {
2001-
Target::Struct | Target::Union | Target::Enum => {}
2001+
Target::Struct | Target::Union | Target::Enum => continue,
20022002
Target::Fn | Target::Method(_) => {
20032003
feature_err(
20042004
&self.tcx.sess,

library/core/src/num/uint_macros.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -2533,15 +2533,20 @@ macro_rules! uint_impl {
25332533
#[doc = concat!("assert_eq!((diff1, diff0), (3, ", stringify!($SelfT), "::MAX));")]
25342534
/// ```
25352535
#[unstable(feature = "bigint_helper_methods", issue = "85532")]
2536+
#[rustc_const_unstable(feature = "bigint_helper_methods", issue = "85532")]
25362537
#[must_use = "this returns the result of the operation, \
25372538
without modifying the original"]
25382539
#[inline]
25392540
pub const fn borrowing_sub(self, rhs: Self, borrow: bool) -> (Self, bool) {
25402541
// note: longer-term this should be done via an intrinsic, but this has been shown
25412542
// to generate optimal code for now, and LLVM doesn't have an equivalent intrinsic
2542-
let (a, b) = self.overflowing_sub(rhs);
2543-
let (c, d) = a.overflowing_sub(borrow as $SelfT);
2544-
(c, b | d)
2543+
let (a, c1) = self.overflowing_sub(rhs);
2544+
let (b, c2) = a.overflowing_sub(borrow as $SelfT);
2545+
// SAFETY: Only one of `c1` and `c2` can be set.
2546+
// For c1 to be set we need to have underflowed, but if we did then
2547+
// `a` is nonzero, which means that `c2` cannot possibly
2548+
// underflow because it's subtracting at most `1` (since it came from `bool`)
2549+
(b, unsafe { intrinsics::disjoint_bitor(c1, c2) })
25452550
}
25462551

25472552
/// Calculates `self` - `rhs` with a signed `rhs`
File renamed without changes.

library/std/src/sys/pal/hermit/fs.rs library/std/src/sys/fs/hermit.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
use super::fd::FileDesc;
2-
use super::hermit_abi::{
3-
self, DT_DIR, DT_LNK, DT_REG, DT_UNKNOWN, O_APPEND, O_CREAT, O_DIRECTORY, O_EXCL, O_RDONLY,
4-
O_RDWR, O_TRUNC, O_WRONLY, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, dirent64, stat as stat_struct,
5-
};
61
use crate::ffi::{CStr, OsStr, OsString, c_char};
72
use crate::io::{self, BorrowedCursor, Error, ErrorKind, IoSlice, IoSliceMut, SeekFrom};
83
use crate::os::hermit::ffi::OsStringExt;
4+
use crate::os::hermit::hermit_abi::{
5+
self, DT_DIR, DT_LNK, DT_REG, DT_UNKNOWN, O_APPEND, O_CREAT, O_DIRECTORY, O_EXCL, O_RDONLY,
6+
O_RDWR, O_TRUNC, O_WRONLY, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, dirent64, stat as stat_struct,
7+
};
98
use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
109
use crate::path::{Path, PathBuf};
1110
use crate::sync::Arc;
1211
use crate::sys::common::small_c_string::run_path_with_cstr;
12+
pub use crate::sys::fs::common::{copy, exists};
13+
use crate::sys::pal::fd::FileDesc;
1314
use crate::sys::time::SystemTime;
1415
use crate::sys::{cvt, unsupported};
15-
pub use crate::sys_common::fs::{copy, exists};
1616
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
1717
use crate::{fmt, mem};
1818

library/std/src/sys/fs/mod.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![deny(unsafe_op_in_unsafe_fn)]
2+
3+
pub mod common;
4+
5+
cfg_if::cfg_if! {
6+
if #[cfg(target_family = "unix")] {
7+
mod unix;
8+
pub use unix::*;
9+
} else if #[cfg(target_os = "windows")] {
10+
mod windows;
11+
pub use windows::*;
12+
} else if #[cfg(target_os = "hermit")] {
13+
mod hermit;
14+
pub use hermit::*;
15+
} else if #[cfg(target_os = "solid_asp3")] {
16+
mod solid;
17+
pub use solid::*;
18+
} else if #[cfg(target_os = "uefi")] {
19+
mod uefi;
20+
pub use uefi::*;
21+
} else if #[cfg(target_os = "wasi")] {
22+
mod wasi;
23+
pub use wasi::*;
24+
} else {
25+
mod unsupported;
26+
pub use unsupported::*;
27+
}
28+
}

library/std/src/sys/pal/solid/fs.rs library/std/src/sys/fs/solid.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use super::{abi, error};
1+
#![allow(dead_code)]
2+
23
use crate::ffi::{CStr, CString, OsStr, OsString};
34
use crate::fmt;
45
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom};
@@ -7,9 +8,10 @@ use crate::os::raw::{c_int, c_short};
78
use crate::os::solid::ffi::OsStrExt;
89
use crate::path::{Path, PathBuf};
910
use crate::sync::Arc;
11+
pub use crate::sys::fs::common::exists;
12+
use crate::sys::pal::{abi, error};
1013
use crate::sys::time::SystemTime;
1114
use crate::sys::unsupported;
12-
pub use crate::sys_common::fs::exists;
1315
use crate::sys_common::ignore_notfound;
1416

1517
type CIntNotMinusOne = core::num::niche_types::NotAllOnes<c_int>;
File renamed without changes.

library/std/src/sys/pal/unix/fs.rs library/std/src/sys/fs/unix.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(nonstandard_style)]
2+
#![allow(unsafe_op_in_unsafe_fn)]
13
// miri has some special hacks here that make things unused.
24
#![cfg_attr(miri, allow(unused))]
35

@@ -79,13 +81,13 @@ use crate::path::{Path, PathBuf};
7981
use crate::sync::Arc;
8082
use crate::sys::common::small_c_string::run_path_with_cstr;
8183
use crate::sys::fd::FileDesc;
84+
pub use crate::sys::fs::common::exists;
8285
use crate::sys::time::SystemTime;
8386
#[cfg(all(target_os = "linux", target_env = "gnu"))]
8487
use crate::sys::weak::syscall;
8588
#[cfg(target_os = "android")]
8689
use crate::sys::weak::weak;
8790
use crate::sys::{cvt, cvt_r};
88-
pub use crate::sys_common::fs::exists;
8991
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
9092
use crate::{mem, ptr};
9193

@@ -699,6 +701,8 @@ impl Iterator for ReadDir {
699701
target_os = "hurd",
700702
))]
701703
fn next(&mut self) -> Option<io::Result<DirEntry>> {
704+
use crate::sys::os::{errno, set_errno};
705+
702706
if self.end_of_stream {
703707
return None;
704708
}
@@ -710,7 +714,7 @@ impl Iterator for ReadDir {
710714
// with unlimited or variable NAME_MAX. Many modern platforms guarantee
711715
// thread safety for readdir() as long an individual DIR* is not accessed
712716
// concurrently, which is sufficient for Rust.
713-
super::os::set_errno(0);
717+
set_errno(0);
714718
let entry_ptr: *const dirent64 = readdir64(self.inner.dirp.0);
715719
if entry_ptr.is_null() {
716720
// We either encountered an error, or reached the end. Either way,
@@ -719,7 +723,7 @@ impl Iterator for ReadDir {
719723

720724
// To distinguish between errors and end-of-directory, we had to clear
721725
// errno beforehand to check for an error now.
722-
return match super::os::errno() {
726+
return match errno() {
723727
0 => None,
724728
e => Some(Err(Error::from_raw_os_error(e))),
725729
};
@@ -1932,7 +1936,7 @@ pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
19321936

19331937
fn open_from(from: &Path) -> io::Result<(crate::fs::File, crate::fs::Metadata)> {
19341938
use crate::fs::File;
1935-
use crate::sys_common::fs::NOT_FILE_ERROR;
1939+
use crate::sys::fs::common::NOT_FILE_ERROR;
19361940

19371941
let reader = File::open(from)?;
19381942
let metadata = reader.metadata()?;
@@ -2151,7 +2155,7 @@ pub use remove_dir_impl::remove_dir_all;
21512155
miri
21522156
))]
21532157
mod remove_dir_impl {
2154-
pub use crate::sys_common::fs::remove_dir_all;
2158+
pub use crate::sys::fs::common::remove_dir_all;
21552159
}
21562160

21572161
// Modern implementation using openat(), unlinkat() and fdopendir()

library/std/src/sys/pal/unix/fs/tests.rs library/std/src/sys/fs/unix/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::sys::pal::unix::fs::FilePermissions;
1+
use crate::sys::fs::FilePermissions;
22

33
#[test]
44
fn test_debug_permissions() {

library/std/src/sys/pal/wasi/fs.rs library/std/src/sys/fs/wasi.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![forbid(unsafe_op_in_unsafe_fn)]
2-
3-
use super::fd::WasiFd;
41
use crate::ffi::{CStr, OsStr, OsString};
52
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom};
63
use crate::mem::{self, ManuallyDrop};
@@ -10,9 +7,10 @@ use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd
107
use crate::path::{Path, PathBuf};
118
use crate::sync::Arc;
129
use crate::sys::common::small_c_string::run_path_with_cstr;
10+
use crate::sys::fd::WasiFd;
11+
pub use crate::sys::fs::common::exists;
1312
use crate::sys::time::SystemTime;
1413
use crate::sys::unsupported;
15-
pub use crate::sys_common::fs::exists;
1614
use crate::sys_common::{AsInner, FromInner, IntoInner, ignore_notfound};
1715
use crate::{fmt, iter, ptr};
1816

library/std/src/sys/pal/windows/fs.rs library/std/src/sys/fs/windows.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use super::api::{self, WinError, set_file_information_by_handle};
2-
use super::{IoResult, to_u16s};
1+
#![allow(nonstandard_style)]
2+
33
use crate::alloc::{Layout, alloc, dealloc};
44
use crate::borrow::Cow;
55
use crate::ffi::{OsStr, OsString, c_void};
@@ -10,6 +10,8 @@ use crate::os::windows::prelude::*;
1010
use crate::path::{Path, PathBuf};
1111
use crate::sync::Arc;
1212
use crate::sys::handle::Handle;
13+
use crate::sys::pal::api::{self, WinError, set_file_information_by_handle};
14+
use crate::sys::pal::{IoResult, fill_utf16_buf, to_u16s, truncate_utf16_at_nul};
1315
use crate::sys::path::maybe_verbatim;
1416
use crate::sys::time::SystemTime;
1517
use crate::sys::{Align8, c, cvt};
@@ -167,7 +169,7 @@ impl DirEntry {
167169
}
168170

169171
pub fn file_name(&self) -> OsString {
170-
let filename = super::truncate_utf16_at_nul(&self.data.cFileName);
172+
let filename = truncate_utf16_at_nul(&self.data.cFileName);
171173
OsString::from_wide(filename)
172174
}
173175

@@ -695,7 +697,7 @@ impl File {
695697
// Turn `\??\` into `\\?\` (a verbatim path).
696698
subst[1] = b'\\' as u16;
697699
// Attempt to convert to a more user-friendly path.
698-
let user = super::args::from_wide_to_user_path(
700+
let user = crate::sys::args::from_wide_to_user_path(
699701
subst.iter().copied().chain([0]).collect(),
700702
)?;
701703
Ok(PathBuf::from(OsString::from_wide(user.strip_suffix(&[0]).unwrap_or(&user))))
@@ -1492,7 +1494,7 @@ pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> {
14921494
}
14931495

14941496
fn get_path(f: &File) -> io::Result<PathBuf> {
1495-
super::fill_utf16_buf(
1497+
fill_utf16_buf(
14961498
|buf, sz| unsafe {
14971499
c::GetFinalPathNameByHandleW(f.handle.as_raw_handle(), buf, sz, c::VOLUME_NAME_DOS)
14981500
},

library/std/src/sys/pal/windows/fs/remove_dir_all.rs library/std/src/sys/fs/windows/remove_dir_all.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use core::sync::atomic::{AtomicU32, Ordering};
3333

3434
use super::{AsRawHandle, DirBuff, File, FromRawHandle};
3535
use crate::sys::c;
36-
use crate::sys::pal::windows::api::WinError;
36+
use crate::sys::pal::api::WinError;
3737
use crate::thread;
3838

3939
// The maximum number of times to spin when waiting for deletes to complete.

library/std/src/sys/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub mod anonymous_pipe;
1212
pub mod backtrace;
1313
pub mod cmath;
1414
pub mod exit_guard;
15+
pub mod fs;
1516
pub mod io;
1617
pub mod net;
1718
pub mod os_str;

library/std/src/sys/pal/hermit/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use crate::os::raw::c_char;
2121
pub mod args;
2222
pub mod env;
2323
pub mod fd;
24-
pub mod fs;
2524
pub mod futex;
2625
pub mod os;
2726
#[path = "../unsupported/pipe.rs"]

library/std/src/sys/pal/sgx/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ pub mod abi;
1212
pub mod args;
1313
pub mod env;
1414
pub mod fd;
15-
#[path = "../unsupported/fs.rs"]
16-
pub mod fs;
1715
mod libunwind_integration;
1816
pub mod os;
1917
#[path = "../unsupported/pipe.rs"]

library/std/src/sys/pal/solid/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub mod env;
2222
// `error` is `pub(crate)` so that it can be accessed by `itron/error.rs` as
2323
// `crate::sys::error`
2424
pub(crate) mod error;
25-
pub mod fs;
2625
pub mod os;
2726
#[path = "../unsupported/pipe.rs"]
2827
pub mod pipe;

library/std/src/sys/pal/solid/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl SystemTime {
3535
SystemTime(t)
3636
}
3737

38-
pub(super) fn from_time_t(t: abi::time_t) -> Self {
38+
pub fn from_time_t(t: abi::time_t) -> Self {
3939
Self(t)
4040
}
4141

library/std/src/sys/pal/teeos/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ pub mod args;
1111
#[path = "../unsupported/env.rs"]
1212
pub mod env;
1313
//pub mod fd;
14-
#[path = "../unsupported/fs.rs"]
15-
pub mod fs;
1614
pub mod os;
1715
#[path = "../unsupported/pipe.rs"]
1816
pub mod pipe;

library/std/src/sys/pal/uefi/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
pub mod args;
1717
pub mod env;
18-
pub mod fs;
1918
pub mod helpers;
2019
pub mod os;
2120
#[path = "../unsupported/pipe.rs"]

library/std/src/sys/pal/unix/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pub mod weak;
99
pub mod args;
1010
pub mod env;
1111
pub mod fd;
12-
pub mod fs;
1312
pub mod futex;
1413
#[cfg(any(target_os = "linux", target_os = "android"))]
1514
pub mod kernel_copy;

library/std/src/sys/pal/unsupported/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
pub mod args;
44
pub mod env;
5-
pub mod fs;
65
pub mod os;
76
pub mod pipe;
87
pub mod process;

library/std/src/sys/pal/wasi/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
pub mod args;
1717
pub mod env;
1818
pub mod fd;
19-
pub mod fs;
2019
#[allow(unused)]
2120
#[path = "../wasm/atomics/futex.rs"]
2221
pub mod futex;

library/std/src/sys/pal/wasip2/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ pub mod args;
1212
pub mod env;
1313
#[path = "../wasi/fd.rs"]
1414
pub mod fd;
15-
#[path = "../wasi/fs.rs"]
16-
pub mod fs;
1715
#[allow(unused)]
1816
#[path = "../wasm/atomics/futex.rs"]
1917
pub mod futex;

library/std/src/sys/pal/wasm/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#[path = "../unsupported/args.rs"]
2020
pub mod args;
2121
pub mod env;
22-
#[path = "../unsupported/fs.rs"]
23-
pub mod fs;
2422
#[path = "../unsupported/os.rs"]
2523
pub mod os;
2624
#[path = "../unsupported/pipe.rs"]

library/std/src/sys/pal/windows/c.rs

+11
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,17 @@ compat_fn_with_fallback! {
237237
STATUS_NOT_IMPLEMENTED
238238
}
239239
#[cfg(target_vendor = "uwp")]
240+
pub fn NtOpenFile(
241+
filehandle: *mut HANDLE,
242+
desiredaccess: u32,
243+
objectattributes: *const OBJECT_ATTRIBUTES,
244+
iostatusblock: *mut IO_STATUS_BLOCK,
245+
shareaccess: u32,
246+
openoptions: u32
247+
) -> NTSTATUS {
248+
STATUS_NOT_IMPLEMENTED
249+
}
250+
#[cfg(target_vendor = "uwp")]
240251
pub fn NtReadFile(
241252
filehandle: HANDLE,
242253
event: HANDLE,

0 commit comments

Comments
 (0)