Auto merge of #49460 - kennytm:rollup, r=kennytm
Rollup of 12 pull requests - Successful merges: #49243, #49329, #49364, #49400, #49405, #49427, #49428, #49429, #49439, #49442, #49444, #49452 - Failed merges:
This commit is contained in:
commit
d52c44ea8d
35 changed files with 472 additions and 158 deletions
|
@ -1,23 +0,0 @@
|
||||||
# `string_retain`
|
|
||||||
|
|
||||||
The tracking issue for this feature is: [#43874]
|
|
||||||
|
|
||||||
[#43874]: https://github.com/rust-lang/rust/issues/43874
|
|
||||||
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
Retains only the characters specified by the predicate.
|
|
||||||
|
|
||||||
In other words, remove all characters `c` such that `f(c)` returns `false`.
|
|
||||||
This method operates in place and preserves the order of the retained
|
|
||||||
characters.
|
|
||||||
|
|
||||||
```rust
|
|
||||||
#![feature(string_retain)]
|
|
||||||
|
|
||||||
let mut s = String::from("f_o_ob_ar");
|
|
||||||
|
|
||||||
s.retain(|c| c != '_');
|
|
||||||
|
|
||||||
assert_eq!(s, "foobar");
|
|
||||||
```
|
|
|
@ -509,6 +509,31 @@ impl<T: Ord> BinaryHeap<T> {
|
||||||
self.data.shrink_to_fit();
|
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
|
/// Removes the greatest item from the binary heap and returns it, or `None` if it
|
||||||
/// is empty.
|
/// is empty.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1015,6 +1015,34 @@ impl String {
|
||||||
self.vec.shrink_to_fit()
|
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`.
|
/// Appends the given [`char`] to the end of this `String`.
|
||||||
///
|
///
|
||||||
/// [`char`]: ../../std/primitive.char.html
|
/// [`char`]: ../../std/primitive.char.html
|
||||||
|
@ -1177,8 +1205,6 @@ impl String {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(string_retain)]
|
|
||||||
///
|
|
||||||
/// let mut s = String::from("f_o_ob_ar");
|
/// let mut s = String::from("f_o_ob_ar");
|
||||||
///
|
///
|
||||||
/// s.retain(|c| c != '_');
|
/// s.retain(|c| c != '_');
|
||||||
|
@ -1186,7 +1212,7 @@ impl String {
|
||||||
/// assert_eq!(s, "foobar");
|
/// assert_eq!(s, "foobar");
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "string_retain", issue = "43874")]
|
#[stable(feature = "string_retain", since = "1.26.0")]
|
||||||
pub fn retain<F>(&mut self, mut f: F)
|
pub fn retain<F>(&mut self, mut f: F)
|
||||||
where F: FnMut(char) -> bool
|
where F: FnMut(char) -> bool
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
use core::cmp::Ordering;
|
use core::cmp::{self, Ordering};
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core::hash::{self, Hash};
|
use core::hash::{self, Hash};
|
||||||
use core::intrinsics::{arith_offset, assume};
|
use core::intrinsics::{arith_offset, assume};
|
||||||
|
@ -334,9 +334,10 @@ impl<T> Vec<T> {
|
||||||
/// The vector will be able to hold exactly `capacity` elements without
|
/// The vector will be able to hold exactly `capacity` elements without
|
||||||
/// reallocating. If `capacity` is 0, the vector will not allocate.
|
/// reallocating. If `capacity` is 0, the vector will not allocate.
|
||||||
///
|
///
|
||||||
/// It is important to note that this function does not specify the *length*
|
/// It is important to note that although the returned vector has the
|
||||||
/// of the returned vector, but only the *capacity*. For an explanation of
|
/// *capacity* specified, the vector will have a zero *length*. For an
|
||||||
/// the difference between length and capacity, see *[Capacity and reallocation]*.
|
/// explanation of the difference between length and capacity, see
|
||||||
|
/// *[Capacity and reallocation]*.
|
||||||
///
|
///
|
||||||
/// [Capacity and reallocation]: #capacity-and-reallocation
|
/// [Capacity and reallocation]: #capacity-and-reallocation
|
||||||
///
|
///
|
||||||
|
@ -586,6 +587,31 @@ impl<T> Vec<T> {
|
||||||
self.buf.shrink_to_fit(self.len);
|
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].
|
/// Converts the vector into [`Box<[T]>`][owned slice].
|
||||||
///
|
///
|
||||||
/// Note that this will drop any excess capacity.
|
/// Note that this will drop any excess capacity.
|
||||||
|
|
|
@ -676,9 +676,42 @@ impl<T> VecDeque<T> {
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "deque_extras_15", since = "1.5.0")]
|
#[stable(feature = "deque_extras_15", since = "1.5.0")]
|
||||||
pub fn shrink_to_fit(&mut self) {
|
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
|
// +1 since the ringbuffer always leaves one space empty
|
||||||
// len + 1 can't overflow for an existing, well-formed ringbuffer.
|
// 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() {
|
if target_cap < self.cap() {
|
||||||
// There are three cases of interest:
|
// There are three cases of interest:
|
||||||
// All elements are out of desired bounds
|
// All elements are out of desired bounds
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
//! constant evaluation on the HIR and code to validate patterns/matches
|
|
||||||
//!
|
|
||||||
//! # Note
|
|
||||||
//!
|
|
||||||
//! This API is completely unstable and subject to change.
|
|
||||||
|
|
||||||
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
|
||||||
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
|
|
||||||
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
|
||||||
#![deny(warnings)]
|
|
||||||
|
|
||||||
#![feature(rustc_diagnostic_macros)]
|
|
||||||
#![feature(box_patterns)]
|
|
||||||
#![feature(box_syntax)]
|
|
||||||
#![feature(macro_lifetime_matcher)]
|
|
||||||
#![cfg_attr(stage0, feature(i128_type))]
|
|
||||||
#![feature(from_ref)]
|
|
||||||
|
|
||||||
extern crate arena;
|
|
||||||
#[macro_use] extern crate syntax;
|
|
||||||
#[macro_use] extern crate log;
|
|
||||||
#[macro_use] extern crate rustc;
|
|
||||||
extern crate rustc_const_math;
|
|
||||||
extern crate rustc_data_structures;
|
|
||||||
extern crate rustc_errors;
|
|
||||||
extern crate syntax_pos;
|
|
||||||
|
|
||||||
// NB: This module needs to be declared first so diagnostics are
|
|
||||||
// registered before they are used.
|
|
||||||
mod diagnostics;
|
|
||||||
|
|
||||||
mod eval;
|
|
||||||
mod _match;
|
|
||||||
pub mod check_match;
|
|
||||||
pub mod pattern;
|
|
||||||
|
|
||||||
pub use eval::*;
|
|
||||||
|
|
||||||
use rustc::ty::maps::Providers;
|
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
|
||||||
*providers = Providers {
|
|
||||||
check_match: check_match::check_match,
|
|
||||||
..*providers
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the diagnostics array at the end so that the metadata includes error use sites.
|
|
||||||
__build_diagnostic_array! { librustc_const_eval, DIAGNOSTICS }
|
|
|
@ -901,7 +901,9 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session,
|
||||||
Some(future) => {
|
Some(future) => {
|
||||||
let prev_graph = time(sess, "blocked while dep-graph loading finishes", || {
|
let prev_graph = time(sess, "blocked while dep-graph loading finishes", || {
|
||||||
future.open()
|
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)
|
.open(sess)
|
||||||
});
|
});
|
||||||
DepGraph::new(prev_graph)
|
DepGraph::new(prev_graph)
|
||||||
|
|
|
@ -39,6 +39,7 @@ pub use assert_dep_graph::assert_dep_graph;
|
||||||
pub use persist::dep_graph_tcx_init;
|
pub use persist::dep_graph_tcx_init;
|
||||||
pub use persist::load_dep_graph;
|
pub use persist::load_dep_graph;
|
||||||
pub use persist::load_query_result_cache;
|
pub use persist::load_query_result_cache;
|
||||||
|
pub use persist::LoadResult;
|
||||||
pub use persist::save_dep_graph;
|
pub use persist::save_dep_graph;
|
||||||
pub use persist::save_trans_partition;
|
pub use persist::save_trans_partition;
|
||||||
pub use persist::save_work_products;
|
pub use persist::save_work_products;
|
||||||
|
|
|
@ -89,7 +89,8 @@ impl LoadResult<PreviousDepGraph> {
|
||||||
pub fn open(self, sess: &Session) -> PreviousDepGraph {
|
pub fn open(self, sess: &Session) -> PreviousDepGraph {
|
||||||
match self {
|
match self {
|
||||||
LoadResult::Error { message } => {
|
LoadResult::Error { message } => {
|
||||||
sess.fatal(&message) /* never returns */
|
sess.warn(&message);
|
||||||
|
PreviousDepGraph::new(SerializedDepGraph::new())
|
||||||
},
|
},
|
||||||
LoadResult::DataOutOfDate => {
|
LoadResult::DataOutOfDate => {
|
||||||
if let Err(err) = delete_all_session_dir_contents(sess) {
|
if let Err(err) = delete_all_session_dir_contents(sess) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ pub use self::fs::prepare_session_directory;
|
||||||
pub use self::load::dep_graph_tcx_init;
|
pub use self::load::dep_graph_tcx_init;
|
||||||
pub use self::load::load_dep_graph;
|
pub use self::load::load_dep_graph;
|
||||||
pub use self::load::load_query_result_cache;
|
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_dep_graph;
|
||||||
pub use self::save::save_work_products;
|
pub use self::save::save_work_products;
|
||||||
pub use self::work_product::save_trans_partition;
|
pub use self::work_product::save_trans_partition;
|
||||||
|
|
|
@ -713,6 +713,7 @@ fn link_natively(sess: &Session,
|
||||||
// linking executables as pie. Different versions of gcc seem to use
|
// linking executables as pie. Different versions of gcc seem to use
|
||||||
// different quotes in the error message so don't check for them.
|
// different quotes in the error message so don't check for them.
|
||||||
if sess.target.target.options.linker_is_gnu &&
|
if sess.target.target.options.linker_is_gnu &&
|
||||||
|
sess.linker_flavor() != LinkerFlavor::Ld &&
|
||||||
(out.contains("unrecognized command line option") ||
|
(out.contains("unrecognized command line option") ||
|
||||||
out.contains("unknown argument")) &&
|
out.contains("unknown argument")) &&
|
||||||
out.contains("-no-pie") &&
|
out.contains("-no-pie") &&
|
||||||
|
@ -1008,8 +1009,9 @@ fn link_args(cmd: &mut Linker,
|
||||||
} else {
|
} else {
|
||||||
// recent versions of gcc can be configured to generate position
|
// recent versions of gcc can be configured to generate position
|
||||||
// independent executables by default. We have to pass -no-pie to
|
// independent executables by default. We have to pass -no-pie to
|
||||||
// explicitly turn that off.
|
// explicitly turn that off. Not applicable to ld.
|
||||||
if sess.target.target.options.linker_is_gnu {
|
if sess.target.target.options.linker_is_gnu
|
||||||
|
&& sess.linker_flavor() != LinkerFlavor::Ld {
|
||||||
cmd.no_position_independent_executable();
|
cmd.no_position_independent_executable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1380,17 +1380,18 @@ fn external_path(cx: &DocContext, name: &str, trait_did: Option<DefId>, has_self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
|
impl<'a, 'tcx> Clean<TyParamBound> for (&'a ty::TraitRef<'tcx>, Vec<TypeBinding>) {
|
||||||
fn clean(&self, cx: &DocContext) -> TyParamBound {
|
fn clean(&self, cx: &DocContext) -> TyParamBound {
|
||||||
inline::record_extern_fqn(cx, self.def_id, TypeKind::Trait);
|
let (trait_ref, ref bounds) = *self;
|
||||||
let path = external_path(cx, &cx.tcx.item_name(self.def_id),
|
inline::record_extern_fqn(cx, trait_ref.def_id, TypeKind::Trait);
|
||||||
Some(self.def_id), true, vec![], self.substs);
|
let path = external_path(cx, &cx.tcx.item_name(trait_ref.def_id),
|
||||||
|
Some(trait_ref.def_id), true, bounds.clone(), trait_ref.substs);
|
||||||
|
|
||||||
debug!("ty::TraitRef\n subst: {:?}\n", self.substs);
|
debug!("ty::TraitRef\n subst: {:?}\n", trait_ref.substs);
|
||||||
|
|
||||||
// collect any late bound regions
|
// collect any late bound regions
|
||||||
let mut late_bounds = vec![];
|
let mut late_bounds = vec![];
|
||||||
for ty_s in self.input_types().skip(1) {
|
for ty_s in trait_ref.input_types().skip(1) {
|
||||||
if let ty::TyTuple(ts) = ty_s.sty {
|
if let ty::TyTuple(ts) = ty_s.sty {
|
||||||
for &ty_s in ts {
|
for &ty_s in ts {
|
||||||
if let ty::TyRef(ref reg, _) = ty_s.sty {
|
if let ty::TyRef(ref reg, _) = ty_s.sty {
|
||||||
|
@ -1410,7 +1411,7 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
|
||||||
trait_: ResolvedPath {
|
trait_: ResolvedPath {
|
||||||
path,
|
path,
|
||||||
typarams: None,
|
typarams: None,
|
||||||
did: self.def_id,
|
did: trait_ref.def_id,
|
||||||
is_generic: false,
|
is_generic: false,
|
||||||
},
|
},
|
||||||
generic_params: late_bounds,
|
generic_params: late_bounds,
|
||||||
|
@ -1420,6 +1421,12 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
|
||||||
|
fn clean(&self, cx: &DocContext) -> TyParamBound {
|
||||||
|
(self, vec![]).clean(cx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'tcx> Clean<Option<Vec<TyParamBound>>> for Substs<'tcx> {
|
impl<'tcx> Clean<Option<Vec<TyParamBound>>> for Substs<'tcx> {
|
||||||
fn clean(&self, cx: &DocContext) -> Option<Vec<TyParamBound>> {
|
fn clean(&self, cx: &DocContext) -> Option<Vec<TyParamBound>> {
|
||||||
let mut v = Vec::new();
|
let mut v = Vec::new();
|
||||||
|
@ -2780,9 +2787,51 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
||||||
let predicates_of = cx.tcx.predicates_of(def_id);
|
let predicates_of = cx.tcx.predicates_of(def_id);
|
||||||
let substs = cx.tcx.lift(&substs).unwrap();
|
let substs = cx.tcx.lift(&substs).unwrap();
|
||||||
let bounds = predicates_of.instantiate(cx.tcx, substs);
|
let bounds = predicates_of.instantiate(cx.tcx, substs);
|
||||||
ImplTrait(bounds.predicates.into_iter().filter_map(|predicate| {
|
let mut regions = vec![];
|
||||||
predicate.to_opt_poly_trait_ref().clean(cx)
|
let mut has_sized = false;
|
||||||
}).collect())
|
let mut bounds = bounds.predicates.iter().filter_map(|predicate| {
|
||||||
|
let trait_ref = if let Some(tr) = predicate.to_opt_poly_trait_ref() {
|
||||||
|
tr
|
||||||
|
} else if let ty::Predicate::TypeOutlives(pred) = *predicate {
|
||||||
|
// these should turn up at the end
|
||||||
|
pred.skip_binder().1.clean(cx).map(|r| regions.push(RegionBound(r)));
|
||||||
|
return None;
|
||||||
|
} else {
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(sized) = cx.tcx.lang_items().sized_trait() {
|
||||||
|
if trait_ref.def_id() == sized {
|
||||||
|
has_sized = true;
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let bounds = bounds.predicates.iter().filter_map(|pred|
|
||||||
|
if let ty::Predicate::Projection(proj) = *pred {
|
||||||
|
let proj = proj.skip_binder();
|
||||||
|
if proj.projection_ty.trait_ref(cx.tcx) == *trait_ref.skip_binder() {
|
||||||
|
Some(TypeBinding {
|
||||||
|
name: cx.tcx.associated_item(proj.projection_ty.item_def_id)
|
||||||
|
.name.clean(cx),
|
||||||
|
ty: proj.ty.clean(cx),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
).collect();
|
||||||
|
|
||||||
|
Some((trait_ref.skip_binder(), bounds).clean(cx))
|
||||||
|
}).collect::<Vec<_>>();
|
||||||
|
bounds.extend(regions);
|
||||||
|
if !has_sized && !bounds.is_empty() {
|
||||||
|
bounds.insert(0, TyParamBound::maybe_sized(cx));
|
||||||
|
}
|
||||||
|
ImplTrait(bounds)
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::TyClosure(..) | ty::TyGenerator(..) => Tuple(vec![]), // FIXME(pcwalton)
|
ty::TyClosure(..) | ty::TyGenerator(..) => Tuple(vec![]), // FIXME(pcwalton)
|
||||||
|
|
|
@ -2243,14 +2243,7 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
|
|
||||||
fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter,
|
fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter,
|
||||||
implementor_dups: &FxHashMap<&str, (DefId, bool)>) -> Result<(), fmt::Error> {
|
implementor_dups: &FxHashMap<&str, (DefId, bool)>) -> Result<(), fmt::Error> {
|
||||||
write!(w, "<li>")?;
|
write!(w, "<li><table class='table-display'><tbody><tr><td><code>")?;
|
||||||
if let Some(l) = (Item { cx, item: &implementor.impl_item }).src_href() {
|
|
||||||
write!(w, "<div class='out-of-band'>")?;
|
|
||||||
write!(w, "<a class='srclink' href='{}' title='{}'>[src]</a>",
|
|
||||||
l, "goto source code")?;
|
|
||||||
write!(w, "</div>")?;
|
|
||||||
}
|
|
||||||
write!(w, "<code>")?;
|
|
||||||
// If there's already another implementor that has the same abbridged name, use the
|
// If there's already another implementor that has the same abbridged name, use the
|
||||||
// full path, for example in `std::iter::ExactSizeIterator`
|
// full path, for example in `std::iter::ExactSizeIterator`
|
||||||
let use_absolute = match implementor.inner_impl().for_ {
|
let use_absolute = match implementor.inner_impl().for_ {
|
||||||
|
@ -2269,7 +2262,14 @@ fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter,
|
||||||
write!(w, ";</span>")?;
|
write!(w, ";</span>")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeln!(w, "</code></li>")?;
|
write!(w, "</code><td>")?;
|
||||||
|
if let Some(l) = (Item { cx, item: &implementor.impl_item }).src_href() {
|
||||||
|
write!(w, "<div class='out-of-band'>")?;
|
||||||
|
write!(w, "<a class='srclink' href='{}' title='{}'>[src]</a>",
|
||||||
|
l, "goto source code")?;
|
||||||
|
write!(w, "</div>")?;
|
||||||
|
}
|
||||||
|
writeln!(w, "</td></tr></tbody></table></li>")?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3314,10 +3314,11 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
||||||
Some(ref t) => format!("impl-{}", small_url_encode(&format!("{:#}", t))),
|
Some(ref t) => format!("impl-{}", small_url_encode(&format!("{:#}", t))),
|
||||||
None => "impl".to_string(),
|
None => "impl".to_string(),
|
||||||
});
|
});
|
||||||
write!(w, "<h3 id='{}' class='impl'><span class='in-band'><code>{}</code>",
|
write!(w, "<h3 id='{}' class='impl'><span class='in-band'><table class='table-display'>\
|
||||||
|
<tbody><tr><td><code>{}</code>",
|
||||||
id, i.inner_impl())?;
|
id, i.inner_impl())?;
|
||||||
write!(w, "<a href='#{}' class='anchor'></a>", id)?;
|
write!(w, "<a href='#{}' class='anchor'></a>", id)?;
|
||||||
write!(w, "</span><span class='out-of-band'>")?;
|
write!(w, "</span></td><td><span class='out-of-band'>")?;
|
||||||
let since = i.impl_item.stability.as_ref().map(|s| &s.since[..]);
|
let since = i.impl_item.stability.as_ref().map(|s| &s.since[..]);
|
||||||
if let Some(l) = (Item { item: &i.impl_item, cx: cx }).src_href() {
|
if let Some(l) = (Item { item: &i.impl_item, cx: cx }).src_href() {
|
||||||
write!(w, "<div class='ghost'></div>")?;
|
write!(w, "<div class='ghost'></div>")?;
|
||||||
|
@ -3327,8 +3328,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
||||||
} else {
|
} else {
|
||||||
render_stability_since_raw(w, since, outer_version)?;
|
render_stability_since_raw(w, since, outer_version)?;
|
||||||
}
|
}
|
||||||
write!(w, "</span>")?;
|
write!(w, "</span></td></tr></tbody></table></h3>")?;
|
||||||
write!(w, "</h3>\n")?;
|
|
||||||
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
|
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
|
||||||
write!(w, "<div class='docblock'>{}</div>",
|
write!(w, "<div class='docblock'>{}</div>",
|
||||||
Markdown(&*dox, &i.impl_item.links()))?;
|
Markdown(&*dox, &i.impl_item.links()))?;
|
||||||
|
@ -3357,19 +3357,20 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
||||||
write!(w, "<h4 id='{}' class=\"{}\">", id, item_type)?;
|
write!(w, "<h4 id='{}' class=\"{}\">", id, item_type)?;
|
||||||
write!(w, "{}", spotlight_decl(decl)?)?;
|
write!(w, "{}", spotlight_decl(decl)?)?;
|
||||||
write!(w, "<span id='{}' class='invisible'>", ns_id)?;
|
write!(w, "<span id='{}' class='invisible'>", ns_id)?;
|
||||||
write!(w, "<code>")?;
|
write!(w, "<table class='table-display'><tbody><tr><td><code>")?;
|
||||||
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl)?;
|
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl)?;
|
||||||
write!(w, "</code>")?;
|
write!(w, "</code>")?;
|
||||||
if let Some(l) = (Item { cx, item }).src_href() {
|
if let Some(l) = (Item { cx, item }).src_href() {
|
||||||
write!(w, "</span><span class='out-of-band'>")?;
|
write!(w, "</span></td><td><span class='out-of-band'>")?;
|
||||||
write!(w, "<div class='ghost'></div>")?;
|
write!(w, "<div class='ghost'></div>")?;
|
||||||
render_stability_since_raw(w, item.stable_since(), outer_version)?;
|
render_stability_since_raw(w, item.stable_since(), outer_version)?;
|
||||||
write!(w, "<a class='srclink' href='{}' title='{}'>[src]</a>",
|
write!(w, "<a class='srclink' href='{}' title='{}'>[src]</a>",
|
||||||
l, "goto source code")?;
|
l, "goto source code")?;
|
||||||
} else {
|
} else {
|
||||||
|
write!(w, "</td><td>")?;
|
||||||
render_stability_since_raw(w, item.stable_since(), outer_version)?;
|
render_stability_since_raw(w, item.stable_since(), outer_version)?;
|
||||||
}
|
}
|
||||||
write!(w, "</span></h4>\n")?;
|
write!(w, "</td></tr></tbody></table></span></h4>")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clean::TypedefItem(ref tydef, _) => {
|
clean::TypedefItem(ref tydef, _) => {
|
||||||
|
|
|
@ -1171,6 +1171,10 @@
|
||||||
return h1.innerHTML;
|
return h1.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pathSplitter(path) {
|
||||||
|
return '<span>' + path.replace(/::/g, '::</span><span>');
|
||||||
|
}
|
||||||
|
|
||||||
function addTab(array, query, display) {
|
function addTab(array, query, display) {
|
||||||
var extraStyle = '';
|
var extraStyle = '';
|
||||||
if (display === false) {
|
if (display === false) {
|
||||||
|
@ -1225,7 +1229,7 @@
|
||||||
|
|
||||||
output += '<tr class="' + type + ' result"><td>' +
|
output += '<tr class="' + type + ' result"><td>' +
|
||||||
'<a href="' + href + '">' +
|
'<a href="' + href + '">' +
|
||||||
displayPath + '<span class="' + type + '">' +
|
pathSplitter(displayPath) + '<span class="' + type + '">' +
|
||||||
name + '</span></a></td><td>' +
|
name + '</span></a></td><td>' +
|
||||||
'<a href="' + href + '">' +
|
'<a href="' + href + '">' +
|
||||||
'<span class="desc">' + escape(item.desc) +
|
'<span class="desc">' + escape(item.desc) +
|
||||||
|
@ -1713,19 +1717,20 @@
|
||||||
// we are collapsing the impl block
|
// we are collapsing the impl block
|
||||||
function implHider(addOrRemove) {
|
function implHider(addOrRemove) {
|
||||||
return function(n) {
|
return function(n) {
|
||||||
if (hasClass(n, "method")) {
|
var is_method = hasClass(n, "method");
|
||||||
if (addOrRemove) {
|
if (is_method || hasClass(n, "type")) {
|
||||||
addClass(n, "hidden-by-impl-hider");
|
if (is_method === true) {
|
||||||
} else {
|
if (addOrRemove) {
|
||||||
removeClass(n, "hidden-by-impl-hider");
|
addClass(n, "hidden-by-impl-hider");
|
||||||
|
} else {
|
||||||
|
removeClass(n, "hidden-by-impl-hider");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var ns = n.nextElementSibling;
|
var ns = n.nextElementSibling;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (ns && (
|
if (ns && (
|
||||||
hasClass(ns, "docblock") ||
|
hasClass(ns, "docblock") ||
|
||||||
hasClass(ns, "stability") ||
|
hasClass(ns, "stability"))) {
|
||||||
false
|
|
||||||
)) {
|
|
||||||
if (addOrRemove) {
|
if (addOrRemove) {
|
||||||
addClass(ns, "hidden-by-impl-hider");
|
addClass(ns, "hidden-by-impl-hider");
|
||||||
} else {
|
} else {
|
||||||
|
@ -1741,12 +1746,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var relatedDoc = toggle.parentNode;
|
var relatedDoc = toggle.parentNode;
|
||||||
|
var docblock = relatedDoc.nextElementSibling;
|
||||||
|
|
||||||
while (!hasClass(relatedDoc, "impl-items")) {
|
while (!hasClass(relatedDoc, "impl-items")) {
|
||||||
relatedDoc = relatedDoc.nextElementSibling;
|
relatedDoc = relatedDoc.nextElementSibling;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!relatedDoc) {
|
if (!relatedDoc && !hasClass(docblock, "docblock")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1754,7 +1760,8 @@
|
||||||
|
|
||||||
var action = mode;
|
var action = mode;
|
||||||
if (action === "toggle") {
|
if (action === "toggle") {
|
||||||
if (hasClass(relatedDoc, "fns-now-collapsed")) {
|
if (hasClass(relatedDoc, "fns-now-collapsed") ||
|
||||||
|
hasClass(docblock, "hidden-by-impl-hider")) {
|
||||||
action = "show";
|
action = "show";
|
||||||
} else {
|
} else {
|
||||||
action = "hide";
|
action = "hide";
|
||||||
|
@ -1763,10 +1770,12 @@
|
||||||
|
|
||||||
if (action === "show") {
|
if (action === "show") {
|
||||||
removeClass(relatedDoc, "fns-now-collapsed");
|
removeClass(relatedDoc, "fns-now-collapsed");
|
||||||
|
removeClass(docblock, "hidden-by-usual-hider");
|
||||||
onEach(toggle.childNodes, adjustToggle(false));
|
onEach(toggle.childNodes, adjustToggle(false));
|
||||||
onEach(relatedDoc.childNodes, implHider(false));
|
onEach(relatedDoc.childNodes, implHider(false));
|
||||||
} else if (action === "hide") {
|
} else if (action === "hide") {
|
||||||
addClass(relatedDoc, "fns-now-collapsed");
|
addClass(relatedDoc, "fns-now-collapsed");
|
||||||
|
addClass(docblock, "hidden-by-usual-hider");
|
||||||
onEach(toggle.childNodes, adjustToggle(true));
|
onEach(toggle.childNodes, adjustToggle(true));
|
||||||
onEach(relatedDoc.childNodes, implHider(true));
|
onEach(relatedDoc.childNodes, implHider(true));
|
||||||
}
|
}
|
||||||
|
@ -1816,6 +1825,9 @@
|
||||||
|
|
||||||
var func = function(e) {
|
var func = function(e) {
|
||||||
var next = e.nextElementSibling;
|
var next = e.nextElementSibling;
|
||||||
|
if (hasClass(e, 'impl') && next && hasClass(next, 'docblock')) {
|
||||||
|
next = next.nextElementSibling;
|
||||||
|
}
|
||||||
if (!next) {
|
if (!next) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,6 +296,11 @@ nav.sub {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#results > table {
|
||||||
|
width: 100%;
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
.content pre.line-numbers {
|
.content pre.line-numbers {
|
||||||
float: left;
|
float: left;
|
||||||
border: none;
|
border: none;
|
||||||
|
@ -387,8 +392,6 @@ h4 > code, h3 > code, .invisible > code {
|
||||||
.content .in-band {
|
.content .in-band {
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
display: inline-block;
|
|
||||||
max-width: calc(100% - 43px);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.in-band > code {
|
.in-band > code {
|
||||||
|
@ -403,7 +406,7 @@ h4 > code, h3 > code, .invisible > code {
|
||||||
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content table {
|
.content table:not(.table-display) {
|
||||||
border-spacing: 0 5px;
|
border-spacing: 0 5px;
|
||||||
border-collapse: separate;
|
border-collapse: separate;
|
||||||
}
|
}
|
||||||
|
@ -470,7 +473,6 @@ h4 > code, h3 > code, .invisible > code {
|
||||||
.content .methods > div:not(.important-traits) { margin-left: 40px; }
|
.content .methods > div:not(.important-traits) { margin-left: 40px; }
|
||||||
|
|
||||||
.content .impl-items .docblock, .content .impl-items .stability {
|
.content .impl-items .docblock, .content .impl-items .stability {
|
||||||
margin-left: 40px;
|
|
||||||
margin-bottom: .6em;
|
margin-bottom: .6em;
|
||||||
}
|
}
|
||||||
.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant {
|
.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant {
|
||||||
|
@ -577,8 +579,16 @@ a {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content .search-results td:first-child { padding-right: 0; }
|
.content .search-results td:first-child {
|
||||||
.content .search-results td:first-child a { padding-right: 10px; }
|
padding-right: 0;
|
||||||
|
width: 75%;
|
||||||
|
}
|
||||||
|
.content .search-results td:first-child a {
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
.content .search-results td:first-child a span {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
tr.result span.primitive::after {
|
tr.result span.primitive::after {
|
||||||
content: ' (primitive type)';
|
content: ' (primitive type)';
|
||||||
|
@ -1254,3 +1264,28 @@ kbd {
|
||||||
/* important because of conflicting rule for small screens */
|
/* important because of conflicting rule for small screens */
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#implementations-list > h3 > span.in-band {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-display {
|
||||||
|
width: 100%;
|
||||||
|
border: 0;
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-spacing: 0;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-display tr td:first-child {
|
||||||
|
padding-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-display tr td:last-child {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
.table-display .out-of-band {
|
||||||
|
position: relative;
|
||||||
|
font-size: 19px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
|
@ -910,6 +910,46 @@ impl<K, V, S> HashMap<K, V, S>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Shrinks the capacity of the map with a lower limit. It will drop
|
||||||
|
/// down no lower than the supplied limit while maintaining the internal rules
|
||||||
|
/// and possibly leaving some space in accordance with the resize policy.
|
||||||
|
///
|
||||||
|
/// Panics if the current capacity is smaller than the supplied
|
||||||
|
/// minimum capacity.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #![feature(shrink_to)]
|
||||||
|
/// use std::collections::HashMap;
|
||||||
|
///
|
||||||
|
/// let mut map: HashMap<i32, i32> = HashMap::with_capacity(100);
|
||||||
|
/// map.insert(1, 2);
|
||||||
|
/// map.insert(3, 4);
|
||||||
|
/// assert!(map.capacity() >= 100);
|
||||||
|
/// map.shrink_to(10);
|
||||||
|
/// assert!(map.capacity() >= 10);
|
||||||
|
/// map.shrink_to(0);
|
||||||
|
/// assert!(map.capacity() >= 2);
|
||||||
|
/// ```
|
||||||
|
#[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");
|
||||||
|
|
||||||
|
let new_raw_cap = self.resize_policy.raw_capacity(max(self.len(), min_capacity));
|
||||||
|
if self.raw_capacity() != new_raw_cap {
|
||||||
|
let old_table = replace(&mut self.table, RawTable::new(new_raw_cap));
|
||||||
|
let old_size = old_table.size();
|
||||||
|
|
||||||
|
// Shrink the table. Naive algorithm for resizing:
|
||||||
|
for (h, k, v) in old_table.into_iter() {
|
||||||
|
self.insert_hashed_nocheck(h, k, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
debug_assert_eq!(self.table.size(), old_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Insert a pre-hashed key-value pair, without first checking
|
/// Insert a pre-hashed key-value pair, without first checking
|
||||||
/// that there's enough room in the buckets. Returns a reference to the
|
/// that there's enough room in the buckets. Returns a reference to the
|
||||||
/// newly insert value.
|
/// newly insert value.
|
||||||
|
|
|
@ -292,6 +292,34 @@ impl<T, S> HashSet<T, S>
|
||||||
self.map.shrink_to_fit()
|
self.map.shrink_to_fit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Shrinks the capacity of the set with a lower limit. It will drop
|
||||||
|
/// down no lower than the supplied limit while maintaining the internal rules
|
||||||
|
/// and possibly leaving some space in accordance with the resize policy.
|
||||||
|
///
|
||||||
|
/// Panics if the current capacity is smaller than the supplied
|
||||||
|
/// minimum capacity.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #![feature(shrink_to)]
|
||||||
|
/// use std::collections::HashSet;
|
||||||
|
///
|
||||||
|
/// let mut set = HashSet::with_capacity(100);
|
||||||
|
/// set.insert(1);
|
||||||
|
/// set.insert(2);
|
||||||
|
/// assert!(set.capacity() >= 100);
|
||||||
|
/// set.shrink_to(10);
|
||||||
|
/// assert!(set.capacity() >= 10);
|
||||||
|
/// set.shrink_to(0);
|
||||||
|
/// assert!(set.capacity() >= 2);
|
||||||
|
/// ```
|
||||||
|
#[inline]
|
||||||
|
#[unstable(feature = "shrink_to", reason = "new API", issue="0")]
|
||||||
|
pub fn shrink_to(&mut self, min_capacity: usize) {
|
||||||
|
self.map.shrink_to(min_capacity)
|
||||||
|
}
|
||||||
|
|
||||||
/// An iterator visiting all elements in arbitrary order.
|
/// An iterator visiting all elements in arbitrary order.
|
||||||
/// The iterator element type is `&'a T`.
|
/// The iterator element type is `&'a T`.
|
||||||
///
|
///
|
||||||
|
|
|
@ -295,6 +295,36 @@ impl OsString {
|
||||||
self.inner.shrink_to_fit()
|
self.inner.shrink_to_fit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Shrinks the capacity of the `OsString` 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::ffi::OsString;
|
||||||
|
///
|
||||||
|
/// let mut s = OsString::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.inner.shrink_to(min_capacity)
|
||||||
|
}
|
||||||
|
|
||||||
/// Converts this `OsString` into a boxed [`OsStr`].
|
/// Converts this `OsString` into a boxed [`OsStr`].
|
||||||
///
|
///
|
||||||
/// [`OsStr`]: struct.OsStr.html
|
/// [`OsStr`]: struct.OsStr.html
|
||||||
|
|
|
@ -298,6 +298,7 @@
|
||||||
#![feature(raw)]
|
#![feature(raw)]
|
||||||
#![feature(rustc_attrs)]
|
#![feature(rustc_attrs)]
|
||||||
#![feature(stdsimd)]
|
#![feature(stdsimd)]
|
||||||
|
#![feature(shrink_to)]
|
||||||
#![feature(slice_bytes)]
|
#![feature(slice_bytes)]
|
||||||
#![feature(slice_concat_ext)]
|
#![feature(slice_concat_ext)]
|
||||||
#![feature(slice_internals)]
|
#![feature(slice_internals)]
|
||||||
|
|
|
@ -104,6 +104,11 @@ impl Buf {
|
||||||
self.inner.shrink_to_fit()
|
self.inner.shrink_to_fit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn shrink_to(&mut self, min_capacity: usize) {
|
||||||
|
self.inner.shrink_to(min_capacity)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn as_slice(&self) -> &Slice {
|
pub fn as_slice(&self) -> &Slice {
|
||||||
unsafe { mem::transmute(&*self.inner) }
|
unsafe { mem::transmute(&*self.inner) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,11 @@ impl Buf {
|
||||||
self.inner.shrink_to_fit()
|
self.inner.shrink_to_fit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn shrink_to(&mut self, min_capacity: usize) {
|
||||||
|
self.inner.shrink_to(min_capacity)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn as_slice(&self) -> &Slice {
|
pub fn as_slice(&self) -> &Slice {
|
||||||
unsafe { mem::transmute(&*self.inner) }
|
unsafe { mem::transmute(&*self.inner) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,11 @@ impl Buf {
|
||||||
self.inner.shrink_to_fit()
|
self.inner.shrink_to_fit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn shrink_to(&mut self, min_capacity: usize) {
|
||||||
|
self.inner.shrink_to(min_capacity)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn as_slice(&self) -> &Slice {
|
pub fn as_slice(&self) -> &Slice {
|
||||||
unsafe { mem::transmute(&*self.inner) }
|
unsafe { mem::transmute(&*self.inner) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,11 @@ impl Buf {
|
||||||
self.inner.shrink_to_fit()
|
self.inner.shrink_to_fit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn shrink_to(&mut self, min_capacity: usize) {
|
||||||
|
self.inner.shrink_to(min_capacity)
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_box(self) -> Box<Slice> {
|
pub fn into_box(self) -> Box<Slice> {
|
||||||
unsafe { mem::transmute(self.inner.into_box()) }
|
unsafe { mem::transmute(self.inner.into_box()) }
|
||||||
|
|
|
@ -253,6 +253,11 @@ impl Wtf8Buf {
|
||||||
self.bytes.shrink_to_fit()
|
self.bytes.shrink_to_fit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn shrink_to(&mut self, min_capacity: usize) {
|
||||||
|
self.bytes.shrink_to(min_capacity)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the number of bytes that this string buffer can hold without reallocating.
|
/// Returns the number of bytes that this string buffer can hold without reallocating.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn capacity(&self) -> usize {
|
pub fn capacity(&self) -> usize {
|
||||||
|
|
|
@ -205,17 +205,13 @@ GEN_SUBTARGETS
|
||||||
|
|
||||||
extern "C" bool LLVMRustHasFeature(LLVMTargetMachineRef TM,
|
extern "C" bool LLVMRustHasFeature(LLVMTargetMachineRef TM,
|
||||||
const char *Feature) {
|
const char *Feature) {
|
||||||
#if LLVM_RUSTLLVM
|
#if LLVM_VERSION_GE(6, 0)
|
||||||
TargetMachine *Target = unwrap(TM);
|
TargetMachine *Target = unwrap(TM);
|
||||||
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
|
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
|
||||||
const FeatureBitset &Bits = MCInfo->getFeatureBits();
|
return MCInfo->checkFeatures(std::string("+") + Feature);
|
||||||
const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getFeatureTable();
|
#else
|
||||||
|
|
||||||
for (auto &FeatureEntry : FeatTable)
|
|
||||||
if (!strcmp(FeatureEntry.Key, Feature))
|
|
||||||
return (Bits & FeatureEntry.Value) == FeatureEntry.Value;
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class LLVMRustCodeModel {
|
enum class LLVMRustCodeModel {
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// no-system-llvm -- needs MCSubtargetInfo::getFeatureTable()
|
// min-llvm-version 6.0
|
||||||
|
// ^ needs MCSubtargetInfo::checkFeatures()
|
||||||
// ignore-cloudabi no std::env
|
// ignore-cloudabi no std::env
|
||||||
|
|
||||||
#![feature(cfg_target_feature)]
|
#![feature(cfg_target_feature)]
|
||||||
|
@ -29,4 +30,7 @@ fn main() {
|
||||||
assert!(cfg!(target_feature = "sse2"),
|
assert!(cfg!(target_feature = "sse2"),
|
||||||
"SSE2 was not detected as available on an x86 platform");
|
"SSE2 was not detected as available on an x86 platform");
|
||||||
}
|
}
|
||||||
|
// check a negative case too -- whitelisted on x86, but not enabled by default
|
||||||
|
assert!(cfg!(not(target_feature = "avx2")),
|
||||||
|
"AVX2 shouldn't be detected as available by default on any platform");
|
||||||
}
|
}
|
||||||
|
|
37
src/test/rustdoc/auxiliary/extern-impl-trait.rs
Normal file
37
src/test/rustdoc/auxiliary/extern-impl-trait.rs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
pub trait Foo {
|
||||||
|
type Associated;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct X;
|
||||||
|
pub struct Y;
|
||||||
|
|
||||||
|
|
||||||
|
impl Foo for X {
|
||||||
|
type Associated = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Foo for Y {
|
||||||
|
type Associated = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl X {
|
||||||
|
pub fn returns_sized<'a>(&'a self) -> impl Foo<Associated=()> + 'a {
|
||||||
|
X
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Y {
|
||||||
|
pub fn returns_unsized<'a>(&'a self) -> Box<impl ?Sized + Foo<Associated=()> + 'a> {
|
||||||
|
Box::new(X)
|
||||||
|
}
|
||||||
|
}
|
21
src/test/rustdoc/extern-impl-trait.rs
Normal file
21
src/test/rustdoc/extern-impl-trait.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
// aux-build:extern-impl-trait.rs
|
||||||
|
|
||||||
|
#![crate_name = "foo"]
|
||||||
|
|
||||||
|
extern crate extern_impl_trait;
|
||||||
|
|
||||||
|
// @has 'foo/struct.X.html' '//code' "impl Foo<Associated = ()> + 'a"
|
||||||
|
pub use extern_impl_trait::X;
|
||||||
|
|
||||||
|
// @has 'foo/struct.Y.html' '//code' "impl ?Sized + Foo<Associated = ()> + 'a"
|
||||||
|
pub use extern_impl_trait::Y;
|
|
@ -30,7 +30,7 @@ mod foo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// @has complex/struct.NotOuter.html
|
// @has complex/struct.NotOuter.html
|
||||||
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<'a, T, K: \
|
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'a, T, K: \
|
||||||
// ?Sized> Send for NotOuter<'a, T, K> where K: for<'b> Fn((&'b bool, &'a u8)) \
|
// ?Sized> Send for NotOuter<'a, T, K> where K: for<'b> Fn((&'b bool, &'a u8)) \
|
||||||
// -> &'b i8, T: MyTrait<'a>, <T as MyTrait<'a>>::MyItem: Copy, 'a: 'static"
|
// -> &'b i8, T: MyTrait<'a>, <T as MyTrait<'a>>::MyItem: Copy, 'a: 'static"
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,10 @@ where
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// @has lifetimes/struct.Foo.html
|
// @has lifetimes/struct.Foo.html
|
||||||
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<'c, K> Send \
|
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'c, K> Send \
|
||||||
// for Foo<'c, K> where K: for<'b> Fn(&'b bool) -> &'c u8, 'c: 'static"
|
// for Foo<'c, K> where K: for<'b> Fn(&'b bool) -> &'c u8, 'c: 'static"
|
||||||
//
|
//
|
||||||
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<'c, K> Sync \
|
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'c, K> Sync \
|
||||||
// for Foo<'c, K> where K: Sync"
|
// for Foo<'c, K> where K: Sync"
|
||||||
pub struct Foo<'c, K: 'c> {
|
pub struct Foo<'c, K: 'c> {
|
||||||
inner_field: Inner<'c, K>,
|
inner_field: Inner<'c, K>,
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// @has manual/struct.Foo.html
|
// @has manual/struct.Foo.html
|
||||||
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' 'impl<T> Sync for \
|
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' 'impl<T> Sync for \
|
||||||
// Foo<T> where T: Sync'
|
// Foo<T> where T: Sync'
|
||||||
//
|
//
|
||||||
// @has - '//*[@id="implementations-list"]/*[@class="impl"]/*/code' \
|
// @has - '//*[@id="implementations-list"]/*[@class="impl"]//*/code' \
|
||||||
// 'impl<T> Send for Foo<T>'
|
// 'impl<T> Send for Foo<T>'
|
||||||
//
|
//
|
||||||
// @count - '//*[@id="implementations-list"]/*[@class="impl"]' 1
|
// @count - '//*[@id="implementations-list"]/*[@class="impl"]' 1
|
||||||
|
|
|
@ -13,10 +13,10 @@ pub struct Inner<T: Copy> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// @has negative/struct.Outer.html
|
// @has negative/struct.Outer.html
|
||||||
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<T> !Send for \
|
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<T> !Send for \
|
||||||
// Outer<T>"
|
// Outer<T>"
|
||||||
//
|
//
|
||||||
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<T> \
|
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<T> \
|
||||||
// !Sync for Outer<T>"
|
// !Sync for Outer<T>"
|
||||||
pub struct Outer<T: Copy> {
|
pub struct Outer<T: Copy> {
|
||||||
inner_field: Inner<T>,
|
inner_field: Inner<T>,
|
||||||
|
|
|
@ -18,10 +18,10 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// @has nested/struct.Foo.html
|
// @has nested/struct.Foo.html
|
||||||
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' 'impl<T> Send for \
|
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' 'impl<T> Send for \
|
||||||
// Foo<T> where T: Copy'
|
// Foo<T> where T: Copy'
|
||||||
//
|
//
|
||||||
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' \
|
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' \
|
||||||
// 'impl<T> Sync for Foo<T> where T: Sync'
|
// 'impl<T> Sync for Foo<T> where T: Sync'
|
||||||
pub struct Foo<T> {
|
pub struct Foo<T> {
|
||||||
inner_field: Inner<T>,
|
inner_field: Inner<T>,
|
||||||
|
|
|
@ -19,7 +19,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// @has no_redundancy/struct.Outer.html
|
// @has no_redundancy/struct.Outer.html
|
||||||
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<T> Send for \
|
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<T> Send for \
|
||||||
// Outer<T> where T: Copy + Send"
|
// Outer<T> where T: Copy + Send"
|
||||||
pub struct Outer<T> {
|
pub struct Outer<T> {
|
||||||
inner_field: Inner<T>,
|
inner_field: Inner<T>,
|
||||||
|
|
|
@ -33,10 +33,10 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// @has project/struct.Foo.html
|
// @has project/struct.Foo.html
|
||||||
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<'c, K> Send \
|
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'c, K> Send \
|
||||||
// for Foo<'c, K> where K: MyTrait<MyItem = bool>, 'c: 'static"
|
// for Foo<'c, K> where K: MyTrait<MyItem = bool>, 'c: 'static"
|
||||||
//
|
//
|
||||||
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<'c, K> Sync \
|
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'c, K> Sync \
|
||||||
// for Foo<'c, K> where K: MyTrait, <K as MyTrait>::MyItem: OtherTrait, 'c: 'static,"
|
// for Foo<'c, K> where K: MyTrait, <K as MyTrait>::MyItem: OtherTrait, 'c: 'static,"
|
||||||
pub struct Foo<'c, K: 'c> {
|
pub struct Foo<'c, K: 'c> {
|
||||||
inner_field: Inner<'c, K>,
|
inner_field: Inner<'c, K>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue