Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially revert #107200 #114897

Merged
merged 1 commit into from
Aug 18, 2023
Merged

Conversation

joshtriplett
Copy link
Member

Ok(0) is indeed something the caller may interpret as an error, but
that's the correct thing to return if the writer can't accept any more
bytes.

`Ok(0)` is indeed something the caller may interpret as an error, but
that's the *correct* thing to return if the writer can't accept any more
bytes.
@rustbot
Copy link
Collaborator

rustbot commented Aug 16, 2023

r? @m-ou-se

(rustbot has picked a reviewer for you, use r? to override)

@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 16, 2023
@cuviper cuviper added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Aug 16, 2023
@mina86
Copy link
Contributor

mina86 commented Aug 16, 2023

but that's the correct thing to return if the writer can't accept any more bytes.

I have no voting power but nonetheless I’m strongly against such API.

@joshtriplett
Copy link
Member Author

@mina86 It's the current stable API in std's own implementations of Write (such as for &mut [u8]), and it seems to be what at least some callers of write expect. As identified in #107200 (comment) it seems like it'd be a breaking change for std's own implementations of Write to change this behavior.

@mina86
Copy link
Contributor

mina86 commented Aug 16, 2023

$ cat src/main.rs
use std::io::Write;

fn main() -> std::io::Result<()> {
    let buf = [0; 1024 * 1024];
    let mut file = std::fs::File::create("/mnt/foo")?;
    loop {
        eprintln!("{}", file.write(&buf)?);
    }
}
$ cargo run
    Finished dev [unoptimized] target(s) in 0.00s
     Running `target/debug/a`
913408
Error: Os { code: 28, kind: StorageFull, message: "No space left on device" }

No matter how you slice it, std is inconsistent. With StorageFull finally being added, we can change the documentation to encourage its use and consistency in future code.

@joshtriplett
Copy link
Member Author

StorageFull is being used correctly there: it's returned by the OS for a full disk, and Rust passes it along to the caller.

@m-ou-se
Copy link
Member

m-ou-se commented Aug 17, 2023

@mina86 We're not reverting this to say that write should be returning Ok(0) for "out of storage", but because there already is plenty of code that returns Ok(0) for EOF (including the raw OS APIs), which a caller should be able to handle.

That doesn't mean that the resulting wording in the docs here is final. We might still want to add a note that recommends using a StorageFull error in certain cases, for example. (But that's something for after the 1.72 release. And probably only when ErrorKind::StorageFull itself is stable.)

@bors r+

@bors
Copy link
Contributor

bors commented Aug 17, 2023

📌 Commit 5210f48 has been approved by m-ou-se

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 17, 2023
@m-ou-se m-ou-se added beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 17, 2023
@bors
Copy link
Contributor

bors commented Aug 17, 2023

⌛ Testing commit 5210f48 with merge a9270420c3e25469f73da2c3a5a4db03c6d286bc...

@bors
Copy link
Contributor

bors commented Aug 17, 2023

☀️ Test successful - checks-actions
Approved by: m-ou-se
Pushing a9270420c3e25469f73da2c3a5a4db03c6d286bc to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 17, 2023
@bors
Copy link
Contributor

bors commented Aug 17, 2023

👀 Test was successful, but fast-forwarding failed: 422 Update is not a fast forward

@cuviper
Copy link
Member

cuviper commented Aug 17, 2023

@bors retry

@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 17, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a9270420c3e25469f73da2c3a5a4db03c6d286bc): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.4% [0.4%, 0.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [0.4%, 0.4%] 1

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.3% [-3.8%, -2.3%] 3
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 634.954s -> 633.803s (-0.18%)
Artifact size: 347.10 MiB -> 347.16 MiB (0.02%)

@cuviper
Copy link
Member

cuviper commented Aug 17, 2023

@bors rollup

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 18, 2023
Rollup of 5 pull requests

Successful merges:

 - rust-lang#113715 (Unstable Book: update `lang_items` page and split it)
 - rust-lang#114897 (Partially revert rust-lang#107200)
 - rust-lang#114913 (Fix suggestion for attempting to define a string with single quotes)
 - rust-lang#114931 (Revert PR rust-lang#114052 to fix invalid suggestion)
 - rust-lang#114944 (update `thiserror` to version >= 1.0.46)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4f14451 into rust-lang:master Aug 18, 2023
11 checks passed
@rustbot rustbot added this to the 1.73.0 milestone Aug 18, 2023
@cuviper cuviper mentioned this pull request Aug 18, 2023
@cuviper cuviper modified the milestones: 1.73.0, 1.72.0 Aug 18, 2023
@cuviper cuviper removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Aug 18, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 18, 2023
[beta] backports

* Upgrade std to gimli 0.28.0 rust-lang#114825
* Partially revert rust-lang#107200 rust-lang#114897
* Permit pre-evaluated constants in simd_shuffle rust-lang#113529

r? cuviper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. merged-by-bors This PR was explicitly merged by bors. 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.

7 participants