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 7 pull requests #40969

Closed
wants to merge 28 commits into from
Closed
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
70deac1
fixed some clippy warnings in libcollections
llogiq Mar 15, 2017
d6c8dde
Merge branch 'master' into clippy-libcollections
llogiq Mar 19, 2017
2715101
Add missing urls in ptr docs
GuillaumeGomez Mar 21, 2017
4dc1225
Add helpful hint on io function for beginners
pirate Mar 23, 2017
53d5082
requested changes
pirate Mar 23, 2017
04fbec1
newline for breathing room
pirate Mar 23, 2017
1cbfdf4
Merge branch 'master' into clippy-libcollections
llogiq Mar 25, 2017
4806f01
Fix tidy errors and simplify example
pirate Mar 27, 2017
756f224
Adding links for Atomics docs #29377
projektir Mar 28, 2017
cd2ec7e
add missing import
pirate Mar 28, 2017
11ce5b7
Make overlapping_inherent_impls lint a hard error
topecongiro Mar 22, 2017
4ea03c8
Fixing formatting issues #29377
projektir Mar 29, 2017
9d4b486
Modify Lines' description
donniebishop Mar 30, 2017
0f5cf54
Modify Bytes' description
donniebishop Mar 30, 2017
41e0498
Modify CharIndices' description
donniebishop Mar 30, 2017
17b4884
Modify Chars' description
donniebishop Mar 30, 2017
5d14ccb
Modify EncodeUtf16's description
donniebishop Mar 30, 2017
a4a7166
Modify SplitWhitespace's description
donniebishop Mar 30, 2017
c4b11d1
Revert SplitWhitespace's description
donniebishop Mar 30, 2017
3b39621
Remove parentheses in method references
donniebishop Mar 30, 2017
0e2d3d4
Test sort algorithms using a random cmp function
Mar 31, 2017
6db3051
Rollup merge of #40541 - llogiq:clippy-libcollections, r=brson
frewsxcv Mar 31, 2017
81e7f35
Rollup merge of #40703 - GuillaumeGomez:pointer-docs, r=steveklabnik
frewsxcv Mar 31, 2017
bd77add
Rollup merge of #40728 - topecongiro:stabilize, r=arielb1
frewsxcv Mar 31, 2017
6de74a4
Rollup merge of #40763 - pirate:patch-2, r=steveklabnik
frewsxcv Mar 31, 2017
f5d0105
Rollup merge of #40871 - projektir:atomic_links, r=steveklabnik
frewsxcv Mar 31, 2017
cd631a9
Rollup merge of #40935 - donniebishop:str_boilerplate_docs, r=stevekl…
frewsxcv Mar 31, 2017
07b657a
Rollup merge of #40947 - stjepang:test-sort-random-cmp, r=alexcrichton
frewsxcv Mar 31, 2017
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
8 changes: 4 additions & 4 deletions src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ impl<'a, T> Hole<'a, T> {
/// Unsafe because index must be within the data slice and not equal to pos.
#[inline]
unsafe fn get(&self, index: usize) -> &T {
debug_assert!(index != self.pos);
debug_assert_ne!(index, self.pos);
debug_assert!(index < self.data.len());
self.data.get_unchecked(index)
}
Expand All @@ -951,7 +951,7 @@ impl<'a, T> Hole<'a, T> {
/// Unsafe because index must be within the data slice and not equal to pos.
#[inline]
unsafe fn move_to(&mut self, index: usize) {
debug_assert!(index != self.pos);
debug_assert_ne!(index, self.pos);
debug_assert!(index < self.data.len());
let index_ptr: *const _ = self.data.get_unchecked(index);
let hole_ptr = self.data.get_unchecked_mut(self.pos);
Expand Down Expand Up @@ -1194,8 +1194,8 @@ impl<T: Ord, I: IntoIterator<Item = T>> SpecExtend<I> for BinaryHeap<T> {
}

impl<T: Ord> SpecExtend<BinaryHeap<T>> for BinaryHeap<T> {
fn spec_extend(&mut self, ref mut other: BinaryHeap<T>) {
self.append(other);
fn spec_extend(&mut self, mut other: BinaryHeap<T>) {
self.append(&mut other);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ impl<'a, B: ?Sized> fmt::Debug for Cow<'a, B>
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Borrowed(ref b) => fmt::Debug::fmt(b, f),
Borrowed(b) => fmt::Debug::fmt(b, f),
Owned(ref o) => fmt::Debug::fmt(o, f),
}
}
Expand All @@ -267,7 +267,7 @@ impl<'a, B: ?Sized> fmt::Display for Cow<'a, B>
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Borrowed(ref b) => fmt::Display::fmt(b, f),
Borrowed(b) => fmt::Display::fmt(b, f),
Owned(ref o) => fmt::Display::fmt(o, f),
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl<K, Q: ?Sized> super::Recover<Q> for BTreeMap<K, ()>
}
}

/// An iterator over a BTreeMap's entries.
/// An iterator over a `BTreeMap`'s entries.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Iter<'a, K: 'a, V: 'a> {
range: Range<'a, K, V>,
Expand All @@ -276,15 +276,15 @@ impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Iter<'a, K, V> {
}
}

