Skip to content

fs::rename fails when dest exists only on windows #31301

Closed
@brson

Description

@brson

This code fails on windows, not on linux:

use std::fs;

fn main() {
    let src = "testdir1";
    let dest = "testdir2";
    fs::create_dir(src).unwrap();
    fs::create_dir(dest).unwrap();
    fs::rename(src, dest).unwrap();
}

with

thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 5, message: "Access is denied." } }', ../src/libcore\result.rs:741

Metadata

Metadata

Assignees

No one assigned

    Labels

    O-windowsOperating system: Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions