about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/f128.rs2
-rw-r--r--library/std/src/f16.rs2
-rw-r--r--library/std/src/f32.rs2
-rw-r--r--library/std/src/f64.rs2
-rw-r--r--library/std/src/sys/pal/windows/fs.rs36
5 files changed, 15 insertions, 29 deletions
diff --git a/library/std/src/f128.rs b/library/std/src/f128.rs
index 14ce2b69ca4..974514c9c45 100644
--- a/library/std/src/f128.rs
+++ b/library/std/src/f128.rs
@@ -126,7 +126,7 @@ impl f128 {
     #[unstable(feature = "f128", issue = "116909")]
     #[must_use = "method returns a new number and does not mutate the original value"]
     pub fn round_ties_even(self) -> f128 {
-        unsafe { intrinsics::rintf128(self) }
+        intrinsics::round_ties_even_f128(self)
     }
 
     /// Returns the integer part of `self`.
diff --git a/library/std/src/f16.rs b/library/std/src/f16.rs
index 0af69dff05a..c3b51bf31de 100644
--- a/library/std/src/f16.rs
+++ b/library/std/src/f16.rs
@@ -126,7 +126,7 @@ impl f16 {
     #[unstable(feature = "f16", issue = "116909")]
     #[must_use = "method returns a new number and does not mutate the original value"]
     pub fn round_ties_even(self) -> f16 {
-        unsafe { intrinsics::rintf16(self) }
+        intrinsics::round_ties_even_f16(self)
     }
 
     /// Returns the integer part of `self`.
diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs
index 295eee8700a..19fb24c8ee2 100644
--- a/library/std/src/f32.rs
+++ b/library/std/src/f32.rs
@@ -122,7 +122,7 @@ impl f32 {
     #[stable(feature = "round_ties_even", since = "1.77.0")]
     #[inline]
     pub fn round_ties_even(self) -> f32 {
-        unsafe { intrinsics::rintf32(self) }
+        intrinsics::round_ties_even_f32(self)
     }
 
     /// Returns the integer part of `self`.
diff --git a/library/std/src/f64.rs b/library/std/src/f64.rs
index 0d713ecbc73..f1c3cb56127 100644
--- a/library/std/src/f64.rs
+++ b/library/std/src/f64.rs
@@ -122,7 +122,7 @@ impl f64 {
     #[stable(feature = "round_ties_even", since = "1.77.0")]
     #[inline]
     pub fn round_ties_even(self) -> f64 {
-        unsafe { intrinsics::rintf64(self) }
+        intrinsics::round_ties_even_f64(self)
     }
 
     /// Returns the integer part of `self`.
diff --git a/library/std/src/sys/pal/windows/fs.rs b/library/std/src/sys/pal/windows/fs.rs
index 0ddce30cf8e..dce5a429cb0 100644
--- a/library/std/src/sys/pal/windows/fs.rs
+++ b/library/std/src/sys/pal/windows/fs.rs
@@ -1,4 +1,4 @@
-use super::api::{self, WinError};
+use super::api::{self, WinError, set_file_information_by_handle};
 use super::{IoResult, to_u16s};
 use crate::alloc::{alloc, handle_alloc_error};
 use crate::borrow::Cow;
@@ -319,31 +319,17 @@ impl File {
                 && creation == c::OPEN_ALWAYS
                 && api::get_last_error() == WinError::ALREADY_EXISTS
             {
-                unsafe {
-                    // This first tries `FileAllocationInfo` but falls back to
-                    // `FileEndOfFileInfo` in order to support WINE.
-                    // If WINE gains support for FileAllocationInfo, we should
-                    // remove the fallback.
-                    let alloc = c::FILE_ALLOCATION_INFO { AllocationSize: 0 };
-                    let result = c::SetFileInformationByHandle(
-                        handle.as_raw_handle(),
-                        c::FileAllocationInfo,
-                        (&raw const alloc).cast::<c_void>(),
-                        mem::size_of::<c::FILE_ALLOCATION_INFO>() as u32,
-                    );
-                    if result == 0 {
+                // This first tries `FileAllocationInfo` but falls back to
+                // `FileEndOfFileInfo` in order to support WINE.
+                // If WINE gains support for FileAllocationInfo, we should
+                // remove the fallback.
+                let alloc = c::FILE_ALLOCATION_INFO { AllocationSize: 0 };
+                set_file_information_by_handle(handle.as_raw_handle(), &alloc)
+                    .or_else(|_| {
                         let eof = c::FILE_END_OF_FILE_INFO { EndOfFile: 0 };
-                        let result = c::SetFileInformationByHandle(
-                            handle.as_raw_handle(),
-                            c::FileEndOfFileInfo,
-                            (&raw const eof).cast::<c_void>(),
-                            mem::size_of::<c::FILE_END_OF_FILE_INFO>() as u32,
-                        );
-                        if result == 0 {
-                            return Err(io::Error::last_os_error());
-                        }
-                    }
-                }
+                        set_file_information_by_handle(handle.as_raw_handle(), &eof)
+                    })
+                    .io_result()?;
             }
             Ok(File { handle: Handle::from_inner(handle) })
         } else {