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 14 pull requests #57087

Merged
merged 43 commits into from
Dec 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e38e954
Simplify MIR generation for logical ops
sinkuu Dec 17, 2018
f731445
Mark tuple structs as live if their constructors are used
oli-obk Dec 18, 2018
c2402dc
Replace "native pointer" in error message with "raw pointer"
varkor Dec 18, 2018
d6969ac
Fix string for raw pointer deref suggestion
varkor Dec 18, 2018
0309874
Fix string for array access suggestion
varkor Dec 18, 2018
e7c5146
Remove `TokenStream::JointTree`.
nnethercote Dec 19, 2018
405d8b0
Copyrite
oli-obk Dec 20, 2018
59f643f
Point to return span when writing `return;` on non-() fn
estebank Dec 20, 2018
cdbccf5
Point at coercion source on type errors for fn returning `impl Trait`
estebank Dec 21, 2018
f8e508c
Fix a recently introduces regression
oli-obk Dec 17, 2018
b9d74fc
Also test projections
oli-obk Dec 17, 2018
3414be0
fix deprecation warnings in liballoc benches
RalfJung Dec 21, 2018
6ed596e
Update tests to changes on master
oli-obk Dec 21, 2018
097d39d
Fix alignment for array indexing
nikic Dec 21, 2018
20d694a
Update Pin API to match the one proposed for stabilization
cramertj Dec 18, 2018
610bcaf
Stabilize Pin
cramertj Dec 18, 2018
3005bf3
Pin stabilization: fix doctests
cramertj Dec 18, 2018
684fe9a
Rename Box/Arc/Rc::pinned to ::pin
cramertj Dec 18, 2018
861df06
Fix Unpin docs link
cramertj Dec 18, 2018
6dd0d2d
Fix a comment
bjorn3 Dec 22, 2018
3986c96
enum type instead of variant suggestion unification
zackmdavis Nov 19, 2018
64ad3e2
adjust enum type instead of variant suggestions for prelude enums
zackmdavis Nov 23, 2018
2820dc8
Remove dead code
estebank Dec 23, 2018
b42a3ac
stabilize min_const_unsafe_fn in 1.33.
Centril Dec 22, 2018
bd1d5bc
stabilize min_const_unsafe_fn --bless tests.
Centril Dec 22, 2018
7ae6fb2
stabilize min_const_unsafe_fn -- revert const-size_of-cycle changes
Centril Dec 22, 2018
db542b8
test: Ignore ui/target-feature-gate on s390x
glaubitz Dec 23, 2018
ecdbcad
test: Ignore codegen/x86_mmx.rs on s390x
glaubitz Dec 23, 2018
2c0f011
Improve docs for collecting into `Option`s
killercup Nov 29, 2018
4c97162
Rollup merge of #56188 - zackmdavis:if_i_may_suggest, r=davidtwco
Centril Dec 23, 2018
90a3586
Rollup merge of #56342 - killercup:collect-into-option-docs, r=bluss
Centril Dec 23, 2018
84bc34e
Rollup merge of #56916 - oli-obk:static_mut_beta_regression, r=davidtwco
Centril Dec 23, 2018
6ce5ecb
Rollup merge of #56917 - sinkuu:mir_build_logicop, r=davidtwco
Centril Dec 23, 2018
93af1e7
Rollup merge of #56939 - cramertj:pin-stabilization, r=alexcrichton
Centril Dec 23, 2018
5157c22
Rollup merge of #56953 - oli-obk:dead_const, r=petrochenkov
Centril Dec 23, 2018
61f50d9
Rollup merge of #56964 - nnethercote:TokenStream-IsJoint, r=petrochenkov
Centril Dec 23, 2018
eb24b33
Rollup merge of #56966 - varkor:raw-pointer-deref-parens, r=zackmdavis
Centril Dec 23, 2018
0c1ba07
Rollup merge of #57020 - estebank:return-span, r=zackmdavis
Centril Dec 23, 2018
93bc72f
Rollup merge of #57032 - RalfJung:alloc-bench-deprecations, r=Centril
Centril Dec 23, 2018
4ebc7b7
Rollup merge of #57053 - nikic:fix-gep-align, r=nagisa
Centril Dec 23, 2018
e482677
Rollup merge of #57062 - bjorn3:patch-1, r=varkor
Centril Dec 23, 2018
975a7f0
Rollup merge of #57067 - Centril:stabilize-min_const_unsafe_fn, r=oli…
Centril Dec 23, 2018
dff3e41
Rollup merge of #57078 - glaubitz:ignore-tests, r=nikic
Centril Dec 23, 2018
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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies = [
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
Expand Down
1 change: 1 addition & 0 deletions src/liballoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ compiler_builtins = { version = "0.1.0", features = ['rustc-dep-of-std'] }

[dev-dependencies]
rand = "0.6"
rand_xorshift = "0.1"

[[test]]
name = "collectionstests"
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/benches/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use std::iter::Iterator;
use std::vec::Vec;
use std::collections::BTreeMap;
use rand::{Rng, thread_rng};
use rand::{Rng, seq::SliceRandom, thread_rng};
use test::{Bencher, black_box};

macro_rules! map_insert_rand_bench {
Expand Down Expand Up @@ -78,7 +78,7 @@ macro_rules! map_find_rand_bench {
map.insert(k, k);
}

rng.shuffle(&mut keys);
keys.shuffle(&mut rng);

// measure
let mut i = 0;
Expand Down
1 change: 1 addition & 0 deletions src/liballoc/benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#![feature(test)]

extern crate rand;
extern crate rand_xorshift;
extern crate test;

mod btree;
Expand Down
3 changes: 2 additions & 1 deletion src/liballoc/benches/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ use rand::{thread_rng};
use std::mem;
use std::ptr;

use rand::{Rng, SeedableRng, XorShiftRng};
use rand::{Rng, SeedableRng};
use rand::distributions::{Standard, Alphanumeric};
use rand_xorshift::XorShiftRng;
use test::{Bencher, black_box};

#[bench]
Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/benches/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,11 @@ make_test!(split_a_str, s, s.split("a").count());
make_test!(trim_ascii_char, s, {
s.trim_matches(|c: char| c.is_ascii())
});
make_test!(trim_left_ascii_char, s, {
s.trim_left_matches(|c: char| c.is_ascii())
make_test!(trim_start_ascii_char, s, {
s.trim_start_matches(|c: char| c.is_ascii())
});
make_test!(trim_right_ascii_char, s, {
s.trim_right_matches(|c: char| c.is_ascii())
make_test!(trim_end_ascii_char, s, {
s.trim_end_matches(|c: char| c.is_ascii())
});

make_test!(find_underscore_char, s, s.find('_'));
Expand Down
10 changes: 6 additions & 4 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ impl<T> Box<T> {
box x
}

#[unstable(feature = "pin", issue = "49150")]
/// Constructs a new `Pin<Box<T>>`. If `T` does not implement `Unpin`, then
/// `x` will be pinned in memory and unable to be moved.
#[stable(feature = "pin", since = "1.33.0")]
#[inline(always)]
pub fn pinned(x: T) -> Pin<Box<T>> {
pub fn pin(x: T) -> Pin<Box<T>> {
(box x).into()
}
}
Expand Down Expand Up @@ -446,7 +448,7 @@ impl<T> From<T> for Box<T> {
}
}

#[unstable(feature = "pin", issue = "49150")]
#[stable(feature = "pin", since = "1.33.0")]
impl<T> From<Box<T>> for Pin<Box<T>> {
fn from(boxed: Box<T>) -> Self {
// It's not possible to move or replace the insides of a `Pin<Box<T>>`
Expand Down Expand Up @@ -813,7 +815,7 @@ impl<T: ?Sized> AsMut<T> for Box<T> {
* implementation of `Unpin` (where `T: Unpin`) would be valid/safe, and
* could have a method to project a Pin<T> from it.
*/
#[unstable(feature = "pin", issue = "49150")]
#[stable(feature = "pin", since = "1.33.0")]
impl<T: ?Sized> Unpin for Box<T> { }

#[unstable(feature = "generator_trait", issue = "43122")]
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
#![feature(nll)]
#![feature(optin_builtin_traits)]
#![feature(pattern)]
#![feature(pin)]
#![feature(ptr_internals)]
#![feature(ptr_offset_from)]
#![feature(rustc_attrs)]
Expand Down
8 changes: 5 additions & 3 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,10 @@ impl<T> Rc<T> {
}
}

#[unstable(feature = "pin", issue = "49150")]
pub fn pinned(value: T) -> Pin<Rc<T>> {
/// Constructs a new `Pin<Rc<T>>`. If `T` does not implement `Unpin`, then
/// `value` will be pinned in memory and unable to be moved.
#[stable(feature = "pin", since = "1.33.0")]
pub fn pin(value: T) -> Pin<Rc<T>> {
unsafe { Pin::new_unchecked(Rc::new(value)) }
}

Expand Down Expand Up @@ -1934,5 +1936,5 @@ impl<T: ?Sized> AsRef<T> for Rc<T> {
}
}

#[unstable(feature = "pin", issue = "49150")]
#[stable(feature = "pin", since = "1.33.0")]
impl<T: ?Sized> Unpin for Rc<T> { }
8 changes: 5 additions & 3 deletions src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,10 @@ impl<T> Arc<T> {
Arc { ptr: Box::into_raw_non_null(x), phantom: PhantomData }
}

#[unstable(feature = "pin", issue = "49150")]
pub fn pinned(data: T) -> Pin<Arc<T>> {
/// Constructs a new `Pin<Arc<T>>`. If `T` does not implement `Unpin`, then
/// `data` will be pinned in memory and unable to be moved.
#[stable(feature = "pin", since = "1.33.0")]
pub fn pin(data: T) -> Pin<Arc<T>> {
unsafe { Pin::new_unchecked(Arc::new(data)) }
}

Expand Down Expand Up @@ -2050,5 +2052,5 @@ impl<T: ?Sized> AsRef<T> for Arc<T> {
}
}

#[unstable(feature = "pin", issue = "49150")]
#[stable(feature = "pin", since = "1.33.0")]
impl<T: ?Sized> Unpin for Arc<T> { }
2 changes: 1 addition & 1 deletion src/libcore/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl<'a, F: ?Sized + Future + Unpin> Future for &'a mut F {

impl<P> Future for Pin<P>
where
P: ops::DerefMut,
P: Unpin + ops::DerefMut,
P::Target: Future,
{
type Output = <<P as ops::Deref>::Target as Future>::Output;
Expand Down
11 changes: 5 additions & 6 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,6 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
/// So this, for example, can only be done on types implementing `Unpin`:
///
/// ```rust
/// #![feature(pin)]
/// use std::mem::replace;
/// use std::pin::Pin;
///
Expand All @@ -637,23 +636,23 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
/// [`replace`]: ../../std/mem/fn.replace.html
/// [`Pin`]: ../pin/struct.Pin.html
/// [`pin module`]: ../../std/pin/index.html
#[unstable(feature = "pin", issue = "49150")]
#[stable(feature = "pin", since = "1.33.0")]
pub auto trait Unpin {}

/// A marker type which does not implement `Unpin`.
///
/// If a type contains a `PhantomPinned`, it will not implement `Unpin` by default.
#[unstable(feature = "pin", issue = "49150")]
#[stable(feature = "pin", since = "1.33.0")]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct PhantomPinned;

#[unstable(feature = "pin", issue = "49150")]
#[stable(feature = "pin", since = "1.33.0")]
impl !Unpin for PhantomPinned {}

#[unstable(feature = "pin", issue = "49150")]
#[stable(feature = "pin", since = "1.33.0")]
impl<'a, T: ?Sized + 'a> Unpin for &'a T {}

#[unstable(feature = "pin", issue = "49150")]
#[stable(feature = "pin", since = "1.33.0")]
impl<'a, T: ?Sized + 'a> Unpin for &'a mut T {}

/// Implementations of `Copy` for primitive types.
Expand Down
46 changes: 34 additions & 12 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl<T> Option<T> {

/// Converts from `Pin<&Option<T>>` to `Option<Pin<&T>>`
#[inline]
#[unstable(feature = "pin", issue = "49150")]
#[stable(feature = "pin", since = "1.33.0")]
pub fn as_pin_ref<'a>(self: Pin<&'a Option<T>>) -> Option<Pin<&'a T>> {
unsafe {
Pin::get_ref(self).as_ref().map(|x| Pin::new_unchecked(x))
Expand All @@ -282,10 +282,10 @@ impl<T> Option<T> {

/// Converts from `Pin<&mut Option<T>>` to `Option<Pin<&mut T>>`
#[inline]
#[unstable(feature = "pin", issue = "49150")]
#[stable(feature = "pin", since = "1.33.0")]
pub fn as_pin_mut<'a>(self: Pin<&'a mut Option<T>>) -> Option<Pin<&'a mut T>> {
unsafe {
Pin::get_mut_unchecked(self).as_mut().map(|x| Pin::new_unchecked(x))
Pin::get_unchecked_mut(self).as_mut().map(|x| Pin::new_unchecked(x))
}
}

Expand Down Expand Up @@ -1253,20 +1253,42 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
/// returned. Should no [`None`][Option::None] occur, a container with the
/// values of each [`Option`] is returned.
///
/// Here is an example which increments every integer in a vector,
/// checking for overflow:
/// # Examples
///
/// Here is an example which increments every integer in a vector.
/// `We use the checked variant of `add` that returns `None` when the
/// calculation would result in an overflow.
///
/// ```
/// use std::u16;
/// let items = vec![0_u16, 1, 2];
///
/// let res: Option<Vec<u16>> = items
/// .iter()
/// .map(|x| x.checked_add(1))
/// .collect();
///
/// let v = vec![1, 2];
/// let res: Option<Vec<u16>> = v.iter().map(|&x: &u16|
/// if x == u16::MAX { None }
/// else { Some(x + 1) }
/// ).collect();
/// assert!(res == Some(vec![2, 3]));
/// assert_eq!(res, Some(vec![1, 2, 3]));
/// ```
///
/// As you can see, this will return the expected, valid items.
///
/// Here is another example that tries to subtract one from another list
/// of integers, this time checking for underflow:
///
/// ```
/// let items = vec![2_u16, 1, 0];
///
/// let res: Option<Vec<u16>> = items
/// .iter()
/// .map(|x| x.checked_sub(1))
/// .collect();
///
/// assert_eq!(res, None);
/// ```
///
/// Since the last element is zero, it would underflow. Thus, the resulting
/// value is `None`.
///
/// [`Iterator`]: ../iter/trait.Iterator.html
#[inline]
fn from_iter<I: IntoIterator<Item=Option<A>>>(iter: I) -> Option<V> {
Expand Down
Loading