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

Lines changed: 5 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 8 additions & 3 deletions
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 renamed to library/std/src/sys/fs/hermit.rs

Lines changed: 6 additions & 6 deletions
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

Lines changed: 28 additions & 0 deletions
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 renamed to library/std/src/sys/fs/solid.rs

Lines changed: 4 additions & 2 deletions
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 renamed to library/std/src/sys/fs/unix.rs

Lines changed: 9 additions & 5 deletions
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 renamed to library/std/src/sys/fs/unix/tests.rs

Lines changed: 1 addition & 1 deletion
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() {

0 commit comments

Comments
 (0)