Skip to content

Commit a33a3ae

Browse files
committed
Auto merge of #93921 - matthiaskrgr:rollup-wn3jlxj, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #90955 (Rename `FilenameTooLong` to `InvalidFilename` and also use it for Windows' `ERROR_INVALID_NAME`) - #91607 (Make `span_extend_to_prev_str()` more robust) - #92895 (Remove some unused functionality) - #93635 (Add missing platform-specific information on current_dir and set_current_dir) - #93660 (rustdoc-json: Add some tests for typealias item) - #93782 (Split `pauth` target feature) - #93868 (Fix incorrect register conflict detection in asm!) - #93888 (Implement `AsFd` for `&T` and `&mut T`.) - #93909 (Fix typo: explicitely -> explicitly) - #93910 (fix mention of moved function in `rustc_hir` docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents fc9faf6 + 0f1fb07 commit a33a3ae

File tree

9 files changed

+67
-9
lines changed

9 files changed

+67
-9
lines changed

std/src/env.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ use crate::sys::os as os_imp;
2323

2424
/// Returns the current working directory as a [`PathBuf`].
2525
///
26+
/// # Platform-specific behavior
27+
///
28+
/// This function currently corresponds to the `getcwd` function on Unix
29+
/// and the `GetCurrentDirectoryW` function on Windows.
30+
///
2631
/// # Errors
2732
///
2833
/// Returns an [`Err`] if the current working directory value is invalid.
@@ -49,6 +54,11 @@ pub fn current_dir() -> io::Result<PathBuf> {
4954

5055
/// Changes the current working directory to the specified path.
5156
///
57+
/// # Platform-specific behavior
58+
///
59+
/// This function currently corresponds to the `chdir` function on Unix
60+
/// and the `SetCurrentDirectoryW` function on Windows.
61+
///
5262
/// Returns an [`Err`] if the operation fails.
5363
///
5464
/// # Examples

std/src/io/error.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,11 @@ pub enum ErrorKind {
296296
/// The filesystem does not support making so many hardlinks to the same file.
297297
#[unstable(feature = "io_error_more", issue = "86442")]
298298
TooManyLinks,
299-
/// Filename too long.
299+
/// A filename was invalid.
300300
///
301-
/// The limit might be from the underlying filesystem or API, or an administratively imposed
302-
/// resource limit.
301+
/// This error can also cause if it exceeded the filename length limit.
303302
#[unstable(feature = "io_error_more", issue = "86442")]
304-
FilenameTooLong,
303+
InvalidFilename,
305304
/// Program argument list too long.
306305
///
307306
/// When trying to run an external program, a system or process limit on the size of the
@@ -382,12 +381,12 @@ impl ErrorKind {
382381
DirectoryNotEmpty => "directory not empty",
383382
ExecutableFileBusy => "executable file busy",
384383
FileTooLarge => "file too large",
385-
FilenameTooLong => "filename too long",
386384
FilesystemLoop => "filesystem loop or indirection limit (e.g. symlink loop)",
387385
FilesystemQuotaExceeded => "filesystem quota exceeded",
388386
HostUnreachable => "host unreachable",
389387
Interrupted => "operation interrupted",
390388
InvalidData => "invalid data",
389+
InvalidFilename => "invalid filename",
391390
InvalidInput => "invalid input parameter",
392391
IsADirectory => "is a directory",
393392
NetworkDown => "network down",

std/src/io/error/repr_bitpacked.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ fn kind_from_prim(ek: u32) -> Option<ErrorKind> {
315315
Deadlock,
316316
CrossesDevices,
317317
TooManyLinks,
318-
FilenameTooLong,
318+
InvalidFilename,
319319
ArgumentListTooLong,
320320
Interrupted,
321321
Other,

std/src/os/fd/owned.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,22 @@ pub trait AsFd {
200200
fn as_fd(&self) -> BorrowedFd<'_>;
201201
}
202202

203+
#[unstable(feature = "io_safety", issue = "87074")]
204+
impl<T: AsFd> AsFd for &T {
205+
#[inline]
206+
fn as_fd(&self) -> BorrowedFd<'_> {
207+
T::as_fd(self)
208+
}
209+
}
210+
211+
#[unstable(feature = "io_safety", issue = "87074")]
212+
impl<T: AsFd> AsFd for &mut T {
213+
#[inline]
214+
fn as_fd(&self) -> BorrowedFd<'_> {
215+
T::as_fd(self)
216+
}
217+
}
218+
203219
#[unstable(feature = "io_safety", issue = "87074")]
204220
impl AsFd for BorrowedFd<'_> {
205221
#[inline]

std/src/os/unix/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ pub fn chown<P: AsRef<Path>>(dir: P, uid: Option<u32>, gid: Option<u32>) -> io::
966966
///
967967
/// fn main() -> std::io::Result<()> {
968968
/// let f = std::fs::File::open("/file")?;
969-
/// fs::fchown(f, Some(0), Some(0))?;
969+
/// fs::fchown(&f, Some(0), Some(0))?;
970970
/// Ok(())
971971
/// }
972972
/// ```

std/src/os/windows/io/handle.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,22 @@ pub trait AsHandle {
316316
fn as_handle(&self) -> BorrowedHandle<'_>;
317317
}
318318

319+
#[unstable(feature = "io_safety", issue = "87074")]
320+
impl<T: AsHandle> AsHandle for &T {
321+
#[inline]
322+
fn as_handle(&self) -> BorrowedHandle<'_> {
323+
T::as_handle(self)
324+
}
325+
}
326+
327+
#[unstable(feature = "io_safety", issue = "87074")]
328+
impl<T: AsHandle> AsHandle for &mut T {
329+
#[inline]
330+
fn as_handle(&self) -> BorrowedHandle<'_> {
331+
T::as_handle(self)
332+
}
333+
}
334+
319335
impl AsHandle for BorrowedHandle<'_> {
320336
#[inline]
321337
fn as_handle(&self) -> BorrowedHandle<'_> {

std/src/os/windows/io/socket.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,22 @@ pub trait AsSocket {
210210
fn as_socket(&self) -> BorrowedSocket<'_>;
211211
}
212212

213+
#[unstable(feature = "io_safety", issue = "87074")]
214+
impl<T: AsSocket> AsSocket for &T {
215+
#[inline]
216+
fn as_socket(&self) -> BorrowedSocket<'_> {
217+
T::as_socket(self)
218+
}
219+
}
220+
221+
#[unstable(feature = "io_safety", issue = "87074")]
222+
impl<T: AsSocket> AsSocket for &mut T {
223+
#[inline]
224+
fn as_socket(&self) -> BorrowedSocket<'_> {
225+
T::as_socket(self)
226+
}
227+
}
228+
213229
impl AsSocket for BorrowedSocket<'_> {
214230
#[inline]
215231
fn as_socket(&self) -> BorrowedSocket<'_> {

std/src/sys/unix/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
159159
libc::ENOSPC => StorageFull,
160160
libc::ENOSYS => Unsupported,
161161
libc::EMLINK => TooManyLinks,
162-
libc::ENAMETOOLONG => FilenameTooLong,
162+
libc::ENAMETOOLONG => InvalidFilename,
163163
libc::ENETDOWN => NetworkDown,
164164
libc::ENETUNREACH => NetworkUnreachable,
165165
libc::ENOTCONN => NotConnected,

std/src/sys/windows/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
7171
c::ERROR_FILE_NOT_FOUND => return NotFound,
7272
c::ERROR_PATH_NOT_FOUND => return NotFound,
7373
c::ERROR_NO_DATA => return BrokenPipe,
74+
c::ERROR_INVALID_NAME => return InvalidFilename,
7475
c::ERROR_INVALID_PARAMETER => return InvalidInput,
7576
c::ERROR_NOT_ENOUGH_MEMORY | c::ERROR_OUTOFMEMORY => return OutOfMemory,
7677
c::ERROR_SEM_TIMEOUT
@@ -104,7 +105,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
104105
c::ERROR_POSSIBLE_DEADLOCK => return Deadlock,
105106
c::ERROR_NOT_SAME_DEVICE => return CrossesDevices,
106107
c::ERROR_TOO_MANY_LINKS => return TooManyLinks,
107-
c::ERROR_FILENAME_EXCED_RANGE => return FilenameTooLong,
108+
c::ERROR_FILENAME_EXCED_RANGE => return InvalidFilename,
108109
_ => {}
109110
}
110111

0 commit comments

Comments
 (0)