Skip to content

Rollup of 9 pull requests #37090

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

Merged
merged 28 commits into from
Oct 12, 2016
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
9cfd4ef
rustdoc: print arguments to bare functions on their own line
Sep 23, 2016
fccfc53
rustdoc: format non-self arguments for struct methods on their own line
Sep 23, 2016
2a274e7
rustdoc: format struct methods like rustfmt
Sep 26, 2016
fb442a7
rustdoc: format bare functions like rustfmt
Sep 26, 2016
2a7d495
rustdoc: fix regression when printing single-element tuples
Sep 27, 2016
0c2b258
add rustdoc test for adding line breaks
Sep 27, 2016
2130637
Book: Be very explicit of lifetimes being descriptive
KillTheMule Oct 6, 2016
7f02eb3
Distinguish lifetimes and their annotations
KillTheMule Oct 6, 2016
a542302
Another shot at clarity
KillTheMule Oct 6, 2016
2a0bd6d
Typos
KillTheMule Oct 6, 2016
0d0cdb7
Wrap & improve
KillTheMule Oct 7, 2016
5a30f0c
Add ICH test case for statics
flodiebold Oct 8, 2016
eb07a6c
Add ICH test case for consts
flodiebold Oct 8, 2016
9d36426
Update E0303 to new error format
jfirebaugh Oct 9, 2016
67a5444
Merge `Printer::token` and `Printer::size`.
nnethercote Oct 7, 2016
f52723c
ICH: Enable some cases in trait definition hashing.
michaelwoerister Oct 10, 2016
3c66f96
Add missing urls on String module
GuillaumeGomez Oct 10, 2016
2b7222d
Add method str::repeat(self, usize) -> String
bluss Sep 24, 2016
ee3de44
Changed 0 into '0'
Oct 10, 2016
6717dba
Rollup merge of #36679 - QuietMisdreavus:rustdoc-line-breaks, r=steve…
GuillaumeGomez Oct 11, 2016
0b7fe4d
Rollup merge of #36699 - bluss:repeat-str, r=alexcrichton
GuillaumeGomez Oct 11, 2016
97e9eac
Rollup merge of #36997 - KillTheMule:patch-1, r=steveklabnik
GuillaumeGomez Oct 11, 2016
0ff115c
Rollup merge of #37040 - flodiebold:hash-tests, r=michaelwoerister
GuillaumeGomez Oct 11, 2016
ac94bde
Rollup merge of #37060 - jfirebaugh:E0303, r=jonathandturner
GuillaumeGomez Oct 11, 2016
ffa9bbf
Rollup merge of #37065 - nnethercote:opt-mk_printer, r=nikomatsakis
GuillaumeGomez Oct 11, 2016
bfbd0a5
Rollup merge of #37072 - michaelwoerister:enable-trait-ich-tests, r=n…
GuillaumeGomez Oct 11, 2016
5c29a91
Rollup merge of #37073 - GuillaumeGomez:string_url, r=steveklabnik
GuillaumeGomez Oct 11, 2016
30164c2
Rollup merge of #37081 - p512:master, r=sfackler
GuillaumeGomez Oct 11, 2016
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: 6 additions & 2 deletions src/doc/book/lifetimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ To fix this, we have to make sure that step four never happens after step
three. The ownership system in Rust does this through a concept called
lifetimes, which describe the scope that a reference is valid for.

When we have a function that takes an argument by reference, we can be
implicit or explicit about the lifetime of the reference:
**Note** It's important to understand that lifetime annotations are
_descriptive_, not _prescriptive_. This means that how long a reference is valid
is determined by the code, not by the annotations. The annotations, however,
give information about lifetimes to the compiler that uses them to check the
validity of references. The compiler can do so without annotations in simple
cases, but needs the programmers support in complex scenarios.

```rust
// implicit
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
//! format := '{' [ argument ] [ ':' format_spec ] '}'
//! argument := integer | identifier
//!
//! format_spec := [[fill]align][sign]['#'][0][width]['.' precision][type]
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision][type]
//! fill := character
//! align := '<' | '^' | '>'
//! sign := '+' | '-'
Expand Down
20 changes: 20 additions & 0 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1789,4 +1789,24 @@ impl str {
String::from_utf8_unchecked(slice.into_vec())
}
}

/// Create a [`String`] by repeating a string `n` times.
///
/// [`String`]: string/struct.String.html
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(repeat_str)]
///
/// assert_eq!("abc".repeat(4), String::from("abcabcabcabc"));
/// ```
#[unstable(feature = "repeat_str", issue = "37079")]
pub fn repeat(&self, n: usize) -> String {
let mut s = String::with_capacity(self.len() * n);
s.extend((0..n).map(|_| self));
s
}
}
7 changes: 4 additions & 3 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
//! [`ToString`]s, and several error types that may result from working with
//! [`String`]s.
//!
//! [`String`]: struct.String.html
//! [`ToString`]: trait.ToString.html
//!
//! # Examples
//!
//! There are multiple ways to create a new `String` from a string literal:
//! There are multiple ways to create a new [`String`] from a string literal:
//!
//! ```
//! let s = "Hello".to_string();
Expand All @@ -28,9 +27,11 @@
//! let s: String = "also this".into();
//! ```
//!
//! You can create a new `String` from an existing one by concatenating with
//! You can create a new [`String`] from an existing one by concatenating with
//! `+`:
//!
//! [`String`]: struct.String.html
//!
//! ```
//! let s = "Hello".to_string();
//!
Expand Down
1 change: 1 addition & 0 deletions src/libcollectionstest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#![feature(enumset)]
#![feature(pattern)]
#![feature(rand)]
#![feature(repeat_str)]
#![feature(step_by)]
#![feature(str_escape)]
#![feature(str_replacen)]
Expand Down
7 changes: 7 additions & 0 deletions src/libcollectionstest/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,13 @@ fn test_cow_from() {
}
}

#[test]
fn test_repeat() {
assert_eq!("".repeat(3), "");
assert_eq!("abc".repeat(0), "");
assert_eq!("α".repeat(3), "ααα");
}

mod pattern {
use std::str::pattern::Pattern;
use std::str::pattern::{Searcher, ReverseSearcher};
Expand Down
6 changes: 4 additions & 2 deletions src/librustc_const_eval/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1238,8 +1238,10 @@ impl<'a, 'b, 'tcx, 'v> Visitor<'v> for AtBindingPatternVisitor<'a, 'b, 'tcx> {
match pat.node {
PatKind::Binding(.., ref subpat) => {
if !self.bindings_allowed {
span_err!(self.cx.tcx.sess, pat.span, E0303,
"pattern bindings are not allowed after an `@`");
struct_span_err!(self.cx.tcx.sess, pat.span, E0303,
"pattern bindings are not allowed after an `@`")
.span_label(pat.span, &format!("not allowed after `@`"))
.emit();
}

if subpat.is_some() {
Expand Down
Loading