Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
503ceda
Test that maplike FromIter satisfies uniqueness
nhynes Jul 16, 2019
f22bc2d
Suggest trait bound on type parameter when it is unconstrained
estebank Jul 17, 2019
48b6069
Fix typo in src/libstd/net/udp.rs doc comment
Indy2222 Jul 18, 2019
886fb21
normalize use of backticks in compiler messages for libcore/ptr
Jul 18, 2019
33452b0
warn about deprecated-in-future in most of libstd
RalfJung Jul 17, 2019
13ed0cf
do not use mem::uninitialized in std::io
RalfJung Jul 17, 2019
7c1e405
ONCE_INIT is deprecated-in-future only for bootstrap
RalfJung Jul 17, 2019
469b7a9
rustc_typeck: improve diagnostics for _ const/static declarations
lundibundi Jul 18, 2019
c6735a6
fixup! rustc_typeck: improve diagnostics for _ const/static declarations
lundibundi Jul 19, 2019
10d4159
Revert "Disable stack probing for gnux32."
crlf0710 Jul 19, 2019
f5b2859
Handle more cases of typos misinterpreted as type ascription
estebank Jul 17, 2019
9dbe2e7
review comments
estebank Jul 19, 2019
b361864
fixup! rustc_typeck: improve diagnostics for _ const/static declarations
lundibundi Jul 19, 2019
c1b4d62
rustc: Compile the `fmt_macros` crate as an rlib
alexcrichton Jul 19, 2019
c6e027d
fixup! rustc_typeck: improve diagnostics for _ const/static declarations
lundibundi Jul 19, 2019
19a848d
normalize use of backticks in compiler messages for librustc_metadata
Jul 19, 2019
60ca55c
normalize use of backticks in compiler messages for librustc_incremental
Jul 20, 2019
eb1f631
Rollup merge of #62709 - nhynes:test-maplike-fromiter, r=cuviper
Centril Jul 21, 2019
9182b70
Rollup merge of #62746 - RalfJung:deprecated, r=KodrAus
Centril Jul 21, 2019
785acaf
Rollup merge of #62772 - estebank:trait-bound, r=matthewjasper
Centril Jul 21, 2019
c8c401a
Rollup merge of #62787 - Indy2222:master, r=Mark-Simulacrum
Centril Jul 21, 2019
8d91abc
Rollup merge of #62788 - fakenine:normalize_use_of_backticks_compiler…
Centril Jul 21, 2019
38532ae
Rollup merge of #62791 - estebank:type-ascription, r=petrochenkov
Centril Jul 21, 2019
a82c60b
Rollup merge of #62804 - lundibundi:help-infer-const-static, r=eddyb
Centril Jul 21, 2019
cc8ae62
Rollup merge of #62808 - crlf0710:gnux32_stack_probe, r=nikic
Centril Jul 21, 2019
a343f7d
Rollup merge of #62812 - fakenine:normalize_use_of_backticks_compiler…
Centril Jul 21, 2019
b7d136f
Rollup merge of #62813 - alexcrichton:less-dylib, r=Mark-Simulacrum
Centril Jul 21, 2019
6558b98
Rollup merge of #62832 - fakenine:normalize_use_of_backticks_compiler…
Centril Jul 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
do not use mem::uninitialized in std::io
  • Loading branch information
RalfJung committed Jul 19, 2019
commit 13ed0cf9e86a4fdbf75152849353050fea5d4461
7 changes: 4 additions & 3 deletions src/libcore/fmt/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ fn float_to_decimal_common_exact<T>(fmt: &mut Formatter<'_>, num: &T,
unsafe {
let mut buf = MaybeUninit::<[u8; 1024]>::uninit(); // enough for f32 and f64
let mut parts = MaybeUninit::<[flt2dec::Part<'_>; 4]>::uninit();
// FIXME(#53491): Technically, this is calling `get_mut` on an uninitialized
// `MaybeUninit` (here and elsewhere in this file). Revisit this once
// FIXME(#53491): This is calling `get_mut` on an uninitialized
// `MaybeUninit` (here and elsewhere in this file). Revisit this once
// we decided whether that is valid or not.
// Using `freeze` is *not enough*; `flt2dec::Part` is an enum!
// We can do this only because we are libstd and coupled to the compiler.
// (FWIW, using `freeze` would not be enough; `flt2dec::Part` is an enum!)
let formatted = flt2dec::to_exact_fixed_str(flt2dec::strategy::grisu::format_exact,
*num, sign, precision,
false, buf.get_mut(), parts.get_mut());
Expand Down
24 changes: 10 additions & 14 deletions src/libstd/io/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::fmt;
use crate::io::{self, Read, Initializer, Write, ErrorKind, BufRead, IoSlice, IoSliceMut};
use crate::mem;
use crate::mem::MaybeUninit;

/// Copies the entire contents of a reader into a writer.
///
Expand Down Expand Up @@ -43,27 +43,23 @@ use crate::mem;
pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<u64>
where R: Read, W: Write
{
let mut buf = unsafe {
// This is still technically undefined behavior due to creating a reference
// to uninitialized data, but within libstd we can rely on more guarantees
// than if this code were in an external lib

// FIXME: This should probably be changed to an array of `MaybeUninit<u8>`
// once the `mem::MaybeUninit` slice APIs stabilize
let mut buf: mem::MaybeUninit<[u8; super::DEFAULT_BUF_SIZE]> = mem::MaybeUninit::uninit();
reader.initializer().initialize(&mut *buf.as_mut_ptr());
buf.assume_init()
};
let mut buf = MaybeUninit::<[u8; super::DEFAULT_BUF_SIZE]>::uninit();
// FIXME(#53491): This is calling `get_mut` and `get_ref` on an uninitialized
// `MaybeUninit`. Revisit this once we decided whether that is valid or not.
// This is still technically undefined behavior due to creating a reference
// to uninitialized data, but within libstd we can rely on more guarantees
// than if this code were in an external lib
unsafe { reader.initializer().initialize(buf.get_mut()); }

let mut written = 0;
loop {
let len = match reader.read(&mut buf) {
let len = match reader.read(unsafe { buf.get_mut() }) {
Ok(0) => return Ok(written),
Ok(len) => len,
Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
Err(e) => return Err(e),
};
writer.write_all(&buf[..len])?;
writer.write_all(unsafe { &buf.get_ref()[..len] })?;
written += len as u64;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@
#![feature(libc)]
#![feature(link_args)]
#![feature(linkage)]
#![feature(maybe_uninit_ref)]
#![feature(mem_take)]
#![feature(needs_panic_runtime)]
#![feature(never_type)]
Expand Down