rust-lang / rust-lang/rust

Windows implementation of `Dir::rename` resolves `from` path without considering `self` at all

Open
#163,022 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

The actual rename is fine, but there is an is_dir call that's wrong:

https://github.com/rust-lang/rust/blob/fc4de336c52e2d2135e872264867c90cf3a52fe1/library/std/src/sys/fs/windows/dir.rs#L89-L94

This is needed because open_file_native apparently needs to know whether the file it opens inside a Dir is a directory or not. That seems odd? Obviously in reality we might not be able to know this...

https://github.com/rust-lang/rust/blob/fc4de336c52e2d2135e872264867c90cf3a52fe1/library/std/src/sys/fs/windows/dir.rs#L139-L148

Cc @ChrisDenton @Qelxiros
Tracking issue: https://github.com/rust-lang/rust/issues/120426

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in library/std/src/sys/fs/windows/dir.rs, especially the is_dir call at lines 89-94 and open_file_native at lines 139-148. Trace how Dir::rename resolves its from path relative to self and why open_file_native needs directory information; done means the Windows implementation handles the directory-relative source path correctly, with behavior checked against the tracking issue #120426.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.