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 18 pull requests #62352

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
fc918a3
rename InterpretCx -> InterpCx
RalfJung Jun 27, 2019
a02d436
wfcheck: resolve the type-vars in `AdtField` types
arielb1 Jun 29, 2019
f7061db
Update mem::replace example to not be identical to mem::take
czipperz Jun 30, 2019
3f39dc1
syntax: Unsupport `foo! bar { ... }` macros in the parser
petrochenkov Jun 30, 2019
d0dc41a
Address review comments
petrochenkov Jul 1, 2019
47ea8ae
Remove needless lifetimes
jeremystucki Jun 25, 2019
8d6b1d1
Clean up inherent_impls
Zoxc Apr 16, 2019
b49fb76
miri realloc: do not require giving old size+align
RalfJung Jul 1, 2019
8a3797b
Use mem::take instead of mem::replace with default
czipperz Jun 30, 2019
636f5e6
Convert more usages over
czipperz Jun 30, 2019
b0c199a
Enable mem_take feature in relevant crates
czipperz Jun 30, 2019
1443abc
Revert change in compiletest
czipperz Jun 30, 2019
eddfad3
Fix import of take in collapse_docs.rs
czipperz Jul 2, 2019
dc088b2
refactor check_for_substitution
matklad Jul 2, 2019
db16e17
When possible without changing semantics, implement Iterator::last in…
khuey Jul 2, 2019
c004451
Migrate compile-pass annotations to build-pass
JohnTitor Jul 2, 2019
8d2f80b
Use link attributes on extern "C" blocks with llvm-libuwind
petrhosek Jul 2, 2019
87e8613
Remove needless lifetimes
jeremystucki Jun 21, 2019
0477e07
Remove needless lifetimes
jeremystucki Jun 21, 2019
6ae80cf
Remove needless lifetimes
jeremystucki Jun 21, 2019
d50a3a7
Remove needless lifetimes
jeremystucki Jun 21, 2019
ec71176
Remove needless lifetimes
jeremystucki Jun 21, 2019
d28832d
Remove needless lifetimes
jeremystucki Jun 21, 2019
3cd4df7
Add missing lifetime specifier
jeremystucki Jun 23, 2019
80f4c49
Add missing lifetime specifier
jeremystucki Jun 23, 2019
b17cec5
Add missing lifetime specifier
jeremystucki Jun 23, 2019
edcde70
Add missing lifetime specifier
jeremystucki Jun 24, 2019
88c515d
Revert changes to the standard library
jeremystucki Jun 25, 2019
f5b2541
Update the `rust-installer` submodule
alexcrichton Jun 26, 2019
b4712f0
Fix bucket in CPU usage script
Mark-Simulacrum Jul 3, 2019
c51802a
simplify Option::get_or_insert
matklad Jul 3, 2019
4dd5edc
enable a few more tests in Miri and update the comment for others
RalfJung Jul 3, 2019
6225607
remove bogus example from drop_in_place
RalfJung Jul 3, 2019
2970a13
Rollup merge of #62039 - jeremystucki:needless_lifetimes, r=eddyb
Centril Jul 3, 2019
8d3cc45
Rollup merge of #62123 - jeremystucki:needless_lifetimes_std, r=alexc…
Centril Jul 3, 2019
3df3b4e
Rollup merge of #62153 - alexcrichton:parallel-compress, r=Mark-Simul…
Centril Jul 3, 2019
bfd789f
Rollup merge of #62173 - RalfJung:miri-interp, r=oli-obk
Centril Jul 3, 2019
da75e72
Rollup merge of #62240 - arielb1:resolve-wf-fields, r=pnkfelix
Centril Jul 3, 2019
3f12de1
Rollup merge of #62249 - czipperz:use-mem-take-instead-of-replace-def…
Centril Jul 3, 2019
7ec194a
Rollup merge of #62252 - czipperz:change-mem-replace-doc-example, r=d…
Centril Jul 3, 2019
f5e7857
Rollup merge of #62258 - petrochenkov:idclean, r=Centril
Centril Jul 3, 2019
011a407
Rollup merge of #62268 - Zoxc:inherent_impls, r=eddyb
Centril Jul 3, 2019
288ca93
Rollup merge of #62287 - petrhosek:libunwind-link-attribute, r=tmandry
Centril Jul 3, 2019
469c69b
Rollup merge of #62295 - RalfJung:miri-realloc, r=cramertj
Centril Jul 3, 2019
02dc16d
Rollup merge of #62297 - matklad:peek-delimited, r=petrochenkov
Centril Jul 3, 2019
1fd388b
Rollup merge of #62316 - khuey:efficient_last, r=sfackler
Centril Jul 3, 2019
da52d46
Rollup merge of #62317 - JohnTitor:move-tests-to-build-pass, r=Centril
Centril Jul 3, 2019
4a5f89f
Rollup merge of #62337 - Mark-Simulacrum:fix-cpu-usage-script, r=alex…
Centril Jul 3, 2019
24e4e25
Rollup merge of #62344 - matklad:simplify-option, r=sfackler
Centril Jul 3, 2019
8bcb4b6
Rollup merge of #62346 - RalfJung:miri-tests, r=Centril
Centril Jul 3, 2019
2eebc8c
Rollup merge of #62351 - RalfJung:drop-in-place, r=cramertj
Centril Jul 3, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1272,9 +1272,10 @@ name = "installer"
version = "0.0.0"
dependencies = [
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tar 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down
2 changes: 1 addition & 1 deletion src/etc/cpu-usage-over-time-plot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

set -ex

bucket=rust-lang-ci-evalazure
bucket=rust-lang-ci2
commit=$1
builder=$2

Expand Down
8 changes: 8 additions & 0 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@ impl<I: Iterator + ?Sized> Iterator for Box<I> {
(**self).nth(n)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<I: Iterator + Sized> Iterator for Box<I> {
fn last(self) -> Option<I::Item> where I: Sized {
(*self).last()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for Box<I> {
fn next_back(&mut self) -> Option<I::Item> {
Expand Down
5 changes: 5 additions & 0 deletions src/liballoc/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,11 @@ impl<'a, T> Iterator for Iter<'a, T> {
fn size_hint(&self) -> (usize, Option<usize>) {
self.iter.size_hint()
}

#[inline]
fn last(self) -> Option<&'a T> {
self.iter.last()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
40 changes: 34 additions & 6 deletions src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,8 @@ impl<K: Ord, V> BTreeMap<K, V> {
}

// First, we merge `self` and `other` into a sorted sequence in linear time.
let self_iter = mem::replace(self, BTreeMap::new()).into_iter();
let other_iter = mem::replace(other, BTreeMap::new()).into_iter();
let self_iter = mem::take(self).into_iter();
let other_iter = mem::take(other).into_iter();
let iter = MergeIter {
left: self_iter.peekable(),
right: other_iter.peekable(),
Expand Down Expand Up @@ -1193,6 +1193,10 @@ impl<'a, K: 'a, V: 'a> Iterator for Iter<'a, K, V> {
fn size_hint(&self) -> (usize, Option<usize>) {
(self.length, Some(self.length))
}

fn last(mut self) -> Option<(&'a K, &'a V)> {
self.next_back()
}
}

#[stable(feature = "fused", since = "1.26.0")]
Expand Down Expand Up @@ -1253,6 +1257,10 @@ impl<'a, K: 'a, V: 'a> Iterator for IterMut<'a, K, V> {
fn size_hint(&self) -> (usize, Option<usize>) {
(self.length, Some(self.length))
}

fn last(mut self) -> Option<(&'a K, &'a mut V)> {
self.next_back()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1421,6 +1429,10 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> {
fn size_hint(&self) -> (usize, Option<usize>) {
self.inner.size_hint()
}

fn last(mut self) -> Option<&'a K> {
self.next_back()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1458,6 +1470,10 @@ impl<'a, K, V> Iterator for Values<'a, K, V> {
fn size_hint(&self) -> (usize, Option<usize>) {
self.inner.size_hint()
}

fn last(mut self) -> Option<&'a V> {
self.next_back()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1495,6 +1511,10 @@ impl<'a, K, V> Iterator for Range<'a, K, V> {
unsafe { Some(self.next_unchecked()) }
}
}

fn last(mut self) -> Option<(&'a K, &'a V)> {
self.next_back()
}
}

#[stable(feature = "map_values_mut", since = "1.10.0")]
Expand All @@ -1508,6 +1528,10 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
fn size_hint(&self) -> (usize, Option<usize>) {
self.inner.size_hint()
}

fn last(mut self) -> Option<&'a mut V> {
self.next_back()
}
}

#[stable(feature = "map_values_mut", since = "1.10.0")]
Expand Down Expand Up @@ -1626,6 +1650,10 @@ impl<'a, K, V> Iterator for RangeMut<'a, K, V> {
unsafe { Some(self.next_unchecked()) }
}
}

fn last(mut self) -> Option<(&'a K, &'a mut V)> {
self.next_back()
}
}

impl<'a, K, V> RangeMut<'a, K, V> {
Expand Down Expand Up @@ -2004,7 +2032,7 @@ impl<K, V> BTreeMap<K, V> {
/// assert_eq!(keys, [1, 2]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn keys<'a>(&'a self) -> Keys<'a, K, V> {
pub fn keys(&self) -> Keys<'_, K, V> {
Keys { inner: self.iter() }
}

Expand All @@ -2025,7 +2053,7 @@ impl<K, V> BTreeMap<K, V> {
/// assert_eq!(values, ["hello", "goodbye"]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn values<'a>(&'a self) -> Values<'a, K, V> {
pub fn values(&self) -> Values<'_, K, V> {
Values { inner: self.iter() }
}

Expand Down Expand Up @@ -2529,8 +2557,8 @@ enum UnderflowResult<'a, K, V> {
Stole(NodeRef<marker::Mut<'a>, K, V, marker::Internal>),
}

fn handle_underfull_node<'a, K, V>(node: NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>)
-> UnderflowResult<'a, K, V> {
fn handle_underfull_node<K, V>(node: NodeRef<marker::Mut<'_>, K, V, marker::LeafOrInternal>)
-> UnderflowResult<'_, K, V> {
let parent = if let Ok(parent) = node.ascend() {
parent
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
}

/// Temporarily takes out another, immutable reference to the same node.
fn reborrow<'a>(&'a self) -> NodeRef<marker::Immut<'a>, K, V, Type> {
fn reborrow(&self) -> NodeRef<marker::Immut<'_>, K, V, Type> {
NodeRef {
height: self.height,
node: self.node,
Expand Down
7 changes: 7 additions & 0 deletions src/liballoc/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,9 @@ impl<'a, T> Iterator for Iter<'a, T> {
fn size_hint(&self) -> (usize, Option<usize>) {
self.iter.size_hint()
}
fn last(mut self) -> Option<&'a T> {
self.next_back()
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
Expand Down Expand Up @@ -1073,6 +1076,10 @@ impl<'a, T> Iterator for Range<'a, T> {
fn next(&mut self) -> Option<&'a T> {
self.iter.next().map(|(k, _)| k)
}

fn last(mut self) -> Option<&'a T> {
self.next_back()
}
}

#[stable(feature = "btree_range", since = "1.17.0")]
Expand Down
12 changes: 11 additions & 1 deletion src/liballoc/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ impl<T> LinkedList<T> {
let len = self.len();
assert!(at <= len, "Cannot split off at a nonexistent index");
if at == 0 {
return mem::replace(self, Self::new());
return mem::take(self);
} else if at == len {
return Self::new();
}
Expand Down Expand Up @@ -832,6 +832,11 @@ impl<'a, T> Iterator for Iter<'a, T> {
fn size_hint(&self) -> (usize, Option<usize>) {
(self.len, Some(self.len))
}

#[inline]
fn last(mut self) -> Option<&'a T> {
self.next_back()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -881,6 +886,11 @@ impl<'a, T> Iterator for IterMut<'a, T> {
fn size_hint(&self) -> (usize, Option<usize>) {
(self.len, Some(self.len))
}

#[inline]
fn last(mut self) -> Option<&'a mut T> {
self.next_back()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
10 changes: 10 additions & 0 deletions src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2206,6 +2206,11 @@ impl<'a, T> Iterator for Iter<'a, T> {
self.tail = self.head - iter.len();
final_res
}

#[inline]
fn last(mut self) -> Option<&'a T> {
self.next_back()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -2319,6 +2324,11 @@ impl<'a, T> Iterator for IterMut<'a, T> {
accum = front.iter_mut().fold(accum, &mut f);
back.iter_mut().fold(accum, &mut f)
}

#[inline]
fn last(mut self) -> Option<&'a mut T> {
self.next_back()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
1 change: 1 addition & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
#![feature(maybe_uninit_extra, maybe_uninit_slice, maybe_uninit_array)]
#![feature(alloc_layout_extra)]
#![feature(try_trait)]
#![feature(mem_take)]

// Allow testing this library

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl ToOwned for str {
}

fn clone_into(&self, target: &mut String) {
let mut b = mem::replace(target, String::new()).into_bytes();
let mut b = mem::take(target).into_bytes();
self.as_bytes().clone_into(&mut b);
*target = unsafe { String::from_utf8_unchecked(b) }
}
Expand Down
7 changes: 6 additions & 1 deletion src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ impl String {
/// assert_eq!("Hello �World", output);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> Cow<'a, str> {
pub fn from_utf8_lossy(v: &[u8]) -> Cow<'_, str> {
let mut iter = lossy::Utf8Lossy::from_bytes(v).chunks();

let (first_valid, first_broken) = if let Some(chunk) = iter.next() {
Expand Down Expand Up @@ -2385,6 +2385,11 @@ impl Iterator for Drain<'_> {
fn size_hint(&self) -> (usize, Option<usize>) {
self.iter.size_hint()
}

#[inline]
fn last(mut self) -> Option<char> {
self.next_back()
}
}

#[stable(feature = "drain", since = "1.6.0")]
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,6 @@ fn from_into_inner() {
it.next().unwrap();
let vec = it.collect::<Vec<_>>();
assert_eq!(vec, [2, 3]);
#[cfg(not(miri))] // Miri does not support comparing dangling pointers
assert!(ptr != vec.as_ptr());
}

Expand Down
1 change: 1 addition & 0 deletions src/libcore/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ impl Iterator for EscapeDefault {
type Item = u8;
fn next(&mut self) -> Option<u8> { self.range.next().map(|i| self.data[i]) }
fn size_hint(&self) -> (usize, Option<usize>) { self.range.size_hint() }
fn last(mut self) -> Option<u8> { self.next_back() }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl DoubleEndedIterator for EscapeDefault {
Expand Down
1 change: 1 addition & 0 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
#![feature(adx_target_feature)]
#![feature(maybe_uninit_slice, maybe_uninit_array)]
#![feature(external_doc)]
#![feature(mem_take)]

#[prelude_import]
#[allow(unused)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ macro_rules! impls{
/// # end: *const T,
/// # phantom: PhantomData<&'a T>,
/// # }
/// fn borrow_vec<'a, T>(vec: &'a Vec<T>) -> Slice<'a, T> {
/// fn borrow_vec<T>(vec: &Vec<T>) -> Slice<'_, T> {
/// let ptr = vec.as_ptr();
/// Slice {
/// start: ptr,
Expand Down
28 changes: 20 additions & 8 deletions src/libcore/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,12 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
/// mem::take(&mut self.buf)
/// }
/// }
///
/// let mut buffer = Buffer { buf: vec![0, 1] };
/// assert_eq!(buffer.buf.len(), 2);
///
/// assert_eq!(buffer.get_and_reset(), vec![0, 1]);
/// assert_eq!(buffer.buf.len(), 0);
/// ```
///
/// [`Clone`]: ../../std/clone/trait.Clone.html
Expand Down Expand Up @@ -586,17 +592,17 @@ pub fn take<T: Default>(dest: &mut T) -> T {
/// struct Buffer<T> { buf: Vec<T> }
///
/// impl<T> Buffer<T> {
/// fn get_and_reset(&mut self) -> Vec<T> {
/// fn replace_index(&mut self, i: usize, v: T) -> T {
/// // error: cannot move out of dereference of `&mut`-pointer
/// let buf = self.buf;
/// self.buf = Vec::new();
/// buf
/// let t = self.buf[i];
/// self.buf[i] = v;
/// t
/// }
/// }
/// ```
///
/// Note that `T` does not necessarily implement [`Clone`], so it can't even clone and reset
/// `self.buf`. But `replace` can be used to disassociate the original value of `self.buf` from
/// Note that `T` does not necessarily implement [`Clone`], so we can't even clone `self.buf[i]` to
/// avoid the move. But `replace` can be used to disassociate the original value at that index from
/// `self`, allowing it to be returned:
///
/// ```
Expand All @@ -605,10 +611,16 @@ pub fn take<T: Default>(dest: &mut T) -> T {
///
/// # struct Buffer<T> { buf: Vec<T> }
/// impl<T> Buffer<T> {
/// fn get_and_reset(&mut self) -> Vec<T> {
/// mem::replace(&mut self.buf, Vec::new())
/// fn replace_index(&mut self, i: usize, v: T) -> T {
/// mem::replace(&mut self.buf[i], v)
/// }
/// }
///
/// let mut buffer = Buffer { buf: vec![0, 1] };
/// assert_eq!(buffer.buf[0], 0);
///
/// assert_eq!(buffer.replace_index(0, 2), 0);
/// assert_eq!(buffer.buf[0], 2);
/// ```
///
/// [`Clone`]: ../../std/clone/trait.Clone.html
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/ops/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub trait Index<Idx: ?Sized> {
/// impl Index<Side> for Balance {
/// type Output = Weight;
///
/// fn index<'a>(&'a self, index: Side) -> &'a Self::Output {
/// fn index(&self, index: Side) -> &Self::Output {
/// println!("Accessing {:?}-side of balance immutably", index);
/// match index {
/// Side::Left => &self.left,
Expand All @@ -115,7 +115,7 @@ pub trait Index<Idx: ?Sized> {
/// }
///
/// impl IndexMut<Side> for Balance {
/// fn index_mut<'a>(&'a mut self, index: Side) -> &'a mut Self::Output {
/// fn index_mut(&mut self, index: Side) -> &mut Self::Output {
/// println!("Accessing {:?}-side of balance mutably", index);
/// match index {
/// Side::Left => &mut self.left,
Expand Down
Loading