diff options
| author | Jubilee Young <workingjubilee@gmail.com> | 2024-07-14 17:14:55 -0700 |
|---|---|---|
| committer | Jubilee Young <workingjubilee@gmail.com> | 2024-07-14 17:17:55 -0700 |
| commit | df353a0cc3eaf66c496e07232ceb06a91fc10e67 (patch) | |
| tree | a3cfa6aca024d52a788ffe49e0b7db1f4eff2ac4 /library/std/src/io/mod.rs | |
| parent | 83a0fe53967ef12411cb7f954a7ad52bee20dc56 (diff) | |
| download | rust-df353a0cc3eaf66c496e07232ceb06a91fc10e67.tar.gz rust-df353a0cc3eaf66c496e07232ceb06a91fc10e67.zip | |
std: Unsafe-wrap std::io
Diffstat (limited to 'library/std/src/io/mod.rs')
| -rw-r--r-- | library/std/src/io/mod.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index d69c98ce79e..1345a30361e 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -293,7 +293,6 @@ //! [`Arc`]: crate::sync::Arc #![stable(feature = "rust1", since = "1.0.0")] -#![allow(unsafe_op_in_unsafe_fn)] #[cfg(test)] mod tests; @@ -383,11 +382,11 @@ pub(crate) unsafe fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize where F: FnOnce(&mut Vec<u8>) -> Result<usize>, { - let mut g = Guard { len: buf.len(), buf: buf.as_mut_vec() }; + let mut g = Guard { len: buf.len(), buf: unsafe { buf.as_mut_vec() } }; let ret = f(g.buf); // SAFETY: the caller promises to only append data to `buf` - let appended = g.buf.get_unchecked(g.len..); + let appended = unsafe { g.buf.get_unchecked(g.len..) }; if str::from_utf8(appended).is_err() { ret.and_then(|_| Err(Error::INVALID_UTF8)) } else { |
