Document Error::{new,other} as to be avoided in pre_exec #148971
+5
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a mistake I've found in many projects on GitHub and made myself. It's obvious that
Error::new/Error::otherallocate when you look at their signatures, and it's obvious that thepre_execclosure shouldn't allocate, but when you're asked to write a closure that returns a specific type, you don't expect its main constructor to be problematic.I've included the list of 71 affected projects in a spoiler, though I don't expect anyone to look through it closely. It includes popular projects like alacritty, pika-backup, rio, rpm-ostree, and headcrab, as well as many smaller ones. For the most part, the snippets I've found are careful to only call functions from
libc,nix, orrustix, so it's not a case of general incompetence, but something that just slipped through the cracks.This docs section is already cluttered, so I've kept it terse.
If this is merged, I'd like to mass-post issues to the affected projects linking to this PR as a centralized source of information and place for discussion. Are there any objections about that?
@rustbot label +A-docs +A-process +O-unix +T-libs-api
List of affected projects
Format: links (witness of multi-threading)
tokio::main)thread::spawn)tokio::main)library)thread::spawn)tokio::runtime::Builder::new_multi_thread)tokio::main)actix_rt::main)thread::Builder::new)none)thread::spawn)tokio::main)thread::spawn)tokio::main)library)none)tokio::main)tokio::main)library)none)tokio::main)library)thread::spawn)tokio::runtime::Runtime::new())thread::spawn)tokio::main)thread::spawn)tokio::main)library)tokio::main)thread::spawn)thread::spawn)tokio::main)thread::spawn)thread::spawn)thread::spawn)tokio::main)tokio::main)none)none)thread::spawn)thread::spawn)tokio::main)async_std::task::spawn)tokio::main)tokio::main)library)none)thread::spawn)library)thread::spawn)thread::spawn)gtk)thread::spawn)library)library)thread::spawn)thread::spawn)library)library)thread::spawn)tokio::main)tokio::main)tokio::main)none)tokio::main)library)tokio::main)none)tokio::main)library)