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 23 pull requests #48203

Merged
merged 75 commits into from
Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
7f6a53e
Changed color of struct link from #ff794d to #2dbfb8
PramodBisht Jan 27, 2018
c04d86d
Work around LLVM OCAML binding installation failure
roblabla Jan 29, 2018
434bfb1
Changed of `struct` url to `#ad448e` in rust docs
PramodBisht Jan 31, 2018
b439632
Unimplement Send/Sync for ::env::{Args,ArgsOs,Vars,VarsOs}
panicbit Feb 4, 2018
9bc5986
38880 don't compute hash when searching an empty HashMap
technicalguy Feb 6, 2018
dcdd2c4
38880 use search_mut function rather than search_hashed
technicalguy Feb 6, 2018
2a4c018
Apply optimization from #44355 to retain
Xaeroxe Feb 7, 2018
a67749a
Swap `ptr::read` for `ptr::drop_in_place`
Xaeroxe Feb 8, 2018
4f8049a
Add Range[Inclusive]::is_empty
scottmcm Feb 9, 2018
7fe182f
Fix tidy
scottmcm Feb 9, 2018
b5cb393
Use is_empty in range iteration exhaustion tests
scottmcm Feb 10, 2018
6f70a11
range_is_empty tracking issue is #48111
scottmcm Feb 10, 2018
0cccd9a
Show better warning for trying to cast non-u8 scalar to char
GuillaumeGomez Feb 6, 2018
14f488e
Whitelist pclmul x86 feature flag
newpavlov Feb 10, 2018
877272b
typo fix
newpavlov Feb 10, 2018
3c01dea
Add comment about the problem, and use provided path if available
roblabla Feb 10, 2018
45d5a42
Correct a few stability attributes
ollie27 Feb 10, 2018
8be3068
added conversion from Rust feature to LLVM feature
newpavlov Feb 10, 2018
c97aa09
iterator instead loop
newpavlov Feb 10, 2018
161e8ff
typo: correct endianess to endianness (this also changes function nam…
matthiaskrgr Feb 10, 2018
7c6adb4
fixed errors
newpavlov Feb 11, 2018
22b0489
Add the emptiness condition to the docs; add a PartialOrd example wit…
scottmcm Feb 11, 2018
bf69b0f
Upgrade the Travis CI macOS images for testing from Xcode 8.3 to 9.2.
kennytm Jan 25, 2018
c2a31de
Dangling pointer fix
newpavlov Feb 11, 2018
bd426f1
Update ops range example to avoid confusion between indexes and values.
Feb 12, 2018
f7cabc6
Continue parsing function after finding `...` arg
estebank Feb 12, 2018
0f789aa
add core::iter::repeat_with
Centril Feb 12, 2018
c4099ca
core::iter::repeat_with: general fixes
Centril Feb 12, 2018
1af9ee1
core::iter::repeat_with: derive Copy, Clone, Debug
Centril Feb 12, 2018
f025eff
core::iter::repeat_with: fix tests
Centril Feb 12, 2018
55c669c
core::iter::repeat_with: fix tests some more
Centril Feb 12, 2018
efa3320
core::iter::repeat_with: fix doc tests
Centril Feb 12, 2018
29f7148
38880 remove redundant extra function
technicalguy Feb 12, 2018
fd78621
38880 fixup add missing mut
technicalguy Feb 12, 2018
0f16eee
rustc: Add the ability to not run dsymutil
alexcrichton Jan 26, 2018
9cee79a
core::iter::repeat_with: document DoubleEndedIterator behavior
Centril Feb 12, 2018
43e8ac2
rustc: Persist LLVM's `Linker` in Fat LTO
alexcrichton Feb 12, 2018
4c658f7
Update compiletest's `read2` function
alexcrichton Feb 12, 2018
f237e9e
Remove allocation from width of character function.
Mark-Simulacrum Feb 12, 2018
91a4b90
core::iter::repeat_with: tracking issue is #48169
Centril Feb 12, 2018
db13296
core::iter::repeat_with: fix missing word, see @Pazzaz's review
Centril Feb 13, 2018
0397fc1
Handle path prefix mapping in a more stable way when computing the cr…
michaelwoerister Feb 12, 2018
580dd42
incr.comp.: Run cache directory garbage collection before loading dep…
michaelwoerister Feb 13, 2018
7cf5ea0
Add note about Cargo cwd change to release notes
Mark-Simulacrum Feb 13, 2018
fbad3b2
Switch to retain calling drain_filter.
Xaeroxe Feb 13, 2018
a295ec1
38880 restore original entry(key) method
technicalguy Feb 13, 2018
94c3c84
38880 hashmap check size=0, not just capacity=0
technicalguy Feb 13, 2018
f3330ce
38880 fix incorrect negation
technicalguy Feb 13, 2018
e034ddd
38880 remove unnecessary self.table.size check
technicalguy Feb 13, 2018
893fc32
Update compiler-builtins to latest master.
paoloteti Feb 13, 2018
8671f69
Rollup merge of #47784 - alexcrichton:less-dsymutil, r=michaelwoerister
kennytm Feb 14, 2018
c89976e
Rollup merge of #47806 - PramodBisht:feature/47801, r=steveklabnik
kennytm Feb 14, 2018
2be44ce
Rollup merge of #47846 - roblabla:bugfix-ocaml, r=kennytm
kennytm Feb 14, 2018
c88a6fe
Rollup merge of #48005 - panicbit:env_unimpl_send_sync, r=alexcrichton
kennytm Feb 14, 2018
a5c3209
Rollup merge of #48033 - GuillaumeGomez:better-char-cast-message, r=e…
kennytm Feb 14, 2018
3715f1e
Rollup merge of #48065 - Xaeroxe:patch-1, r=alexcrichton
kennytm Feb 14, 2018
bd3674e
Rollup merge of #48087 - scottmcm:range_is_empty, r=kennytm,alexcrichton
kennytm Feb 14, 2018
c02c5f4
Rollup merge of #48114 - kennytm:xcode9, r=alexcrichton
kennytm Feb 14, 2018
83bed7d
Rollup merge of #48126 - newpavlov:patch-1, r=alexcrichton
kennytm Feb 14, 2018
3bcaaf4
Rollup merge of #48130 - ollie27:stab, r=Mark-Simulacrum
kennytm Feb 14, 2018
5a19366
Rollup merge of #48133 - matthiaskrgr:endianess_to_endianness, r=oli-obk
kennytm Feb 14, 2018
c4b211b
Rollup merge of #48151 - echochamber:update_range_example, r=estebank
kennytm Feb 14, 2018
dcb1526
Rollup merge of #48154 - estebank:issue-31481, r=nikomatsakis
kennytm Feb 14, 2018
bebd2fb
Rollup merge of #48156 - Centril:feature/iterator_repeat_with, r=alex…
kennytm Feb 14, 2018
d38e11e
Rollup merge of #48162 - michaelwoerister:stabler-svh, r=nikomatsakis
kennytm Feb 14, 2018
92c66b7
Rollup merge of #48163 - alexcrichton:persistent-linker, r=rkruppe
kennytm Feb 14, 2018
526e954
Rollup merge of #48165 - alexcrichton:update-read2, r=Mark-Simulacrum
kennytm Feb 14, 2018
dc9d93f
Rollup merge of #48167 - Mark-Simulacrum:remove-allocation-codemap, r…
kennytm Feb 14, 2018
accadb2
Rollup merge of #48181 - michaelwoerister:fix-incr-dir-finalization, …
kennytm Feb 14, 2018
72ef62a
Rollup merge of #48186 - Mark-Simulacrum:release-notes-cargo, r=alexc…
kennytm Feb 14, 2018
6436c44
Rollup merge of #48195 - paoloteti:compiler-builtins-update, r=alexcr…
kennytm Feb 14, 2018
ce89c3d
Rollup merge of #48035 - technicalguy:Early-exit-empty-hashmap-38880,…
kennytm Feb 14, 2018
288c0c3
Clarified why `Sized` bound not implicit on trait's implicit `Self` t…
jacob-hughes Feb 14, 2018
38064a9
Review change - Expanded on explanation.
jacob-hughes Feb 14, 2018
03b089d
Rollup merge of #48210 - jacob-hughes:clarify_sized_trait_in_api_docs…
kennytm Feb 15, 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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ matrix:
NO_LLVM_ASSERTIONS=1
NO_DEBUG_ASSERTIONS=1
os: osx
osx_image: xcode8.3
osx_image: xcode9.2
if: branch = auto
- env: >
Expand All @@ -70,7 +70,7 @@ matrix:
NO_LLVM_ASSERTIONS=1
NO_DEBUG_ASSERTIONS=1
os: osx
osx_image: xcode8.3
osx_image: xcode9.2
if: branch = auto
# OSX builders producing releases. These do not run the full test suite and
Expand Down
2 changes: 2 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Compatibility Notes
- [`column!()` macro is one-based instead of zero-based][46977]
- [`fmt::Arguments` can no longer be shared across threads][45198]
- [Access to `#[repr(packed)]` struct fields is now unsafe][44884]
- [Cargo sets a different working directory for the compiler][cargo/4788]

[44884]: https://github.com/rust-lang/rust/pull/44884
[45198]: https://github.com/rust-lang/rust/pull/45198
Expand Down Expand Up @@ -106,6 +107,7 @@ Compatibility Notes
[47080]: https://github.com/rust-lang/rust/pull/47080
[47084]: https://github.com/rust-lang/rust/pull/47084
[cargo/4743]: https://github.com/rust-lang/cargo/pull/4743
[cargo/4788]: https://github.com/rust-lang/cargo/pull/4788
[cargo/4817]: https://github.com/rust-lang/cargo/pull/4817
[`RefCell::replace`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.replace
[`RefCell::swap`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.swap
Expand Down
8 changes: 8 additions & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ impl Step for Llvm {
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
.define("LLVM_DEFAULT_TARGET_TRIPLE", target);

// By default, LLVM will automatically find OCaml and, if it finds it,
// install the LLVM bindings in LLVM_OCAML_INSTALL_PATH, which defaults
// to /usr/bin/ocaml.
// This causes problem for non-root builds of Rust. Side-step the issue
// by setting LLVM_OCAML_INSTALL_PATH to a relative path, so it installs
// in the prefix.
cfg.define("LLVM_OCAML_INSTALL_PATH",
env::var_os("LLVM_OCAML_INSTALL_PATH").unwrap_or_else(|| "usr/lib/ocaml".into()));

// This setting makes the LLVM tools link to the dynamic LLVM library,
// which saves both memory during parallel links and overall disk space
Expand Down
17 changes: 1 addition & 16 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,22 +805,7 @@ impl<T> Vec<T> {
pub fn retain<F>(&mut self, mut f: F)
where F: FnMut(&T) -> bool
{
let len = self.len();
let mut del = 0;
{
let v = &mut **self;

for i in 0..len {
if !f(&v[i]) {
del += 1;
} else if del > 0 {
v.swap(i - del, i);
}
}
}
if del > 0 {
self.truncate(len - del);
}
self.drain_filter(|x| !f(x));
}

/// Removes all but the first of consecutive elements in the vector that resolve to the same
Expand Down
2 changes: 1 addition & 1 deletion src/libcompiler_builtins
2 changes: 2 additions & 0 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ pub use self::range::Step;

#[stable(feature = "rust1", since = "1.0.0")]
pub use self::sources::{Repeat, repeat};
#[unstable(feature = "iterator_repeat_with", issue = "48169")]
pub use self::sources::{RepeatWith, repeat_with};
#[stable(feature = "iter_empty", since = "1.2.0")]
pub use self::sources::{Empty, empty};
#[stable(feature = "iter_once", since = "1.2.0")]
Expand Down
115 changes: 115 additions & 0 deletions src/libcore/iter/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ unsafe impl<A: Clone> TrustedLen for Repeat<A> {}
///
/// [`take`]: trait.Iterator.html#method.take
///
/// If the element type of the iterator you need does not implement `Clone`,
/// or if you do not want to keep the repeated element in memory, you can
/// instead use the [`repeat_with`] function.
///
/// [`repeat_with`]: fn.repeat_with.html
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -99,6 +105,115 @@ pub fn repeat<T: Clone>(elt: T) -> Repeat<T> {
Repeat{element: elt}
}

/// An iterator that repeats elements of type `A` endlessly by
/// applying the provided closure `F: FnMut() -> A`.
///
/// This `struct` is created by the [`repeat_with`] function.
/// See its documentation for more.
///
/// [`repeat_with`]: fn.repeat_with.html
#[derive(Copy, Clone, Debug)]
#[unstable(feature = "iterator_repeat_with", issue = "48169")]
pub struct RepeatWith<F> {
repeater: F
}

#[unstable(feature = "iterator_repeat_with", issue = "48169")]
impl<A, F: FnMut() -> A> Iterator for RepeatWith<F> {
type Item = A;

#[inline]
fn next(&mut self) -> Option<A> { Some((self.repeater)()) }

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) { (usize::MAX, None) }
}

#[unstable(feature = "iterator_repeat_with", issue = "48169")]
impl<A, F: FnMut() -> A> DoubleEndedIterator for RepeatWith<F> {
#[inline]
fn next_back(&mut self) -> Option<A> { self.next() }
}

#[unstable(feature = "fused", issue = "35602")]
impl<A, F: FnMut() -> A> FusedIterator for RepeatWith<F> {}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<A, F: FnMut() -> A> TrustedLen for RepeatWith<F> {}

/// Creates a new iterator that repeats elements of type `A` endlessly by
/// applying the provided closure, the repeater, `F: FnMut() -> A`.
///
/// The `repeat_with()` function calls the repeater over and over and over and
/// over and over and 🔁.
///
/// Infinite iterators like `repeat_with()` are often used with adapters like
/// [`take`], in order to make them finite.
///
/// [`take`]: trait.Iterator.html#method.take
///
/// If the element type of the iterator you need implements `Clone`, and
/// it is OK to keep the source element in memory, you should instead use
/// the [`repeat`] function.
///
/// [`repeat`]: fn.repeat.html
///
/// An iterator produced by `repeat_with()` is a `DoubleEndedIterator`.
/// It is important to not that reversing `repeat_with(f)` will produce
/// the exact same sequence as the non-reversed iterator. In other words,
/// `repeat_with(f).rev().collect::<Vec<_>>()` is equivalent to
/// `repeat_with(f).collect::<Vec<_>>()`.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(iterator_repeat_with)]
///
/// use std::iter;
///
/// // let's assume we have some value of a type that is not `Clone`
/// // or which don't want to have in memory just yet because it is expensive:
/// #[derive(PartialEq, Debug)]
/// struct Expensive;
///
/// // a particular value forever:
/// let mut things = iter::repeat_with(|| Expensive);
///
/// assert_eq!(Some(Expensive), things.next());
/// assert_eq!(Some(Expensive), things.next());
/// assert_eq!(Some(Expensive), things.next());
/// assert_eq!(Some(Expensive), things.next());
/// assert_eq!(Some(Expensive), things.next());
/// ```
///
/// Using mutation and going finite:
///
/// ```rust
/// #![feature(iterator_repeat_with)]
///
/// use std::iter;
///
/// // From the zeroth to the third power of two:
/// let mut curr = 1;
/// let mut pow2 = iter::repeat_with(|| { let tmp = curr; curr *= 2; tmp })
/// .take(4);
///
/// assert_eq!(Some(1), pow2.next());
/// assert_eq!(Some(2), pow2.next());
/// assert_eq!(Some(4), pow2.next());
/// assert_eq!(Some(8), pow2.next());
///
/// // ... and now we're done
/// assert_eq!(None, pow2.next());
/// ```
#[inline]
#[unstable(feature = "iterator_repeat_with", issue = "48169")]
pub fn repeat_with<A, F: FnMut() -> A>(repeater: F) -> RepeatWith<F> {
RepeatWith { repeater }
}

/// An iterator that yields nothing.
///
/// This `struct` is created by the [`empty`] function. See its documentation for more.
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ pub trait ExactSizeIterator: Iterator {
/// ```
/// #![feature(exact_size_is_empty)]
///
/// let mut one_element = 0..1;
/// let mut one_element = std::iter::once(0);
/// assert!(!one_element.is_empty());
///
/// assert_eq!(one_element.next(), Some(0));
Expand Down
1 change: 1 addition & 0 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
#![feature(unwind_attributes)]
#![feature(doc_spotlight)]
#![feature(rustc_const_unstable)]
#![feature(iterator_repeat_with)]

#[prelude_import]
#[allow(unused)]
Expand Down
10 changes: 7 additions & 3 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ impl<T: ?Sized> !Send for *mut T { }
/// struct BarUse(Bar<[i32]>); // OK
/// ```
///
/// The one exception is the implicit `Self` type of a trait, which does not
/// get an implicit `Sized` bound. This is because a `Sized` bound prevents
/// the trait from being used to form a [trait object]:
/// The one exception is the implicit `Self` type of a trait. A trait does not
/// have an implicit `Sized` bound as this is incompatible with [trait object]s
/// where, by definition, the trait needs to work with all possible implementors,
/// and thus could be any size.
///
/// Although Rust will let you bind `Sized` to a trait, you won't
/// be able to use it to form a trait object later:
///
/// ```
/// # #![allow(unused_variables)]
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2881,7 +2881,7 @@ pub enum FpCategory {
issue = "32110")]
pub trait Float: Sized {
/// Type used by `to_bits` and `from_bits`.
#[stable(feature = "core_float_bits", since = "1.24.0")]
#[stable(feature = "core_float_bits", since = "1.25.0")]
type Bits;

/// Returns `true` if this value is NaN and false otherwise.
Expand Down Expand Up @@ -2947,10 +2947,10 @@ pub trait Float: Sized {
fn min(self, other: Self) -> Self;

/// Raw transmutation to integer.
#[stable(feature = "core_float_bits", since="1.24.0")]
#[stable(feature = "core_float_bits", since="1.25.0")]
fn to_bits(self) -> Self::Bits;
/// Raw transmutation from integer.
#[stable(feature = "core_float_bits", since="1.24.0")]
#[stable(feature = "core_float_bits", since="1.25.0")]
fn from_bits(v: Self::Bits) -> Self;
}

Expand Down
Loading