Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 68333bf

Browse files
committed
Auto merge of rust-lang#137547 - nabijaczleweli:gaming, r=<try>
Revert 00bf74d In service of rust-lang#137499 try-job: dist-x86_64-mingw try-job: dist-x86_64-msvc
2 parents 617aad8 + a172d4d commit 68333bf

File tree

6 files changed

+2566
-233
lines changed

6 files changed

+2566
-233
lines changed

library/std/src/fs.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,14 +2446,12 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
24462446
/// # Platform-specific behavior
24472447
///
24482448
/// This function currently corresponds to the `rename` function on Unix
2449-
/// and the `SetFileInformationByHandle` function on Windows.
2449+
/// and the `MoveFileEx` function with the `MOVEFILE_REPLACE_EXISTING` flag on Windows.
24502450
///
24512451
/// Because of this, the behavior when both `from` and `to` exist differs. On
24522452
/// Unix, if `from` is a directory, `to` must also be an (empty) directory. If
2453-
/// `from` is not a directory, `to` must also be not a directory. The behavior
2454-
/// on Windows is the same on Windows 10 1607 and higher if `FileRenameInfoEx`
2455-
/// is supported by the filesystem; otherwise, `from` can be anything, but
2456-
/// `to` must *not* be a directory.
2453+
/// `from` is not a directory, `to` must also be not a directory. In contrast,
2454+
/// on Windows, `from` can be anything, but `to` must *not* be a directory.
24572455
///
24582456
/// Note that, this [may change in the future][changes].
24592457
///

library/std/src/fs/tests.rs

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,77 +1913,3 @@ fn test_hidden_file_truncation() {
19131913
let metadata = file.metadata().unwrap();
19141914
assert_eq!(metadata.len(), 0);
19151915
}
1916-
1917-
// See https://github.com/rust-lang/rust/pull/131072 for more details about why
1918-
// these two tests are disabled under Windows 7 here.
1919-
#[cfg(windows)]
1920-
#[test]
1921-
#[cfg_attr(target_vendor = "win7", ignore = "Unsupported under Windows 7.")]
1922-
fn test_rename_file_over_open_file() {
1923-
// Make sure that std::fs::rename works if the target file is already opened with FILE_SHARE_DELETE. See #123985.
1924-
let tmpdir = tmpdir();
1925-
1926-
// Create source with test data to read.
1927-
let source_path = tmpdir.join("source_file.txt");
1928-
fs::write(&source_path, b"source hello world").unwrap();
1929-
1930-
// Create target file with test data to read;
1931-
let target_path = tmpdir.join("target_file.txt");
1932-
fs::write(&target_path, b"target hello world").unwrap();
1933-
1934-
// Open target file
1935-
let target_file = fs::File::open(&target_path).unwrap();
1936-
1937-
// Rename source
1938-
fs::rename(source_path, &target_path).unwrap();
1939-
1940-
core::mem::drop(target_file);
1941-
assert_eq!(fs::read(target_path).unwrap(), b"source hello world");
1942-
}
1943-
1944-
#[test]
1945-
#[cfg(windows)]
1946-
#[cfg_attr(target_vendor = "win7", ignore = "Unsupported under Windows 7.")]
1947-
fn test_rename_directory_to_non_empty_directory() {
1948-
// Renaming a directory over a non-empty existing directory should fail on Windows.
1949-
let tmpdir: TempDir = tmpdir();
1950-
1951-
let source_path = tmpdir.join("source_directory");
1952-
let target_path = tmpdir.join("target_directory");
1953-
1954-
fs::create_dir(&source_path).unwrap();
1955-
fs::create_dir(&target_path).unwrap();
1956-
1957-
fs::write(target_path.join("target_file.txt"), b"target hello world").unwrap();
1958-
1959-
error!(fs::rename(source_path, target_path), 145); // ERROR_DIR_NOT_EMPTY
1960-
}
1961-
1962-
#[test]
1963-
fn test_rename_symlink() {
1964-
let tmpdir = tmpdir();
1965-
let original = tmpdir.join("original");
1966-
let dest = tmpdir.join("dest");
1967-
let not_exist = Path::new("does not exist");
1968-
1969-
symlink_file(not_exist, &original).unwrap();
1970-
fs::rename(&original, &dest).unwrap();
1971-
// Make sure that renaming `original` to `dest` preserves the symlink.
1972-
assert_eq!(fs::read_link(&dest).unwrap().as_path(), not_exist);
1973-
}
1974-
1975-
#[test]
1976-
#[cfg(windows)]
1977-
fn test_rename_junction() {
1978-
let tmpdir = tmpdir();
1979-
let original = tmpdir.join("original");
1980-
let dest = tmpdir.join("dest");
1981-
let not_exist = Path::new("does not exist");
1982-
1983-
junction_point(&not_exist, &original).unwrap();
1984-
fs::rename(&original, &dest).unwrap();
1985-
1986-
// Make sure that renaming `original` to `dest` preserves the junction point.
1987-
// Junction links are always absolute so we just check the file name is correct.
1988-
assert_eq!(fs::read_link(&dest).unwrap().file_name(), Some(not_exist.as_os_str()));
1989-
}

library/std/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@
174174
//!
175175
//! - after-main use of thread-locals, which also affects additional features:
176176
//! - [`thread::current()`]
177-
//! - before-main stdio file descriptors are not guaranteed to be open on unix platforms
177+
//! - under UNIX, before main, file descriptors 0, 1, and 2 may be unchanged
178+
//! (they are guaranteed to be open during main,
179+
//! and are opened to /dev/null O_RDWR if they weren't open on program start)
178180
//!
179181
//!
180182
//! [I/O]: io

0 commit comments

Comments
 (0)