-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Rollup of 13 pull requests #101115
Rollup of 13 pull requests #101115
Conversation
A colleague mentioned that they interpreted the old text as saying that only the pointer and the length are copied. Add a clause so it is more clear that the pointed to contents are also copied.
Signed-off-by: Nick Cameron <[email protected]>
Signed-off-by: Nick Cameron <[email protected]>
Signed-off-by: Nick Cameron <[email protected]>
Aids the discoverability of `io::Error::last_os_error()` by linking to commonly used error number functions from C/C++.
Signed-off-by: Nick Cameron <[email protected]>
This was missed in rust-lang#100642
Signed-off-by: Nick Cameron <[email protected]>
Signed-off-by: Nick Cameron <[email protected]>
Signed-off-by: Nick Cameron <[email protected]>
I wrote this code in 2017 back when std::fs::write wasn't available. Also, use the t macro from tidy.
std::io: migrate ReadBuf to BorrowBuf/BorrowCursor This PR replaces `ReadBuf` (used by the `Read::read_buf` family of methods) with `BorrowBuf` and `BorrowCursor`. The general idea is to split `ReadBuf` because its API is large and confusing. `BorrowBuf` represents a borrowed buffer which is mostly read-only and (other than for construction) deals only with filled vs unfilled segments. a `BorrowCursor` is a mostly write-only view of the unfilled part of a `BorrowBuf` which distinguishes between initialized and uninitialized segments. For `Read::read_buf`, the caller would create a `BorrowBuf`, then pass a `BorrowCursor` to `read_buf`. In addition to the major API split, I've made the following smaller changes: * Removed some methods entirely from the API (mostly the functionality can be replicated with two calls rather than a single one) * Unified naming, e.g., by replacing initialized with init and assume_init with set_init * Added an easy way to get the number of bytes written to a cursor (`written` method) As well as simplifying the API (IMO), this approach has the following advantages: * Since we pass the cursor by value, we remove the 'unsoundness footgun' where a malicious `read_buf` could swap out the `ReadBuf`. * Since `read_buf` cannot write into the filled part of the buffer, we prevent the filled part shrinking or changing which could cause underflow for the caller or unexpected behaviour. ## Outline ```rust pub struct BorrowBuf<'a> impl Debug for BorrowBuf<'_> impl<'a> From<&'a mut [u8]> for BorrowBuf<'a> impl<'a> From<&'a mut [MaybeUninit<u8>]> for BorrowBuf<'a> impl<'a> BorrowBuf<'a> { pub fn capacity(&self) -> usize pub fn len(&self) -> usize pub fn init_len(&self) -> usize pub fn filled(&self) -> &[u8] pub fn unfilled<'this>(&'this mut self) -> BorrowCursor<'this, 'a> pub fn clear(&mut self) -> &mut Self pub unsafe fn set_init(&mut self, n: usize) -> &mut Self } pub struct BorrowCursor<'buf, 'data> impl<'buf, 'data> BorrowCursor<'buf, 'data> { pub fn clone<'this>(&'this mut self) -> BorrowCursor<'this, 'data> pub fn capacity(&self) -> usize pub fn written(&self) -> usize pub fn init_ref(&self) -> &[u8] pub fn init_mut(&mut self) -> &mut [u8] pub fn uninit_mut(&mut self) -> &mut [MaybeUninit<u8>] pub unsafe fn as_mut(&mut self) -> &mut [MaybeUninit<u8>] pub unsafe fn advance(&mut self, n: usize) -> &mut Self pub fn ensure_init(&mut self) -> &mut Self pub unsafe fn set_init(&mut self, n: usize) -> &mut Self pub fn append(&mut self, buf: &[u8]) } ``` ## TODO * ~~Migrate non-unix libs and tests~~ * ~~Naming~~ * ~~`BorrowBuf` or `BorrowedBuf` or `SliceBuf`? (We might want an owned equivalent for the async IO traits)~~ * ~~Should we rename the `readbuf` module? We might keep the name indicate it includes both the buf and cursor variations and someday the owned version too. Or we could change it. It is not publicly exposed, so it is not that important~~. * ~~`read_buf` method: we read into the cursor now, so the `_buf` suffix is a bit weird.~~ * ~~Documentation~~ * Tests are incomplete (I adjusted existing tests, but did not add new ones). cc rust-lang#78485, rust-lang#94741 supersedes: rust-lang#95770, rust-lang#93359 fixes rust-lang#93305
…sleywiser Add GDB/LLDB pretty-printers for NonZero types Add GDB/LLDB pretty-printers for `NonZero` types. These pretty-printers were originally implemented for IntelliJ Rust by ```@Kobzol``` in intellij-rust/intellij-rust#5270. Part of rust-lang#29392.
Box::from(slice): Clarify that contents are copied A colleague mentioned that they interpreted the old text as saying that only the pointer and the length are copied. Add a clause so it is more clear that the pointed to contents are also copied.
…homcc Add standard C error function aliases to last_os_error This aids the discoverability of `io::Error::last_os_error()` by linking to commonly used error number functions from C/C++. I've seen a few people not realize this exists, so hopefully this helps draw attention to the API to encourage using it over integer error codes.
Add mention of `BufReader` in `Read::bytes` docs There is a general paragraph about `BufRead` in the `Read` trait's docs, however using `bytes` without `BufRead` *always* has a large impact, due to reads of size 1. `@rustbot` label +A-docs
…, r=Mark-Simulacrum Export Cancel from std::os::fortanix_sgx::usercalls::raw This was missed in rust-lang#100642 cc ``@raoulstrackx`` and ``@jethrogb``
Some papercuts on error::Error Renames the chain method, since I chain could mean anything and doesn't refer to a chain of sources (cc rust-lang#58520) (and adds a comment explaining why sources is not a provided method on Error). Renames arguments to the request method from `req` to `demand` since the type is `Demand` rather than Request or Requisition. r? ``@yaahc``
Provide structured suggestion for `hashmap[idx] = val`
…i-obk no alignment check during interning This should fix rust-lang#101034 r? `@oli-obk` Unfortunately we don't have a self-contained testcase for this problem. I am not sure how it can be triggered...
…er-errors Use smaller span for suggestions
Extend attrs if local_def_id exists Fixes rust-lang#101076
rustc_middle: Remove `Visibility::Invisible` It had a different meaning in the past, but now it's only used as an implementation detail of import resolution.
…ark-Simulacrum unstable-book-gen: use std::fs::write I wrote this code in 2017 back when std::fs::write wasn't available. Also, use the t macro from tidy.
@bors r+ rollup=never p=13 |
☀️ Test successful - checks-actions |
📌 Perf builds for each rolled up PR: previous master: d5ef528beb In the case of a perf regression, run the following command for each PR you suspect might be the cause: |
Finished benchmarking commit (3fdd578): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
Footnotes |
Successful merges:
BufReader
inRead::bytes
docs #100520 (Add mention ofBufReader
inRead::bytes
docs)hashmap[idx] = val
#101002 (Provide structured suggestion forhashmap[idx] = val
)Visibility::Invisible
#101098 (rustc_middle: RemoveVisibility::Invisible
)Failed merges:
r? @ghost
@rustbot modify labels: rollup
Create a similar rollup