Skip to content

Path still exists after remove successful on windows7 SP1 #112139

Closed as not planned

Description

The Rust 1.69 update broke some fairly simple unit tests we have that runs on Windows7 SP1. Removing a file using std::fs::remove_file, and subsequently checking if it exists using Path::exists, will inexplicably return that the path still exists, instead of returning false.

Note that this behavior is not reproduced on Windows10, only on Windows7.

Code

use std::env;
use std::fs::File;
use std::path::Path;

fn main() {
    let path = env::temp_dir().join("tempfile.txt");
    let f = File::create(&path);
    std::fs::remove_file(&path).unwrap();
    assert!(!path.exists());
    println!("Path does not exist anymore");
}

I expected to see this happen: The assertion succeeds, and "Path does not exist anymore" is printed.

Instead, this happened: The assertion fails, rust believes that the path still exists.

Version it worked on

It most recently worked on Rust 1.68.2

Version with regression

rustc --version --verbose:

rustc 1.69.0 (84c898d65 2023-04-16)
binary: rustc
commit-hash: 84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc
commit-date: 2023-04-16
host: aarch64-apple-darwin
release: 1.69.0
LLVM version: 15.0.7

@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`C-bugCategory: This is a bug.O-windowsOperating system: WindowsP-lowLow priorityT-libsRelevant to the library team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions