Add #[must_use] to FileTimes::set_accessed and set_modified#152522
Add #[must_use] to FileTimes::set_accessed and set_modified#152522yashhzd wants to merge 1 commit intorust-lang:mainfrom
Conversation
These methods take `self` by value and return `Self` (builder pattern). Without `#[must_use]`, calling `ft.set_modified(time)` without using the return value silently does nothing, which is a common mistake. Fixes rust-lang#152231
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
|
there is already a PR for it: #152232 |
|
Hi. It looks like you used an LLM without reviewing its output sufficiently. At that point we become the reviewer of the LLM output, with you relaying our reviews back to the LLM as a proxy. That is a lot of work without a clear benefit, while being also frustrating for reviewers. I am thus closing and locking this PR. This is a moderation warning. Repeated instances of such comments or contributions will result in a ban from our project. You can contact the moderation team to discuss your warning. |
Summary
FileTimes::set_accessedandFileTimes::set_modifiedtakeselfby value and returnSelf(builder pattern). Without#[must_use], callingft.set_modified(time)without using the return value silently does nothing, which is a common source of bugs.This PR adds
#[must_use]to both methods so that the compiler warns when the return value is discarded.Example of the bug this prevents:
With this change, the compiler will emit a warning for the above code, guiding users to use the builder pattern correctly:
Fixes #152231