Skip to content

Conversation

0xdeafbeef
Copy link
Contributor

@0xdeafbeef 0xdeafbeef commented Aug 5, 2025

Fixes #140621

@rustbot
Copy link
Collaborator

rustbot commented Aug 5, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
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

@rustbot rustbot added 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 5, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 5, 2025

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

  • This PR is based on an upstream commit that is 618 days old.

    It's recommended to update your branch according to the rustc-dev-guide.

@0xdeafbeef
Copy link
Contributor Author

oops somehow i've untracked remote master, will rebase rn. Sorry

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@0xdeafbeef
Copy link
Contributor Author

@ibraheemdev friendly ping :)

@ibraheemdev
Copy link
Member

Do the tests pass before applying this change (is this a change in behavior)?

@0xdeafbeef
Copy link
Contributor Author

Do the tests pass before applying this change (is this a change in behavior)?

I've only changed the error message; the behavior is the same.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=7b7613497935f70189a3118735e491cf

You can't do anything meaningful when setting these flags, except trigger a validation error.

With my changes, you still get a validation error as before, but now it tells you what’s wrong instead of making you open strace/gdb :)

@ibraheemdev
Copy link
Member

I'm slightly concerned about keeping the message consistent across platforms, but we seem to do the same thing for other error conditions, so this seems fine. @bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 29, 2025

📌 Commit de61934 has been approved by ibraheemdev

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 29, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 29, 2025
…aheemdev

std: clarify `OpenOptions` error for create without write access

Fixes rust-lang#140621
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 29, 2025
…aheemdev

std: clarify `OpenOptions` error for create without write access

Fixes rust-lang#140621
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 29, 2025
…aheemdev

std: clarify `OpenOptions` error for create without write access

Fixes rust-lang#140621
bors added a commit that referenced this pull request Aug 29, 2025
Rollup of 6 pull requests

Successful merges:

 - #144964 (std: clarify `OpenOptions` error for create without write access)
 - #145242 (std: use a TAIT to define `SplitPaths` on UNIX)
 - #145467 (Stabilize `strict_provenance_atomic_ptr` feature)
 - #145990 (`AutoDeref::final_ty` is already resolved)
 - #145991 (std: haiku: fix `B_FIND_PATH_IMAGE_PATH`)
 - #146000 (Improve librustdoc error when a file creation/modification failed)

r? `@ghost`
`@rustbot` modify labels: rollup
tgross35 added a commit to tgross35/rust that referenced this pull request Aug 29, 2025
…aheemdev

std: clarify `OpenOptions` error for create without write access

Fixes rust-lang#140621
tgross35 added a commit to tgross35/rust that referenced this pull request Aug 29, 2025
…aheemdev

std: clarify `OpenOptions` error for create without write access

Fixes rust-lang#140621
@tgross35
Copy link
Contributor

Think this may have failed #146014 (comment)

@bors r-
@bors2 try jobs=aarch64-msvc-1

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 30, 2025
@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 30, 2025
std: clarify `OpenOptions` error for create without write access

try-job: aarch64-msvc-1
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Aug 30, 2025

💔 Test for 4d9eaea failed: CI. Failed jobs:

@rustbot
Copy link
Collaborator

rustbot commented Aug 30, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Previously, attempting to create/truncate a file without write/append access
would result in platform-specific error messages:
 - Unix: "Invalid argument"
 - Windows: raw OS error code 87
These error codes look like system errors, which could waste hours 
of debugging for what is actually an API misuse issue.
@0xdeafbeef
Copy link
Contributor Author

it failed because of different error! behavior on unix and windows

macro_rules! error {
($e:expr, $s:expr) => {
match $e {
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
Err(ref err) => {
assert!(err.raw_os_error() == Some($s), "`{}` did not have a code of `{}`", err, $s)
}
}
};
}
#[cfg(unix)]
macro_rules! error {
($e:expr, $s:expr) => {
error_contains!($e, $s)
};
}

Now i directly use error_contains!

@0xdeafbeef
Copy link
Contributor Author

@bors2 try jobs=aarch64-msvc-1

@rust-bors
Copy link

rust-bors bot commented Aug 30, 2025

@0xdeafbeef: 🔑 Insufficient privileges: not in try users

@0xdeafbeef
Copy link
Contributor Author

@tgross35 can you trigger windows build? should pass now

@tgross35
Copy link
Contributor

@bors2 try jobs=aarch64-msvc-1

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 30, 2025
std: clarify `OpenOptions` error for create without write access

try-job: aarch64-msvc-1
@rust-bors
Copy link

rust-bors bot commented Aug 30, 2025

☀️ Try build successful (CI)
Build commit: 86c30e6 (86c30e619d775841d7969fb536b34ef309901a4d, parent: 0f506968010fa987b0d134034d0ccab9eecd9120)

@tgross35
Copy link
Contributor

@bors r=ibraheemdev

@bors
Copy link
Collaborator

bors commented Aug 30, 2025

📌 Commit 0858b14 has been approved by ibraheemdev

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 30, 2025
bors added a commit that referenced this pull request Aug 30, 2025
Rollup of 4 pull requests

Successful merges:

 - #144964 (std: clarify `OpenOptions` error for create without write access)
 - #146030 (Fix `sys::process::windows::tests::test_thread_handle` spurious failure)
 - #146035 (Update `browser-ui-test` version to `0.21.3`)
 - #146036 (Use move_file for rename in tracing)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9489339 into rust-lang:master Aug 31, 2025
11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 31, 2025
rust-timer added a commit that referenced this pull request Aug 31, 2025
Rollup merge of #144964 - 0xdeafbeef:fix-open-options, r=ibraheemdev

std: clarify `OpenOptions` error for create without write access

Fixes #140621
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

OpenOptions::open InvalidInput error for read(true).create(true) is unclear (or check is redundant)
6 participants