/// A mutable iterator over a BTreeMap's entries.
/// A mutable iterator over a `BTreeMap`'s entries.
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
pub struct IterMut<'a, K: 'a, V: 'a> {
range: RangeMut<'a, K, V>,
length: usize,
}

/// An owning iterator over a BTreeMap's entries.
/// An owning iterator over a `BTreeMap`'s entries.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IntoIter<K, V> {
front: Handle<NodeRef<marker::Owned, K, V, marker::Leaf>, marker::Edge>,
Expand All @@ -303,7 +303,7 @@ impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for IntoIter<K, V> {
}
}

/// An iterator over a BTreeMap's keys.
/// An iterator over a `BTreeMap`'s keys.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Keys<'a, K: 'a, V: 'a> {
inner: Iter<'a, K, V>,
Expand All @@ -316,7 +316,7 @@ impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Keys<'a, K, V> {
}
}

/// An iterator over a BTreeMap's values.
/// An iterator over a `BTreeMap`'s values.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Values<'a, K: 'a, V: 'a> {
inner: Iter<'a, K, V>,
Expand All @@ -329,14 +329,14 @@ impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Values<'a, K, V>
}
}

/// A mutable iterator over a BTreeMap's values.
/// A mutable iterator over a `BTreeMap`'s values.
#[stable(feature = "map_values_mut", since = "1.10.0")]
#[derive(Debug)]
pub struct ValuesMut<'a, K: 'a, V: 'a> {
inner: IterMut<'a, K, V>,
}

/// An iterator over a sub-range of BTreeMap's entries.
/// An iterator over a sub-range of `BTreeMap`'s entries.
#[stable(feature = "btree_range", since = "1.17.0")]
pub struct Range<'a, K: 'a, V: 'a> {
front: Handle<NodeRef<marker::Immut<'a>, K, V, marker::Leaf>, marker::Edge>,
Expand All @@ -350,7 +350,7 @@ impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Range<'a, K, V>
}
}

