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 12 pull requests #49460

Merged
merged 28 commits into from
Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7c442e5
Stabilize method `String::retain`
murarth Mar 21, 2018
7cae6fe
don't pass -no-pie to gnu ld
canarysnort01 Mar 24, 2018
04f6692
Implement `shrink_to` method on collections
Diggsey Mar 26, 2018
96ef2f8
Fix search appearance
GuillaumeGomez Mar 27, 2018
a93a4d2
Enable target_feature on any LLVM 6+
cuviper Mar 27, 2018
8be26a2
Fix collapse toggle insertions on impl with docs
GuillaumeGomez Mar 27, 2018
37fa6f8
rustdoc: Don't use into_iter() when cleaning impl Trait
Manishearth Mar 27, 2018
ac655d2
rustdoc: Include associated type bounds when cleaning foreign impl tr…
Manishearth Mar 27, 2018
32446f8
rustdoc: Remove Sized bounds when cleaning foreign impl Trait
Manishearth Mar 27, 2018
6a547b4
rustdoc: Handle explicit ?Sized on foreign impl Trait
Manishearth Mar 27, 2018
33dceaa
rustdoc: Add test for foreign impl trait with bounds
Manishearth Mar 27, 2018
884153a
Fix trait implementation not collapsing docs
GuillaumeGomez Mar 28, 2018
7038236
Delete leftover librustc_const_eval
oli-obk Mar 28, 2018
51f26ac
Fix text overlap
GuillaumeGomez Mar 28, 2018
0d15a3e
Clarify "length" wording in `Vec::with_capacity`.
frewsxcv Mar 28, 2018
49fd71b
[incremental] Don't panic if decoding the cache fails
wesleywiser Mar 23, 2018
43f56ce
Rollup merge of #49243 - murarth:stabilize-retain, r=BurntSushi
kennytm Mar 28, 2018
4285e1c
Rollup merge of #49329 - canarysnort01:fix-no-pie, r=pnkfelix
kennytm Mar 28, 2018
0214304
Rollup merge of #49364 - wesleywiser:incr_handle_load_failure, r=mich…
kennytm Mar 28, 2018
010fb40
Rollup merge of #49400 - Diggsey:shrink-to, r=joshtriplett
kennytm Mar 28, 2018
c17ab37
Rollup merge of #49405 - GuillaumeGomez:search-appearance, r=QuietMis…
kennytm Mar 28, 2018
6ca1466
Rollup merge of #49427 - Manishearth:rustdoc-impl-trait-extern, r=Gui…
kennytm Mar 28, 2018
294f041
Rollup merge of #49428 - cuviper:llvm6-target_feature, r=alexcrichton
kennytm Mar 28, 2018
611ceef
Rollup merge of #49429 - GuillaumeGomez:fix-collapse-toggle-insertion…
kennytm Mar 28, 2018
1a89250
Rollup merge of #49439 - GuillaumeGomez:trait-impl-collapse, r=QuietM…
kennytm Mar 28, 2018
5dc80dc
Rollup merge of #49442 - GuillaumeGomez:text-overlap, r=QuietMisdreavus
kennytm Mar 28, 2018
03de75e
Rollup merge of #49444 - rust-lang:oli-obk-patch-1, r=Mark-Simulacrum
kennytm Mar 28, 2018
30560bb
Rollup merge of #49452 - frewsxcv:frewsxcv-vec-cap-len, r=dtolnay
kennytm Mar 28, 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
23 changes: 0 additions & 23 deletions src/doc/unstable-book/src/library-features/string-retain.md

This file was deleted.

25 changes: 25 additions & 0 deletions src/liballoc/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,31 @@ impl<T: Ord> BinaryHeap<T> {
self.data.shrink_to_fit();
}

/// Discards capacity with a lower bound.
///
/// The capacity will remain at least as large as both the length
/// and the supplied value.
///
/// Panics if the current capacity is smaller than the supplied
/// minimum capacity.
///
/// # Examples
///
/// ```
/// #![feature(shrink_to)]
/// use std::collections::BinaryHeap;
/// let mut heap: BinaryHeap<i32> = BinaryHeap::with_capacity(100);
///
/// assert!(heap.capacity() >= 100);
/// heap.shrink_to(10);
/// assert!(heap.capacity() >= 10);
/// ```
#[inline]
#[unstable(feature = "shrink_to", reason = "new API", issue="0")]
pub fn shrink_to(&mut self, min_capacity: usize) {
self.data.shrink_to(min_capacity)
}

/// Removes the greatest item from the binary heap and returns it, or `None` if it
/// is empty.
///
Expand Down
32 changes: 29 additions & 3 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,34 @@ impl String {
self.vec.shrink_to_fit()
}

/// Shrinks the capacity of this `String` with a lower bound.
///
/// The capacity will remain at least as large as both the length
/// and the supplied value.
///
/// Panics if the current capacity is smaller than the supplied
/// minimum capacity.
///
/// # Examples
///
/// ```
/// #![feature(shrink_to)]
/// let mut s = String::from("foo");
///
/// s.reserve(100);
/// assert!(s.capacity() >= 100);
///
/// s.shrink_to(10);
/// assert!(s.capacity() >= 10);
/// s.shrink_to(0);
/// assert!(s.capacity() >= 3);
/// ```
#[inline]
#[unstable(feature = "shrink_to", reason = "new API", issue="0")]
pub fn shrink_to(&mut self, min_capacity: usize) {
self.vec.shrink_to(min_capacity)
}

/// Appends the given [`char`] to the end of this `String`.
///
/// [`char`]: ../../std/primitive.char.html
Expand Down Expand Up @@ -1177,16 +1205,14 @@ impl String {
/// # Examples
///
/// ```
/// #![feature(string_retain)]
///
/// let mut s = String::from("f_o_ob_ar");
///
/// s.retain(|c| c != '_');
///
/// assert_eq!(s, "foobar");
/// ```
#[inline]
#[unstable(feature = "string_retain", issue = "43874")]
#[stable(feature = "string_retain", since = "1.26.0")]
pub fn retain<F>(&mut self, mut f: F)
where F: FnMut(char) -> bool
{
Expand Down
34 changes: 30 additions & 4 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

#![stable(feature = "rust1", since = "1.0.0")]

use core::cmp::Ordering;
use core::cmp::{self, Ordering};
use core::fmt;
use core::hash::{self, Hash};
use core::intrinsics::{arith_offset, assume};
Expand Down Expand Up @@ -334,9 +334,10 @@ impl<T> Vec<T> {
/// The vector will be able to hold exactly `capacity` elements without
/// reallocating. If `capacity` is 0, the vector will not allocate.
///
/// It is important to note that this function does not specify the *length*
/// of the returned vector, but only the *capacity*. For an explanation of
/// the difference between length and capacity, see *[Capacity and reallocation]*.
/// It is important to note that although the returned vector has the
/// *capacity* specified, the vector will have a zero *length*. For an
/// explanation of the difference between length and capacity, see
/// *[Capacity and reallocation]*.
///
/// [Capacity and reallocation]: #capacity-and-reallocation
///
Expand Down Expand Up @@ -586,6 +587,31 @@ impl<T> Vec<T> {
self.buf.shrink_to_fit(self.len);
}

/// Shrinks the capacity of the vector with a lower bound.
///
/// The capacity will remain at least as large as both the length
/// and the supplied value.
///
/// Panics if the current capacity is smaller than the supplied
/// minimum capacity.
///
/// # Examples
///
/// ```
/// #![feature(shrink_to)]
/// let mut vec = Vec::with_capacity(10);
/// vec.extend([1, 2, 3].iter().cloned());
/// assert_eq!(vec.capacity(), 10);
/// vec.shrink_to(4);
/// assert!(vec.capacity() >= 4);
/// vec.shrink_to(0);
/// assert!(vec.capacity() >= 3);
/// ```
#[unstable(feature = "shrink_to", reason = "new API", issue="0")]
pub fn shrink_to(&mut self, min_capacity: usize) {
self.buf.shrink_to_fit(cmp::max(self.len, min_capacity));
}

/// Converts the vector into [`Box<[T]>`][owned slice].
///
/// Note that this will drop any excess capacity.
Expand Down
35 changes: 34 additions & 1 deletion src/liballoc/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,42 @@ impl<T> VecDeque<T> {
/// ```
#[stable(feature = "deque_extras_15", since = "1.5.0")]
pub fn shrink_to_fit(&mut self) {
self.shrink_to(0);
}

/// Shrinks the capacity of the `VecDeque` with a lower bound.
///
/// The capacity will remain at least as large as both the length
/// and the supplied value.
///
/// Panics if the current capacity is smaller than the supplied
/// minimum capacity.
///
/// # Examples
///
/// ```
/// #![feature(shrink_to)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::with_capacity(15);
/// buf.extend(0..4);
/// assert_eq!(buf.capacity(), 15);
/// buf.shrink_to(6);
/// assert!(buf.capacity() >= 6);
/// buf.shrink_to(0);
/// assert!(buf.capacity() >= 4);
/// ```
#[unstable(feature = "shrink_to", reason = "new API", issue="0")]
pub fn shrink_to(&mut self, min_capacity: usize) {
assert!(self.capacity() >= min_capacity, "Tried to shrink to a larger capacity");

// +1 since the ringbuffer always leaves one space empty
// len + 1 can't overflow for an existing, well-formed ringbuffer.
let target_cap = cmp::max(self.len() + 1, MINIMUM_CAPACITY + 1).next_power_of_two();
let target_cap = cmp::max(
cmp::max(min_capacity, self.len()) + 1,
MINIMUM_CAPACITY + 1
).next_power_of_two();

if target_cap < self.cap() {
// There are three cases of interest:
// All elements are out of desired bounds
Expand Down
59 changes: 0 additions & 59 deletions src/librustc_const_eval/lib.rs

This file was deleted.

4 changes: 3 additions & 1 deletion src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,9 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session,
Some(future) => {
let prev_graph = time(sess, "blocked while dep-graph loading finishes", || {
future.open()
.expect("Could not join with background dep_graph thread")
.unwrap_or_else(|e| rustc_incremental::LoadResult::Error {
message: format!("could not decode incremental cache: {:?}", e)
})
.open(sess)
});
DepGraph::new(prev_graph)
Expand Down
1 change: 1 addition & 0 deletions src/librustc_incremental/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub use assert_dep_graph::assert_dep_graph;
pub use persist::dep_graph_tcx_init;
pub use persist::load_dep_graph;
pub use persist::load_query_result_cache;
pub use persist::LoadResult;
pub use persist::save_dep_graph;
pub use persist::save_trans_partition;
pub use persist::save_work_products;
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_incremental/persist/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ impl LoadResult<PreviousDepGraph> {
pub fn open(self, sess: &Session) -> PreviousDepGraph {
match self {
LoadResult::Error { message } => {
sess.fatal(&message) /* never returns */
sess.warn(&message);
PreviousDepGraph::new(SerializedDepGraph::new())
},
LoadResult::DataOutOfDate => {
if let Err(err) = delete_all_session_dir_contents(sess) {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_incremental/persist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub use self::fs::prepare_session_directory;
pub use self::load::dep_graph_tcx_init;
pub use self::load::load_dep_graph;
pub use self::load::load_query_result_cache;
pub use self::load::LoadResult;
pub use self::save::save_dep_graph;
pub use self::save::save_work_products;
pub use self::work_product::save_trans_partition;
Expand Down
6 changes: 4 additions & 2 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ fn link_natively(sess: &Session,
// linking executables as pie. Different versions of gcc seem to use
// different quotes in the error message so don't check for them.
if sess.target.target.options.linker_is_gnu &&
sess.linker_flavor() != LinkerFlavor::Ld &&
(out.contains("unrecognized command line option") ||
out.contains("unknown argument")) &&
out.contains("-no-pie") &&
Expand Down Expand Up @@ -1008,8 +1009,9 @@ fn link_args(cmd: &mut Linker,
} else {
// recent versions of gcc can be configured to generate position
// independent executables by default. We have to pass -no-pie to
// explicitly turn that off.
if sess.target.target.options.linker_is_gnu {
// explicitly turn that off. Not applicable to ld.
if sess.target.target.options.linker_is_gnu
&& sess.linker_flavor() != LinkerFlavor::Ld {
cmd.no_position_independent_executable();
}
}
Expand Down
Loading