Skip to content

Adding diagnostic item markers for multiple fs functions and structs - #160489

Open
asder8215 wants to merge 1 commit into
rust-lang:mainfrom
asder8215:fs_diagnostic_items
Open

Adding diagnostic item markers for multiple fs functions and structs#160489
asder8215 wants to merge 1 commit into
rust-lang:mainfrom
asder8215:fs_diagnostic_items

Conversation

@asder8215

Copy link
Copy Markdown
Contributor

A couple months ago there were a good number of TOCTOU/other filesystem lint issues created by @estebank in the clippy repo such as:

(There are more TOCTOU/filesystem bug lints that could be made aside from the list above, e.g. with symlinks).

I was particularly interested in working on the last issue on file creation followed by setting permissions. However, I don't think I could start working on it without diagnostic items on filesystem functions like fs::set_permissions or fs::create_dir_all. I decided to put diagnostic item attributes on all the filesystem functions and a couple of the structs because they may be useful in creating clippy lints against TOCTOU bugs or other relevant filesystem operation bugs.

@rustbot

rustbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

r? @clarfonthey

rustbot has assigned @clarfonthey.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 13 candidates
  • Random selection from 6 candidates

@rustbot rustbot added O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-wasm Target: WASM (WebAssembly), http://webassembly.org/ O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 4, 2026
@clarfonthey

Copy link
Copy Markdown
Contributor

Sorry for taking a bit to get to this, but this looks fine to me. I assume that the cfg_attr(not(test), …) is because in those cases, std is doubled (compiler std + currently-tested `std) and it messes things up?

@asder8215

Copy link
Copy Markdown
Contributor Author

I assume that the cfg_attr(not(test), …) is because in those cases, std is doubled (compiler std + currently-tested `std) and it messes things up?

I'm not sure why the cfg_attr(not(test), ...), I just took this off how it's done for other filesystem functions/structs (e.g. create_dir is marked with #[cfg_attr(not(test), rustc_diagnostic_item = "fs_create_dir")]). I figured that was the pattern we should follow with adding diagnostic items to fs functions/structs.

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

Labels

O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-wasm Target: WASM (WebAssembly), http://webassembly.org/ O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants