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 #48768

Merged
merged 45 commits into from
Mar 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
238bb38
First version
pvdrz Feb 22, 2018
f9e049a
add info about sync
pvdrz Feb 23, 2018
58d1f83
remove redundant info
pvdrz Feb 23, 2018
43de01f
cleaned trailing whitespaces
pvdrz Feb 23, 2018
5344b07
Add new warning for CStr::from_ptr
GuillaumeGomez Feb 24, 2018
ce3ad26
added link to sync containers
pvdrz Feb 24, 2018
7ded7f7
corrected grammar errors
pvdrz Feb 24, 2018
397ce8a
fixed links
pvdrz Feb 25, 2018
9091584
some grammar corrections
pvdrz Feb 26, 2018
02e021b
Add bitreverse intrinsic
Amanieu Apr 7, 2016
df8dd3f
doc: no need for the references
tshepang Feb 28, 2018
e822e62
Suggest type for overflowing bin/hex-literals
flip1995 Feb 22, 2018
19c4771
Implementing requested changes
flip1995 Feb 22, 2018
5c70619
Rewrite error reporting as requested
flip1995 Feb 24, 2018
f45f760
Adapt stderr of UI test to PR #48449
flip1995 Mar 1, 2018
f7693c0
Fix spelling s/casted/cast/
lukaslueg Feb 21, 2018
08504fb
Optimize str::repeat
sinkuu Mar 2, 2018
15ecf06
Remove isize test
flip1995 Mar 2, 2018
bc651ca
core: Stabilize FusedIterator
bluss Jan 15, 2018
c7c23fe
core: Update stability attributes for FusedIterator
bluss Mar 3, 2018
fc33b25
Improve getting literal representation
flip1995 Mar 3, 2018
683bdc7
Add comments
sinkuu Mar 4, 2018
3d58543
Avoid unnecessary calculation
sinkuu Mar 4, 2018
0b0e1b7
Refactor contrived match.
leoyvens Mar 4, 2018
1c191b2
Add note for unterminated raw string error
GuillaumeGomez Feb 26, 2018
16ac85c
Remove useless powerpc64 entry from ARCH_TABLE, closes #47737
debris Mar 4, 2018
88f32d1
Remove a couple of `isize` references from hashmap docs
tbu- Mar 5, 2018
2e7e68b
while let all the things
leoyvens Mar 5, 2018
2ec47e0
Remove seemingly unused sugarise-doc-comments Python script.
frewsxcv Mar 6, 2018
24fb4b7
Add reverse_bits to integer types
Amanieu Feb 27, 2018
88aec91
Add i128 tests for intrinsics
Amanieu Feb 28, 2018
43de95c
Rollup merge of #48403 - lukaslueg:casted, r=steveklabnik
kennytm Mar 6, 2018
813ac2c
Rollup merge of #48432 - flip1995:lit_diag, r=oli-obk
kennytm Mar 6, 2018
e3451f8
Rollup merge of #48546 - GuillaumeGomez:raw-string-error-note, r=este…
kennytm Mar 6, 2018
fe77f5d
Rollup merge of #48573 - Amanieu:bitreverse2, r=sfackler
kennytm Mar 6, 2018
6b8984d
Rollup merge of #48590 - tshepang:more-simple, r=frewsxcv
kennytm Mar 6, 2018
46d629a
Rollup merge of #48657 - sinkuu:opt_str_repeat, r=dtolnay
kennytm Mar 6, 2018
57cfbea
Rollup merge of #48727 - leodasvacas:refactor-contrived-match, r=rkruppe
kennytm Mar 6, 2018
178b2c4
Rollup merge of #48732 - debris:remove_powerpc64, r=alexcrichton
kennytm Mar 6, 2018
7dc3f17
Rollup merge of #48753 - tbu-:pr_hashmap_isize, r=BurntSushi
kennytm Mar 6, 2018
b691c52
Rollup merge of #48754 - leodasvacas:while-let-all-the-things, r=rkruppe
kennytm Mar 6, 2018
fa374f9
Rollup merge of #48761 - frewsxcv:frewsxcv-rm-python, r=alexcrichton
kennytm Mar 6, 2018
ee94252
Rollup merge of #48474 - christianpoveda:new_cell_docs, r=steveklabnik
kennytm Mar 6, 2018
ebc6d6e
Rollup merge of #48507 - GuillaumeGomez:cstr-note, r=steveklabnik
kennytm Mar 6, 2018
8e3493d
Rollup merge of #47463 - bluss:fused-iterator, r=alexcrichton
kennytm Mar 6, 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
93 changes: 0 additions & 93 deletions src/etc/sugarise-doc-comments.py

This file was deleted.

6 changes: 3 additions & 3 deletions src/liballoc/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ impl<'a, T> ExactSizeIterator for Iter<'a, T> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T> FusedIterator for Iter<'a, T> {}

/// An owning iterator over the elements of a `BinaryHeap`.
Expand Down Expand Up @@ -1019,7 +1019,7 @@ impl<T> ExactSizeIterator for IntoIter<T> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<T> FusedIterator for IntoIter<T> {}

/// A draining iterator over the elements of a `BinaryHeap`.
Expand Down Expand Up @@ -1065,7 +1065,7 @@ impl<'a, T: 'a> ExactSizeIterator for Drain<'a, T> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T: 'a> FusedIterator for Drain<'a, T> {}

#[stable(feature = "binary_heap_extras_15", since = "1.5.0")]
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<I: FusedIterator + ?Sized> FusedIterator for Box<I> {}


Expand Down
16 changes: 8 additions & 8 deletions src/liballoc/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ impl<'a, K: 'a, V: 'a> Iterator for Iter<'a, K, V> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for Iter<'a, K, V> {}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1235,7 +1235,7 @@ impl<'a, K: 'a, V: 'a> ExactSizeIterator for IterMut<'a, K, V> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for IterMut<'a, K, V> {}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1365,7 +1365,7 @@ impl<K, V> ExactSizeIterator for IntoIter<K, V> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<K, V> FusedIterator for IntoIter<K, V> {}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1395,7 +1395,7 @@ impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for Keys<'a, K, V> {}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1432,7 +1432,7 @@ impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for Values<'a, K, V> {}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1482,7 +1482,7 @@ impl<'a, K, V> ExactSizeIterator for ValuesMut<'a, K, V> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for ValuesMut<'a, K, V> {}


Expand Down Expand Up @@ -1561,7 +1561,7 @@ impl<'a, K, V> Range<'a, K, V> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for Range<'a, K, V> {}

#[stable(feature = "btree_range", since = "1.17.0")]
Expand Down Expand Up @@ -1630,7 +1630,7 @@ impl<'a, K, V> DoubleEndedIterator for RangeMut<'a, K, V> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for RangeMut<'a, K, V> {}

impl<'a, K, V> RangeMut<'a, K, V> {
Expand Down
14 changes: 7 additions & 7 deletions src/liballoc/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ impl<'a, T> ExactSizeIterator for Iter<'a, T> {
fn len(&self) -> usize { self.iter.len() }
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T> FusedIterator for Iter<'a, T> {}

#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -971,7 +971,7 @@ impl<T> ExactSizeIterator for IntoIter<T> {
fn len(&self) -> usize { self.iter.len() }
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<T> FusedIterator for IntoIter<T> {}

#[stable(feature = "btree_range", since = "1.17.0")]
Expand All @@ -997,7 +997,7 @@ impl<'a, T> DoubleEndedIterator for Range<'a, T> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T> FusedIterator for Range<'a, T> {}

/// Compare `x` and `y`, but return `short` if x is None and `long` if y is None
Expand Down Expand Up @@ -1044,7 +1044,7 @@ impl<'a, T: Ord> Iterator for Difference<'a, T> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T: Ord> FusedIterator for Difference<'a, T> {}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1078,7 +1078,7 @@ impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T: Ord> FusedIterator for SymmetricDifference<'a, T> {}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1116,7 +1116,7 @@ impl<'a, T: Ord> Iterator for Intersection<'a, T> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T: Ord> FusedIterator for Intersection<'a, T> {}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1150,5 +1150,5 @@ impl<'a, T: Ord> Iterator for Union<'a, T> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T: Ord> FusedIterator for Union<'a, T> {}
4 changes: 2 additions & 2 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
#![feature(fmt_internals)]
#![feature(from_ref)]
#![feature(fundamental)]
#![feature(fused)]
#![feature(generic_param_attrs)]
#![feature(i128_type)]
#![feature(inclusive_range)]
Expand Down Expand Up @@ -124,8 +123,9 @@
#![feature(allocator_internals)]
#![feature(on_unimplemented)]
#![feature(exact_chunks)]
#![feature(pointer_methods)]

#![cfg_attr(not(test), feature(fused, fn_traits, placement_new_protocol, swap_with_slice, i128))]
#![cfg_attr(not(test), feature(fn_traits, placement_new_protocol, swap_with_slice, i128))]
#![cfg_attr(test, feature(test, box_heap))]

// Allow testing this library
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> ExactSizeIterator for Iter<'a, T> {}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T> FusedIterator for Iter<'a, T> {}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -946,7 +946,7 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> ExactSizeIterator for IterMut<'a, T> {}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T> FusedIterator for IterMut<'a, T> {}

impl<'a, T> IterMut<'a, T> {
Expand Down Expand Up @@ -1117,7 +1117,7 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> ExactSizeIterator for IntoIter<T> {}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<T> FusedIterator for IntoIter<T> {}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
59 changes: 55 additions & 4 deletions src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use core::str as core_str;
use core::str::pattern::Pattern;
use core::str::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher};
use core::mem;
use core::ptr;
use core::iter::FusedIterator;
use std_unicode::str::{UnicodeStr, Utf16Encoder};

Expand Down Expand Up @@ -171,7 +172,7 @@ impl<'a> Iterator for EncodeUtf16<'a> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a> FusedIterator for EncodeUtf16<'a> {}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -2066,9 +2067,59 @@ impl str {
/// ```
#[stable(feature = "repeat_str", since = "1.16.0")]
pub fn repeat(&self, n: usize) -> String {
let mut s = String::with_capacity(self.len() * n);
s.extend((0..n).map(|_| self));
s
if n == 0 {
return String::new();
}

// If `n` is larger than zero, it can be split as
// `n = 2^expn + rem (2^expn > rem, expn >= 0, rem >= 0)`.
// `2^expn` is the number represented by the leftmost '1' bit of `n`,
// and `rem` is the remaining part of `n`.

// Using `Vec` to access `set_len()`.
let mut buf = Vec::with_capacity(self.len() * n);

// `2^expn` repetition is done by doubling `buf` `expn`-times.
buf.extend(self.as_bytes());
{
let mut m = n >> 1;
// If `m > 0`, there are remaining bits up to the leftmost '1'.
while m > 0 {
// `buf.extend(buf)`:
unsafe {
ptr::copy_nonoverlapping(
buf.as_ptr(),
(buf.as_mut_ptr() as *mut u8).add(buf.len()),
buf.len(),
);
// `buf` has capacity of `self.len() * n`.
let buf_len = buf.len();
buf.set_len(buf_len * 2);
}

m >>= 1;
}
}

// `rem` (`= n - 2^expn`) repetition is done by copying
// first `rem` repetitions from `buf` itself.
let rem_len = self.len() * n - buf.len(); // `self.len() * rem`
if rem_len > 0 {
// `buf.extend(buf[0 .. rem_len])`:
unsafe {
// This is non-overlapping since `2^expn > rem`.
ptr::copy_nonoverlapping(
buf.as_ptr(),
(buf.as_mut_ptr() as *mut u8).add(buf.len()),
rem_len,
);
// `buf.len() + rem_len` equals to `buf.capacity()` (`= self.len() * n`).
let buf_cap = buf.capacity();
buf.set_len(buf_cap);
}
}

unsafe { String::from_utf8_unchecked(buf) }
}

/// Checks if all characters in this string are within the ASCII range.
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2254,5 +2254,5 @@ impl<'a> DoubleEndedIterator for Drain<'a> {
}
}

#[unstable(feature = "fused", issue = "35602")]
#[stable(feature = "fused", since = "1.26.0")]
impl<'a> FusedIterator for Drain<'a> {}
Loading