/// A mutable iterator over a sub-range of BTreeMap's entries.
/// A mutable iterator over a sub-range of `BTreeMap`'s entries.
#[stable(feature = "btree_range", since = "1.17.0")]
pub struct RangeMut<'a, K: 'a, V: 'a> {
front: Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>,
Expand Down Expand Up @@ -685,12 +685,12 @@ impl<K: Ord, V> BTreeMap<K, V> {
#[stable(feature = "btree_append", since = "1.11.0")]
pub fn append(&mut self, other: &mut Self) {
// Do we have to append anything at all?
if other.len() == 0 {
if other.is_empty() {
return;
}

// We can just swap `self` and `other` if `self` is empty.
if self.len() == 0 {
if self.is_empty() {
mem::swap(self, other);
return;
}
Expand Down Expand Up @@ -1894,7 +1894,7 @@ impl<K, V> BTreeMap<K, V> {
/// assert_eq!(keys, [1, 2]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn keys<'a>(&'a self) -> Keys<'a, K, V> {
pub fn keys(&self) -> Keys<K, V> {
Keys { inner: self.iter() }
}

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

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

fn handle_underfull_node<'a, K, V>(node: NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>)
-> UnderflowResult<'a, K, V> {
fn handle_underfull_node<K, V>(node: NodeRef<marker::Mut, K, V, marker::LeafOrInternal>)
-> UnderflowResult<K, V> {
let parent = if let Ok(parent) = node.ascend() {
parent
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/libcollections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
}

/// Temporarily takes out another, immutable reference to the same node.
fn reborrow<'a>(&'a self) -> NodeRef<marker::Immut<'a>, K, V, Type> {
fn reborrow(&self) -> NodeRef<marker::Immut, K, V, Type> {
NodeRef {
height: self.height,
node: self.node,
Expand Down Expand Up @@ -964,7 +964,7 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::
fn insert_fit(&mut self, key: K, val: V, edge: Root<K, V>) {
// Necessary for correctness, but in an internal module
debug_assert!(self.node.len() < CAPACITY);
debug_assert!(edge.height == self.node.height - 1);
debug_assert_eq!(edge.height, self.node.height - 1);

unsafe {
// This cast is a lie, but it allows us to reuse the key/value insertion logic.
Expand Down Expand Up @@ -992,7 +992,7 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::
-> InsertResult<'a, K, V, marker::Internal> {

// Necessary for correctness, but this is an internal module
debug_assert!(edge.height == self.node.height - 1);
debug_assert_eq!(edge.height, self.node.height - 1);

if self.node.len() < CAPACITY {
self.insert_fit(key, val, edge);
Expand Down Expand Up @@ -1488,8 +1488,8 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, ma
let right_new_len = left_node.len() - left_new_len;
let mut right_node = right.reborrow_mut();

debug_assert!(right_node.len() == 0);
debug_assert!(left_node.height == right_node.height);
debug_assert_eq!(right_node.len(), 0);
debug_assert_eq!(left_node.height, right_node.height);

let left_kv = left_node.reborrow_mut().into_kv_pointers_mut();
let right_kv = right_node.reborrow_mut().into_kv_pointers_mut();
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ impl<'a, T: Ord> Iterator for Intersection<'a, T> {
fn next(&mut self) -> Option<&'a T> {
loop {
let o_cmp = match (self.a.peek(), self.b.peek()) {
(None, _) => None,
(None, _) |
(_, None) => None,
(Some(a1), Some(b1)) => Some(a1.cmp(b1)),
};
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/enum_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl<E: CLike> BitXor for EnumSet<E> {
}
}

/// An iterator over an EnumSet
/// An iterator over an `EnumSet`
pub struct Iter<E> {
index: usize,
bits: usize,
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

//! Collection types.
//!
//! See [std::collections](../std/collections/index.html) for a detailed discussion of
//! See [`std::collections`](../std/collections/index.html) for a detailed discussion of
//! collections in Rust.

#![crate_name = "collections"]
Expand Down
12 changes: 6 additions & 6 deletions src/libcollections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub struct IterMut<'a, T: 'a> {
impl<'a, T: 'a + fmt::Debug> fmt::Debug for IterMut<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("IterMut")
.field(self.clone())
.field(self)
.finish()
}
}
Expand All @@ -111,7 +111,7 @@ pub struct IntoIter<T> {
impl<T: fmt::Debug> fmt::Debug for IntoIter<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("IntoIter")
.field(self.clone())
.field(self)
.finish()
}
}
Expand Down Expand Up @@ -1020,8 +1020,8 @@ impl<I: IntoIterator> SpecExtend<I> for LinkedList<I::Item> {
}

impl<T> SpecExtend<LinkedList<T>> for LinkedList<T> {
fn spec_extend(&mut self, ref mut other: LinkedList<T>) {
self.append(other);
fn spec_extend(&mut self, mut other: LinkedList<T>) {
self.append(&mut other);
}
}

Expand Down Expand Up @@ -1110,7 +1110,7 @@ pub struct FrontPlace<'a, T: 'a> {
impl<'a, T: 'a + fmt::Debug> fmt::Debug for FrontPlace<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("FrontPlace")
.field(self.clone())
.field(self)
.finish()
}
}
Expand Down Expand Up @@ -1165,7 +1165,7 @@ pub struct BackPlace<'a, T: 'a> {
impl<'a, T: 'a + fmt::Debug> fmt::Debug for BackPlace<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("BackPlace")
.field(self.clone())
.field(self)
.finish()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use core::ops::{RangeFull, Range, RangeTo, RangeFrom, RangeInclusive, RangeToInclusive};
use Bound::{self, Excluded, Included, Unbounded};

/// **RangeArgument** is implemented by Rust's built-in range types, produced
/// **`RangeArgument`** is implemented by Rust's built-in range types, produced
/// by range syntax like `..`, `a..`, `..b` or `c..d`.
pub trait RangeArgument<T: ?Sized> {
/// Start index bound.
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ unsafe fn merge<T, F>(v: &mut [T], mid: usize, buf: *mut T, is_less: &mut F)
}
}

/// This merge sort borrows some (but not all) ideas from TimSort, which is described in detail
/// This merge sort borrows some (but not all) ideas from `TimSort`, which is described in detail
/// [here](http://svn.python.org/projects/python/trunk/Objects/listsort.txt).
///
/// The algorithm identifies strictly descending and non-descending subsequences, which are called
Expand Down
14 changes: 10 additions & 4 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,15 @@ impl<S: Borrow<str>> SliceConcatExt<str> for [S] {
}
}

/// External iterator for a string's UTF-16 code units.
/// An iterator of [`u16`] over the string encoded as UTF-16.
///
/// For use with the `std::iter` module.
/// [`u16`]: ../../std/primitive.u16.html
///
/// This struct is created by the [`encode_utf16`] method on [`str`].
/// See its documentation for more.
///
/// [`encode_utf16`]: ../../std/primitive.str.html#method.encode_utf16
/// [`str`]: ../../std/primitive.str.html
#[derive(Clone)]
#[stable(feature = "encode_utf16", since = "1.8.0")]
pub struct EncodeUtf16<'a> {
Expand Down Expand Up @@ -1829,7 +1835,7 @@ impl str {
fn map_uppercase_sigma(from: &str, i: usize, to: &mut String) {
// See http://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G33992
// for the definition of `Final_Sigma`.
debug_assert!('Σ'.len_utf8() == 2);
debug_assert_eq!('Σ'.len_utf8(), 2);
let is_word_final = case_ignoreable_then_cased(from[..i].chars().rev()) &&
!case_ignoreable_then_cased(from[i + 2..].chars());
to.push_str(if is_word_final { "ς" } else { "σ" });
Expand Down Expand Up @@ -1876,7 +1882,7 @@ impl str {
pub fn to_uppercase(&self) -> String {
let mut s = String::with_capacity(self.len());
s.extend(self.chars().flat_map(|c| c.to_uppercase()));
return s;
s
}

/// Escapes each char in `s` with `char::escape_debug`.
Expand Down
12 changes: 6 additions & 6 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ impl String {
/// assert_eq!("Hello �World", output);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> Cow<'a, str> {
pub fn from_utf8_lossy(v: &[u8]) -> Cow<str> {
let mut i;
match str::from_utf8(v) {
Ok(s) => return Cow::Borrowed(s),
Expand Down Expand Up @@ -591,9 +591,9 @@ impl String {
}
3 => {
match (byte, safe_get(v, i, total)) {
(0xE0, 0xA0...0xBF) => (),
(0xE1...0xEC, 0x80...0xBF) => (),
(0xED, 0x80...0x9F) => (),
(0xE0, 0xA0...0xBF) |
(0xE1...0xEC, 0x80...0xBF) |
(0xED, 0x80...0x9F) |
(0xEE...0xEF, 0x80...0xBF) => (),
_ => {
error!();
Expand All @@ -609,8 +609,8 @@ impl String {
}
4 => {
match (byte, safe_get(v, i, total)) {
(0xF0, 0x90...0xBF) => (),
(0xF1...0xF3, 0x80...0xBF) => (),
(0xF0, 0x90...0xBF) |
(0xF1...0xF3, 0x80...0xBF) |
(0xF4, 0x80...0x8F) => (),
_ => {
error!();
Expand Down
Loading