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

Merged
merged 12 commits into from
Feb 27, 2016
4 changes: 2 additions & 2 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ Libraries
improved by using `memchr` to search for newlines][1.7m].
* [`f32::to_degrees` and `f32::to_radians` are stable][1.7f]. The
`f64` variants were stabilized previously.
* [`BTreeMap` was rewritten to use less memory improve performance of
insertion and iteration, the latter by as much as 5x`][1.7bm].
* [`BTreeMap` was rewritten to use less memory and improve the performance
of insertion and iteration, the latter by as much as 5x`][1.7bm].
* [`BTreeSet` and its iterators, `Iter`, `IntoIter`, and `Range` are
covariant over their contained type][1.7bt].
* [`LinkedList` and its iterators, `Iter` and `IntoIter` are covariant
Expand Down
2 changes: 1 addition & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3040,7 +3040,7 @@ the case of a `while` loop, the head is the conditional expression controlling
the loop. In the case of a `for` loop, the head is the call-expression
controlling the loop. If the label is present, then `continue 'foo` returns
control to the head of the loop with label `'foo`, which need not be the
innermost label enclosing the `break` expression, but must enclose it.
innermost label enclosing the `continue` expression, but must enclose it.

A `continue` expression is only permitted in the body of a loop.

Expand Down
52 changes: 35 additions & 17 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,11 @@ impl str {
/// Converts a string slice to a raw pointer.
///
/// As string slices are a slice of bytes, the raw pointer points to a
/// `u8`. This pointer will be pointing to the first byte of the string
/// [`u8`]. This pointer will be pointing to the first byte of the string
/// slice.
///
/// [`u8`]: primitive.u8.html
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -661,7 +663,7 @@ impl str {
/// assert_eq!(None, chars.next());
/// ```
///
/// Remember, `char`s may not match your human intuition about characters:
/// Remember, [`char`]s may not match your human intuition about characters:
///
/// ```
/// let y = "y̆";
Expand All @@ -678,16 +680,18 @@ impl str {
pub fn chars(&self) -> Chars {
core_str::StrExt::chars(self)
}
/// Returns an iterator over the `char`s of a string slice, and their
/// Returns an iterator over the [`char`]s of a string slice, and their
/// positions.
///
/// As a string slice consists of valid UTF-8, we can iterate through a
/// string slice by `char`. This method returns an iterator of both
/// these `char`s, as well as their byte positions.
/// string slice by [`char`]. This method returns an iterator of both
/// these [`char`]s, as well as their byte positions.
///
/// The iterator yields tuples. The position is first, the `char` is
/// The iterator yields tuples. The position is first, the [`char`] is
/// second.
///
/// [`char`]: primitive.char.html
///
/// # Examples
///
/// Basic usage:
Expand All @@ -711,7 +715,7 @@ impl str {
/// assert_eq!(None, char_indices.next());
/// ```
///
/// Remember, `char`s may not match your human intuition about characters:
/// Remember, [`char`]s may not match your human intuition about characters:
///
/// ```
/// let y = "y̆";
Expand Down Expand Up @@ -918,12 +922,13 @@ impl str {
/// Returns the byte index of the first character of this string slice that
/// matches the pattern.
///
/// Returns `None` if the pattern doesn't match.
/// Returns [`None`] if the pattern doesn't match.
///
/// The pattern can be a `&str`, [`char`], or a closure that determines if
/// a character matches.
///
/// [`char`]: primitive.char.html
/// [`None`]: option/enum.Option.html#variant.None
///
/// # Examples
///
Expand Down Expand Up @@ -962,12 +967,13 @@ impl str {
/// Returns the byte index of the last character of this string slice that
/// matches the pattern.
///
/// Returns `None` if the pattern doesn't match.
/// Returns [`None`] if the pattern doesn't match.
///
/// The pattern can be a `&str`, [`char`], or a closure that determines if
/// a character matches.
///
/// [`char`]: primitive.char.html
/// [`None`]: option/enum.Option.html#variant.None
///
/// # Examples
///
Expand Down Expand Up @@ -1187,14 +1193,18 @@ impl str {
/// An iterator over substrings of `self`, separated by characters
/// matched by a pattern and yielded in reverse order.
///
/// The pattern can be a simple `&str`, `char`, or a closure that
/// The pattern can be a simple `&str`, [`char`], or a closure that
/// determines the split.
/// Additional libraries might provide more complex patterns like
/// regular expressions.
///
/// Equivalent to `split`, except that the trailing substring is
/// [`char`]: primitive.char.html
///
/// Equivalent to [`split()`], except that the trailing substring is
/// skipped if empty.
///
/// [`split()`]: #method.split
///
/// This method can be used for string data that is _terminated_,
/// rather than _separated_ by a pattern.
///
Expand Down Expand Up @@ -1457,7 +1467,7 @@ impl str {
/// # Iterator behavior
///
/// The returned iterator requires that the pattern supports a reverse
/// search, and it will be a `[DoubleEndedIterator]` if a forward/reverse
/// search, and it will be a [`DoubleEndedIterator`] if a forward/reverse
/// search yields the same elements.
///
/// [`DoubleEndedIterator`]: iter/trait.DoubleEndedIterator.html
Expand Down Expand Up @@ -1694,9 +1704,11 @@ impl str {
///
/// # Errors
///
/// Will return `Err` if it's not possible to parse this string slice into
/// Will return [`Err`] if it's not possible to parse this string slice into
/// the desired type.
///
/// [`Err`]: str/trait.FromStr.html#associatedtype.Err
///
/// # Example
///
/// Basic usage
Expand All @@ -1707,7 +1719,7 @@ impl str {
/// assert_eq!(4, four);
/// ```
///
/// Using the 'turbofish' instead of annotationg `four`:
/// Using the 'turbofish' instead of annotating `four`:
///
/// ```
/// let four = "4".parse::<u32>();
Expand Down Expand Up @@ -1765,11 +1777,13 @@ impl str {
result
}

/// Returns the lowercase equivalent of this string slice, as a new `String`.
/// Returns the lowercase equivalent of this string slice, as a new [`String`].
///
/// 'Lowercase' is defined according to the terms of the Unicode Derived Core Property
/// `Lowercase`.
///
/// [`String`]: string/struct.String.html
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -1839,11 +1853,13 @@ impl str {
}
}

/// Returns the uppercase equivalent of this string slice, as a new `String`.
/// Returns the uppercase equivalent of this string slice, as a new [`String`].
///
/// 'Uppercase' is defined according to the terms of the Unicode Derived Core Property
/// `Uppercase`.
///
/// [`String`]: string/struct.String.html
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -1884,7 +1900,9 @@ impl str {
self.chars().flat_map(|c| c.escape_unicode()).collect()
}

/// Converts a `Box<str>` into a `String` without copying or allocating.
/// Converts a `Box<str>` into a [`String`] without copying or allocating.
///
/// [`String`]: string/struct.String.html
///
/// # Examples
///
Expand Down
10 changes: 10 additions & 0 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
self.with_lint_attrs(&it.attrs, |cx| {
run_lints!(cx, check_foreign_item, late_passes, it);
hir_visit::walk_foreign_item(cx, it);
run_lints!(cx, check_foreign_item_post, late_passes, it);
})
}

Expand Down Expand Up @@ -795,6 +796,7 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
body: &'v hir::Block, span: Span, id: ast::NodeId) {
run_lints!(self, check_fn, late_passes, fk, decl, body, span, id);
hir_visit::walk_fn(self, fk, decl, body, span);
run_lints!(self, check_fn_post, late_passes, fk, decl, body, span, id);
}

fn visit_variant_data(&mut self,
Expand Down Expand Up @@ -835,6 +837,7 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
fn visit_mod(&mut self, m: &hir::Mod, s: Span, n: ast::NodeId) {
run_lints!(self, check_mod, late_passes, m, s, n);
hir_visit::walk_mod(self, m);
run_lints!(self, check_mod_post, late_passes, m, s, n);
}

fn visit_local(&mut self, l: &hir::Local) {
Expand Down Expand Up @@ -874,6 +877,7 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
run_lints!(cx, check_trait_item, late_passes, trait_item);
cx.visit_ids(|v| v.visit_trait_item(trait_item));
hir_visit::walk_trait_item(cx, trait_item);
run_lints!(cx, check_trait_item_post, late_passes, trait_item);
});
}

Expand All @@ -882,6 +886,7 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
run_lints!(cx, check_impl_item, late_passes, impl_item);
cx.visit_ids(|v| v.visit_impl_item(impl_item));
hir_visit::walk_impl_item(cx, impl_item);
run_lints!(cx, check_impl_item_post, late_passes, impl_item);
});
}

Expand Down Expand Up @@ -928,6 +933,7 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
self.with_lint_attrs(&it.attrs, |cx| {
run_lints!(cx, check_foreign_item, early_passes, it);
ast_visit::walk_foreign_item(cx, it);
run_lints!(cx, check_foreign_item_post, early_passes, it);
})
}

Expand All @@ -952,6 +958,7 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
body: &'v ast::Block, span: Span, id: ast::NodeId) {
run_lints!(self, check_fn, early_passes, fk, decl, body, span, id);
ast_visit::walk_fn(self, fk, decl, body, span);
run_lints!(self, check_fn_post, early_passes, fk, decl, body, span, id);
}

fn visit_variant_data(&mut self,
Expand Down Expand Up @@ -992,6 +999,7 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
fn visit_mod(&mut self, m: &ast::Mod, s: Span, n: ast::NodeId) {
run_lints!(self, check_mod, early_passes, m, s, n);
ast_visit::walk_mod(self, m);
run_lints!(self, check_mod_post, early_passes, m, s, n);
}

fn visit_local(&mut self, l: &ast::Local) {
Expand Down Expand Up @@ -1031,6 +1039,7 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
run_lints!(cx, check_trait_item, early_passes, trait_item);
cx.visit_ids(|v| v.visit_trait_item(trait_item));
ast_visit::walk_trait_item(cx, trait_item);
run_lints!(cx, check_trait_item_post, early_passes, trait_item);
});
}

Expand All @@ -1039,6 +1048,7 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
run_lints!(cx, check_impl_item, early_passes, impl_item);
cx.visit_ids(|v| v.visit_impl_item(impl_item));
ast_visit::walk_impl_item(cx, impl_item);
run_lints!(cx, check_impl_item_post, early_passes, impl_item);
});
}

