diff options
| author | bors <bors@rust-lang.org> | 2015-05-10 20:44:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-05-10 20:44:45 +0000 |
| commit | 9ecc9896dedb426e3f4eb3d23dfc60192fe5275f (patch) | |
| tree | fd8c0fefebe5f85a5d400487383c4c9567353268 | |
| parent | 750f2c63f2737305d33288303cdecb7a470a7922 (diff) | |
| parent | c70458ba5dc19dde84d5cf54265e5d100abf5784 (diff) | |
| download | rust-9ecc9896dedb426e3f4eb3d23dfc60192fe5275f.tar.gz rust-9ecc9896dedb426e3f4eb3d23dfc60192fe5275f.zip | |
Auto merge of #25281 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #24948, #25158, #25188, #25222, #25239, #25240, #25241, #25255, #25257, #25263 - Failed merges:
| -rw-r--r-- | src/doc/trpl/guessing-game.md | 4 | ||||
| -rw-r--r-- | src/doc/trpl/match.md | 2 | ||||
| -rw-r--r-- | src/doc/trpl/mutability.md | 4 | ||||
| -rw-r--r-- | src/doc/trpl/ownership.md | 2 | ||||
| -rw-r--r-- | src/doc/trpl/primitive-types.md | 2 | ||||
| -rw-r--r-- | src/doc/trpl/references-and-borrowing.md | 35 | ||||
| -rw-r--r-- | src/etc/CONFIGS.md | 8 | ||||
| -rw-r--r-- | src/libcollections/string.rs | 1 | ||||
| -rw-r--r-- | src/libcore/convert.rs | 1 | ||||
| -rw-r--r-- | src/librustc_typeck/diagnostics.rs | 34 | ||||
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 18 |
11 files changed, 100 insertions, 11 deletions
diff --git a/src/doc/trpl/guessing-game.md b/src/doc/trpl/guessing-game.md index 50767b603c4..12dd087f20c 100644 --- a/src/doc/trpl/guessing-game.md +++ b/src/doc/trpl/guessing-game.md @@ -713,7 +713,7 @@ variety of numbers, we need to give Rust a hint as to the exact type of number we want. Hence, `let guess: u32`. The colon (`:`) after `guess` tells Rust we’re going to annotate its type. `u32` is an unsigned, thirty-two bit integer. Rust has [a number of built-in number types][number], but we’ve -chosen `u32`. It’s a good default choice for a small positive numer. +chosen `u32`. It’s a good default choice for a small positive number. [parse]: ../std/primitive.str.html#method.parse [number]: primitive-types.html#numeric-types @@ -922,7 +922,7 @@ failure. Each contains more information: the successful parsed integer, or an error type. In this case, we `match` on `Ok(num)`, which sets the inner value of the `Ok` to the name `num`, and then we just return it on the right-hand side. In the `Err` case, we don’t care what kind of error it is, so we just -use `_` intead of a name. This ignores the error, and `continue` causes us +use `_` instead of a name. This ignores the error, and `continue` causes us to go to the next iteration of the `loop`. Now we should be good! Let’s try: diff --git a/src/doc/trpl/match.md b/src/doc/trpl/match.md index 2c0c8ea73c0..86b94453389 100644 --- a/src/doc/trpl/match.md +++ b/src/doc/trpl/match.md @@ -50,7 +50,7 @@ side of a `let` binding or directly where an expression is used: ```rust let x = 5; -let numer = match x { +let number = match x { 1 => "one", 2 => "two", 3 => "three", diff --git a/src/doc/trpl/mutability.md b/src/doc/trpl/mutability.md index 435407a8a96..9b386acdca2 100644 --- a/src/doc/trpl/mutability.md +++ b/src/doc/trpl/mutability.md @@ -78,8 +78,8 @@ When we call `clone()`, the `Arc<T>` needs to update the reference count. Yet we’ve not used any `mut`s here, `x` is an immutable binding, and we didn’t take `&mut 5` or anything. So what gives? -To this, we have to go back to the core of Rust’s guiding philosophy, memory -safety, and the mechanism by which Rust guarantees it, the +To understand this, we have to go back to the core of Rust’s guiding +philosophy, memory safety, and the mechanism by which Rust guarantees it, the [ownership][ownership] system, and more specifically, [borrowing][borrowing]: > You may have one or the other of these two kinds of borrows, but not both at diff --git a/src/doc/trpl/ownership.md b/src/doc/trpl/ownership.md index fba5226ca2e..971bb7cd700 100644 --- a/src/doc/trpl/ownership.md +++ b/src/doc/trpl/ownership.md @@ -174,7 +174,7 @@ fn foo(v: Vec<i32>) -> Vec<i32> { } ``` -This would get very tedius. It gets worse the more things we want to take ownership of: +This would get very tedious. It gets worse the more things we want to take ownership of: ```rust fn foo(v1: Vec<i32>, v2: Vec<i32>) -> (Vec<i32>, Vec<i32>, i32) { diff --git a/src/doc/trpl/primitive-types.md b/src/doc/trpl/primitive-types.md index e017e222c74..bb2bf028700 100644 --- a/src/doc/trpl/primitive-types.md +++ b/src/doc/trpl/primitive-types.md @@ -176,7 +176,7 @@ Slices have type `&[T]`. We’ll talk about that `T` when we cover [generics]: generics.html -You can find more documentation for `slices`s [in the standard library +You can find more documentation for slices [in the standard library documentation][slice]. [slice]: ../std/primitive.slice.html diff --git a/src/doc/trpl/references-and-borrowing.md b/src/doc/trpl/references-and-borrowing.md index 8bb3f94760b..da416e994c4 100644 --- a/src/doc/trpl/references-and-borrowing.md +++ b/src/doc/trpl/references-and-borrowing.md @@ -312,6 +312,7 @@ println!("{}", y); We get this error: +```text error: `x` does not live long enough y = &x; ^ @@ -334,3 +335,37 @@ In other words, `y` is only valid for the scope where `x` exists. As soon as `x` goes away, it becomes invalid to refer to it. As such, the error says that the borrow ‘doesn’t live long enough’ because it’s not valid for the right amount of time. + +The same problem occurs when the reference is declared _before_ the variable it refers to: + +```rust,ignore +let y: &i32; +let x = 5; +y = &x; + +println!("{}", y); +``` + +We get this error: + +```text +error: `x` does not live long enough +y = &x; + ^ +note: reference must be valid for the block suffix following statement 0 at +2:16... + let y: &i32; + let x = 5; + y = &x; + + println!("{}", y); +} + +note: ...but borrowed value is only valid for the block suffix following +statement 1 at 3:14 + let x = 5; + y = &x; + + println!("{}", y); +} +``` \ No newline at end of file diff --git a/src/etc/CONFIGS.md b/src/etc/CONFIGS.md index 036a2f7d436..74837a06fae 100644 --- a/src/etc/CONFIGS.md +++ b/src/etc/CONFIGS.md @@ -1,6 +1,8 @@ # Configs -Here are some links to repos with configs which ease the use of rust: +These are some links to repos with configs which ease the use of rust. + +## Officially Maintained Configs * [rust.vim](https://github.com/rust-lang/rust.vim) * [emacs rust-mode](https://github.com/rust-lang/rust-mode) @@ -8,3 +10,7 @@ Here are some links to repos with configs which ease the use of rust: * [kate-config](https://github.com/rust-lang/kate-config) * [nano-config](https://github.com/rust-lang/nano-config) * [zsh-config](https://github.com/rust-lang/zsh-config) + +## Community-maintained Configs + +* [.editorconfig](https://gist.github.com/derhuerst/c9d1b9309e308d9851fa) ([what is this?](http://editorconfig.org/)) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 52d72501b4a..28e47674291 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -1052,6 +1052,7 @@ impl<T: fmt::Display + ?Sized> ToString for T { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef<str> for String { + #[inline] fn as_ref(&self) -> &str { self } diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index d3de77a9241..da6ac6bd752 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -173,6 +173,7 @@ impl<T> AsMut<[T]> for [T] { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef<str> for str { + #[inline] fn as_ref(&self) -> &str { self } diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 0e6386618f1..026ba3d08b4 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -46,6 +46,23 @@ enum variant, one of the fields was not provided. Each field should be specified exactly once. "##, +E0067: r##" +The left-hand side of an assignment operator must be an lvalue expression. An +lvalue expression represents a memory location and includes item paths (ie, +namespaced variables), dereferences, indexing expressions, and field references. + +``` +use std::collections::LinkedList; + +// Good +let mut list = LinkedList::new(); + + +// Bad: assignment to non-lvalue expression +LinkedList::new() += 1; +``` +"##, + E0081: r##" Enum discriminants are used to differentiate enum variants stored in memory. This error indicates that the same value was used for two or more variants, @@ -119,6 +136,20 @@ construct an instance of the following type using only safe code: ``` enum Empty {} ``` +"##, + +E0131: r##" +It is not possible to define `main` with type parameters, or even with function +parameters. When `main` is present, it must take no arguments and return `()`. +"##, + +E0132: r##" +It is not possible to declare type parameters on a function that has the `start` +attribute. Such a function must have the following type signature: + +``` +fn(isize, *const *const u8) -> isize +``` "## } @@ -149,7 +180,6 @@ register_diagnostics! { E0060, E0061, E0066, - E0067, E0068, E0069, E0070, @@ -189,8 +219,6 @@ register_diagnostics! { E0128, E0129, E0130, - E0131, - E0132, E0141, E0159, E0163, diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 9b824f11b92..48f65a5abfd 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -916,6 +916,24 @@ impl<K, V, S> HashMap<K, V, S> } /// Gets the given key's corresponding entry in the map for in-place manipulation. + /// + /// # Examples + /// + /// ``` + /// use std::collections::HashMap; + /// + /// let mut letters = HashMap::new(); + /// + /// for ch in "a short treatise on fungi".chars() { + /// let counter = letters.entry(ch).or_insert(0); + /// *counter += 1; + /// } + /// + /// assert_eq!(letters[&'s'], 2); + /// assert_eq!(letters[&'t'], 3); + /// assert_eq!(letters[&'u'], 1); + /// assert_eq!(letters.get(&'y'), None); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn entry(&mut self, key: K) -> Entry<K, V> { // Gotta resize now. |
