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

Rollup of 7 pull requests #59692

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f48a5dc
Document std::fs::File close behavior ignoring errors
czipperz Mar 27, 2019
d8a6b63
update stdsimd
RalfJung Mar 30, 2019
25e4447
renamed `inner_deref` feature's `deref*()` methods `as_deref*()` as p…
Xandkeeper Apr 1, 2019
b6ebe1b
Document using `sync_all`
czipperz Apr 2, 2019
e1fb2b7
added `deref_mut_*` versions of `inner_deref` methods as per discussi…
Xandkeeper Apr 1, 2019
e71e71b
fixed breaking changes
Xandkeeper Apr 2, 2019
76e82d6
Link to sync_all
czipperz Apr 3, 2019
5e3b1fc
update miri
RalfJung Mar 30, 2019
087999e
try to fix rand feature flags
RalfJung Mar 31, 2019
c75a5a2
update miri
RalfJung Apr 3, 2019
c2e0d7f
Never return uninhabited values at all
cuviper Apr 3, 2019
a969d40
File: Add documentation about dropping to sync_all
czipperz Apr 4, 2019
4c9c2cf
Add description for -Os and -Oz in rustc.1
tesuji Apr 4, 2019
42d652e
Disable stack probing for gnux32.
crlf0710 Apr 4, 2019
bfb7f34
Rollup merge of #59470 - czipperz:document-fs-file-close, r=dtolnay
Centril Apr 4, 2019
1eec471
Rollup merge of #59555 - RalfJung:miri, r=oli-obk
Centril Apr 4, 2019
5fb8949
Rollup merge of #59556 - RalfJung:stdsimd, r=gnzlbg
Centril Apr 4, 2019
06aa86a
Rollup merge of #59628 - U007D:master, r=Kimundi
Centril Apr 4, 2019
4380fde
Rollup merge of #59639 - cuviper:ignore-uninhabited, r=eddyb
Centril Apr 4, 2019
1f65027
Rollup merge of #59685 - lzutao:patch-1, r=GuillaumeGomez
Centril Apr 4, 2019
03a6ae6
Rollup merge of #59686 - crlf0710:disable_gnux32_stackprobe, r=luqmana
Centril Apr 4, 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
24 changes: 1 addition & 23 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2054,18 +2054,6 @@ dependencies = [
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "rand"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "rand"
version = "0.6.1"
Expand Down Expand Up @@ -2093,14 +2081,6 @@ dependencies = [
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "rand_core"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "rand_core"
version = "0.3.0"
Expand Down Expand Up @@ -2560,7 +2540,7 @@ version = "1.0.0"
dependencies = [
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -4206,10 +4186,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c"
"checksum racer 2.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "37c88638777cc178684cf648ca0e1dad56646ce105b8593dfe665c436300adc3"
"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
"checksum rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a"
"checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a"
"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372"
"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db"
"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
Expand Down
2 changes: 1 addition & 1 deletion src/doc/man/rustc.1
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ full debug info with variable and type information.
.RE
.TP
\fBopt\-level\fR=\fIVAL\fR
Optimize with possible levels 0\[en]3
Optimize with possible levels 0\[en]3, s (optimize for size), or z (for minimal size)

.SH ENVIRONMENT

Expand Down
21 changes: 16 additions & 5 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
#![stable(feature = "rust1", since = "1.0.0")]

use iter::{FromIterator, FusedIterator, TrustedLen};
use {hint, mem, ops::{self, Deref}};
use {hint, mem, ops::{self, Deref, DerefMut}};
use pin::Pin;

// Note that this is not a lang item per se, but it has a hidden dependency on
Expand Down Expand Up @@ -991,15 +991,26 @@ impl<T: Default> Option<T> {

#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")]
impl<T: Deref> Option<T> {
/// Converts from `&Option<T>` to `Option<&T::Target>`.
/// Converts from `Option<T>` (or `&Option<T>`) to `Option<&T::Target>`.
///
/// Leaves the original Option in-place, creating a new one with a reference
/// to the original one, additionally coercing the contents via `Deref`.
pub fn deref(&self) -> Option<&T::Target> {
/// Leaves the original `Option` in-place, creating a new one containing a reference to the
/// inner type's `Deref::Target` type.
pub fn as_deref(&self) -> Option<&T::Target> {
self.as_ref().map(|t| t.deref())
}
}

#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")]
impl<T: DerefMut> Option<T> {
/// Converts from `Option<T>` (or `&mut Option<T>`) to `Option<&mut T::Target>`.
///
/// Leaves the original `Option` in-place, creating a new one containing a mutable reference to
/// the inner type's `Deref::Target` type.
pub fn as_deref_mut(&mut self) -> Option<&mut T::Target> {
self.as_mut().map(|t| t.deref_mut())
}
}

impl<T, E> Option<Result<T, E>> {
/// Transposes an `Option` of a `Result` into a `Result` of an `Option`.
///
Expand Down
65 changes: 49 additions & 16 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@

use fmt;
use iter::{FromIterator, FusedIterator, TrustedLen};
use ops::{self, Deref};
use ops::{self, Deref, DerefMut};

/// `Result` is a type that represents either success ([`Ok`]) or failure ([`Err`]).
///
Expand Down Expand Up @@ -927,42 +927,75 @@ impl<T: Default, E> Result<T, E> {

#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")]
impl<T: Deref, E> Result<T, E> {
/// Converts from `&Result<T, E>` to `Result<&T::Target, &E>`.
/// Converts from `Result<T, E>` (or `&Result<T, E>`) to `Result<&T::Target, &E>`.
///
/// Leaves the original Result in-place, creating a new one with a reference
/// to the original one, additionally coercing the `Ok` arm of the Result via
/// `Deref`.
pub fn deref_ok(&self) -> Result<&T::Target, &E> {
/// Leaves the original `Result` in-place, creating a new one containing a reference to the
/// `Ok` type's `Deref::Target` type.
pub fn as_deref_ok(&self) -> Result<&T::Target, &E> {
self.as_ref().map(|t| t.deref())
}
}

#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")]
impl<T, E: Deref> Result<T, E> {
/// Converts from `&Result<T, E>` to `Result<&T, &E::Target>`.
/// Converts from `Result<T, E>` (or `&Result<T, E>`) to `Result<&T, &E::Target>`.
///
/// Leaves the original Result in-place, creating a new one with a reference
/// to the original one, additionally coercing the `Err` arm of the Result via
/// `Deref`.
pub fn deref_err(&self) -> Result<&T, &E::Target>
/// Leaves the original `Result` in-place, creating a new one containing a reference to the
/// `Err` type's `Deref::Target` type.
pub fn as_deref_err(&self) -> Result<&T, &E::Target>
{
self.as_ref().map_err(|e| e.deref())
}
}

#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")]
impl<T: Deref, E: Deref> Result<T, E> {
/// Converts from `&Result<T, E>` to `Result<&T::Target, &E::Target>`.
/// Converts from `Result<T, E>` (or `&Result<T, E>`) to `Result<&T::Target, &E::Target>`.
///
/// Leaves the original Result in-place, creating a new one with a reference
/// to the original one, additionally coercing both the `Ok` and `Err` arms
/// of the Result via `Deref`.
pub fn deref(&self) -> Result<&T::Target, &E::Target>
/// Leaves the original `Result` in-place, creating a new one containing a reference to both
/// the `Ok` and `Err` types' `Deref::Target` types.
pub fn as_deref(&self) -> Result<&T::Target, &E::Target>
{
self.as_ref().map(|t| t.deref()).map_err(|e| e.deref())
}
}

#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")]
impl<T: DerefMut, E> Result<T, E> {
/// Converts from `Result<T, E>` (or `&mut Result<T, E>`) to `Result<&mut T::Target, &mut E>`.
///
/// Leaves the original `Result` in-place, creating a new one containing a mutable reference to
/// the `Ok` type's `Deref::Target` type.
pub fn as_deref_mut_ok(&mut self) -> Result<&mut T::Target, &mut E> {
self.as_mut().map(|t| t.deref_mut())
}
}

#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")]
impl<T, E: DerefMut> Result<T, E> {
/// Converts from `Result<T, E>` (or `&mut Result<T, E>`) to `Result<&mut T, &mut E::Target>`.
///
/// Leaves the original `Result` in-place, creating a new one containing a mutable reference to
/// the `Err` type's `Deref::Target` type.
pub fn as_deref_mut_err(&mut self) -> Result<&mut T, &mut E::Target>
{
self.as_mut().map_err(|e| e.deref_mut())
}
}

#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")]
impl<T: DerefMut, E: DerefMut> Result<T, E> {
/// Converts from `Result<T, E>` (or `&mut Result<T, E>`) to
/// `Result<&mut T::Target, &mut E::Target>`.
///
/// Leaves the original `Result` in-place, creating a new one containing a mutable reference to
/// both the `Ok` and `Err` types' `Deref::Target` types.
pub fn as_deref_mut(&mut self) -> Result<&mut T::Target, &mut E::Target>
{
self.as_mut().map(|t| t.deref_mut()).map_err(|e| e.deref_mut())
}
}

impl<T, E> Result<Option<T>, E> {
/// Transposes a `Result` of an `Option` into an `Option` of a `Result`.
///
Expand Down
30 changes: 25 additions & 5 deletions src/libcore/tests/option.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use core::option::*;
use core::mem;
use core::clone::Clone;
use core::array::FixedSizeArray;
use core::ops::DerefMut;

#[test]
fn test_get_ptr() {
Expand Down Expand Up @@ -310,20 +312,38 @@ fn test_try() {
}

#[test]
fn test_option_deref() {
fn test_option_as_deref() {
// Some: &Option<T: Deref>::Some(T) -> Option<&T::Deref::Target>::Some(&*T)
let ref_option = &Some(&42);
assert_eq!(ref_option.deref(), Some(&42));
assert_eq!(ref_option.as_deref(), Some(&42));

let ref_option = &Some(String::from("a result"));
assert_eq!(ref_option.deref(), Some("a result"));
assert_eq!(ref_option.as_deref(), Some("a result"));

let ref_option = &Some(vec![1, 2, 3, 4, 5]);
assert_eq!(ref_option.deref(), Some(&[1, 2, 3, 4, 5][..]));
assert_eq!(ref_option.as_deref(), Some([1, 2, 3, 4, 5].as_slice()));

// None: &Option<T: Deref>>::None -> None
let ref_option: &Option<&i32> = &None;
assert_eq!(ref_option.deref(), None);
assert_eq!(ref_option.as_deref(), None);
}

#[test]
fn test_option_as_deref_mut() {
// Some: &mut Option<T: Deref>::Some(T) -> Option<&mut T::Deref::Target>::Some(&mut *T)
let mut val = 42;
let ref_option = &mut Some(&mut val);
assert_eq!(ref_option.as_deref_mut(), Some(&mut 42));

let ref_option = &mut Some(String::from("a result"));
assert_eq!(ref_option.as_deref_mut(), Some(String::from("a result").deref_mut()));

let ref_option = &mut Some(vec![1, 2, 3, 4, 5]);
assert_eq!(ref_option.as_deref_mut(), Some([1, 2, 3, 4, 5].as_mut_slice()));

// None: &mut Option<T: Deref>>::None -> None
let ref_option: &mut Option<&mut i32> = &mut None;
assert_eq!(ref_option.as_deref_mut(), None);
}

#[test]
Expand Down
Loading