Expand Down
12 changes: 12 additions & 0 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ pub trait LateLintPass: LintPass {
fn check_crate(&mut self, _: &LateContext, _: &hir::Crate) { }
fn check_crate_post(&mut self, _: &LateContext, _: &hir::Crate) { }
fn check_mod(&mut self, _: &LateContext, _: &hir::Mod, _: Span, _: ast::NodeId) { }
fn check_mod_post(&mut self, _: &LateContext, _: &hir::Mod, _: Span, _: ast::NodeId) { }
fn check_foreign_item(&mut self, _: &LateContext, _: &hir::ForeignItem) { }
fn check_foreign_item_post(&mut self, _: &LateContext, _: &hir::ForeignItem) { }
fn check_item(&mut self, _: &LateContext, _: &hir::Item) { }
fn check_item_post(&mut self, _: &LateContext, _: &hir::Item) { }
fn check_local(&mut self, _: &LateContext, _: &hir::Local) { }
Expand All @@ -150,8 +152,12 @@ pub trait LateLintPass: LintPass {
fn check_generics(&mut self, _: &LateContext, _: &hir::Generics) { }
fn check_fn(&mut self, _: &LateContext,
_: FnKind, _: &hir::FnDecl, _: &hir::Block, _: Span, _: ast::NodeId) { }
fn check_fn_post(&mut self, _: &LateContext,
_: FnKind, _: &hir::FnDecl, _: &hir::Block, _: Span, _: ast::NodeId) { }
fn check_trait_item(&mut self, _: &LateContext, _: &hir::TraitItem) { }
fn check_trait_item_post(&mut self, _: &LateContext, _: &hir::TraitItem) { }
fn check_impl_item(&mut self, _: &LateContext, _: &hir::ImplItem) { }
fn check_impl_item_post(&mut self, _: &LateContext, _: &hir::ImplItem) { }
fn check_struct_def(&mut self, _: &LateContext,
_: &hir::VariantData, _: ast::Name, _: &hir::Generics, _: ast::NodeId) { }
fn check_struct_def_post(&mut self, _: &LateContext,
Expand Down Expand Up @@ -179,7 +185,9 @@ pub trait EarlyLintPass: LintPass {
fn check_crate(&mut self, _: &EarlyContext, _: &ast::Crate) { }
fn check_crate_post(&mut self, _: &EarlyContext, _: &ast::Crate) { }
fn check_mod(&mut self, _: &EarlyContext, _: &ast::Mod, _: Span, _: ast::NodeId) { }
fn check_mod_post(&mut self, _: &EarlyContext, _: &ast::Mod, _: Span, _: ast::NodeId) { }
fn check_foreign_item(&mut self, _: &EarlyContext, _: &ast::ForeignItem) { }
fn check_foreign_item_post(&mut self, _: &EarlyContext, _: &ast::ForeignItem) { }
fn check_item(&mut self, _: &EarlyContext, _: &ast::Item) { }
fn check_item_post(&mut self, _: &EarlyContext, _: &ast::Item) { }
fn check_local(&mut self, _: &EarlyContext, _: &ast::Local) { }
Expand All @@ -195,8 +203,12 @@ pub trait EarlyLintPass: LintPass {
fn check_generics(&mut self, _: &EarlyContext, _: &ast::Generics) { }
fn check_fn(&mut self, _: &EarlyContext,
_: ast_visit::FnKind, _: &ast::FnDecl, _: &ast::Block, _: Span, _: ast::NodeId) { }
fn check_fn_post(&mut self, _: &EarlyContext,
_: ast_visit::FnKind, _: &ast::FnDecl, _: &ast::Block, _: Span, _: ast::NodeId) { }
fn check_trait_item(&mut self, _: &EarlyContext, _: &ast::TraitItem) { }
fn check_trait_item_post(&mut self, _: &EarlyContext, _: &ast::TraitItem) { }
fn check_impl_item(&mut self, _: &EarlyContext, _: &ast::ImplItem) { }
fn check_impl_item_post(&mut self, _: &EarlyContext, _: &ast::ImplItem) { }
fn check_struct_def(&mut self, _: &EarlyContext,
_: &ast::VariantData, _: ast::Ident, _: &ast::Generics, _: ast::NodeId) { }
fn check_struct_def_post(&mut self, _: &EarlyContext,
Expand Down
5 changes: 5 additions & 0 deletions src/librustc/middle/subst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,11 @@ impl<'a,T> Iterator for EnumeratedItems<'a,T> {
None
}
}

fn size_hint(&self) -> (usize, Option<usize>) {
let size = self.vec.as_slice().len();
(size, Some(size))
}
}

impl<T> IntoIterator for VecPerParamSpace<T> {
Expand Down
6 changes: 6 additions & 0 deletions src/libstd/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ mod prim_tuple { }
///
/// *[See also the `std::f32` module](f32/index.html).*
///
/// However, please note that examples are shared between the `f64` and `f32`
/// primitive types. So it's normal if you see usage of `f64` in there.
///
mod prim_f32 { }

#[doc(primitive = "f64")]
Expand All @@ -496,6 +499,9 @@ mod prim_f32 { }
///
/// *[See also the `std::f64` module](f64/index.html).*
///
/// However, please note that examples are shared between the `f64` and `f32`
/// primitive types. So it's normal if you see usage of `f32` in there.
///
mod prim_f64 { }

#[doc(primitive = "i8")]
Expand Down