Skip to content

Rollup of 4 pull requests #25285

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

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a4c1337
link to .editorconfig for Rust files
derhuerst Apr 29, 2015
6f3641d
distinction between official and community plugins
derhuerst Apr 29, 2015
4d1e48e
Typo in ownership.md
tincann May 7, 2015
ae1b2f4
Another typo
tincann May 7, 2015
96229e8
fixed ICE issue #25180
llogiq May 8, 2015
29daa29
formatting correction
llogiq May 8, 2015
1434715
crossed the i-s and dotted the t-s ;-) Also added a run-pass test and…
llogiq May 8, 2015
715f7c3
Add a precision for references
GuillaumeGomez May 8, 2015
7a91fe8
Fixed a typo. Removed an extra s
sindreij May 9, 2015
1e9ce0d
std: Add example for HashMap::entry()
May 9, 2015
7a2ac0c
Added start of last text block
sindreij May 9, 2015
ca5c694
Pulled walk_fn() into Var mode, extended test
llogiq May 10, 2015
f8888af
Add omitted word to mutability docs.
dpetersen May 10, 2015
ae1b64f
Fix typo in Match document.
dpetersen May 10, 2015
2cc4d82
Fix small typos in documentation
fhinkel May 10, 2015
8ad1c90
Removed the backticks on slices
sindreij May 10, 2015
6e19cfa
more tests
llogiq May 10, 2015
a18ce4d
fixed errors in test code
llogiq May 10, 2015
a168dba
Add #[inline] to AsRef<str>::as_ref for String and str.
koute May 10, 2015
5613502
Add long diagnostic for E0067
caipre May 10, 2015
ffc0d04
Add long diagnostic for E0131, E0132
caipre May 10, 2015
25543f3
Add missing backticks
GuillaumeGomez May 10, 2015
0c390d2
point supposed to be immutable in this example
polachok May 10, 2015
685f557
Update docs to stop referencing `BufReadExt`
frewsxcv May 10, 2015
371eb87
Rollup merge of #24948 - derhuerst:patch-1, r=steveklabnik
steveklabnik May 10, 2015
ad1c0c5
Rollup merge of #25158 - koute:master, r=alexcrichton
steveklabnik May 10, 2015
a725378
Rollup merge of #25188 - tincann:patch-1, r=steveklabnik
steveklabnik May 10, 2015
ba8eb58
Rollup merge of #25222 - GuillaumeGomez:doc-ref, r=steveklabnik
steveklabnik May 10, 2015
fa207fa
Rollup merge of #25239 - sindreij:patch-1, r=alexcrichton
steveklabnik May 10, 2015
dcc76da
Rollup merge of #25240 - bluss:doc-hashmap-entry, r=steveklabnik
steveklabnik May 10, 2015
d065d57
Rollup merge of #25241 - sindreij:patch-2, r=steveklabnik
steveklabnik May 10, 2015
5160bf8
Rollup merge of #25255 - caipre:diagnostic-messages, r=alexcrichton
steveklabnik May 10, 2015
7ae332c
Rollup merge of #25257 - dpetersen:mutability-docfix, r=steveklabnik
steveklabnik May 10, 2015
c70458b
Rollup merge of #25263 - fhinkel:master, r=steveklabnik
steveklabnik May 10, 2015
9ecc989
Auto merge of #25281 - steveklabnik:rollup, r=steveklabnik
bors May 10, 2015
82f76a3
Rollup merge of #25209 - llogiq:master, r=eddyb
steveklabnik May 10, 2015
21aa65f
Rollup merge of #25271 - tshepang:doc-deunwrap, r=steveklabnik
steveklabnik May 10, 2015
92f8ff2
Rollup merge of #25277 - polachok:docfix, r=steveklabnik
steveklabnik May 10, 2015
2266142
Rollup merge of #25280 - frewsxcv:patch-22, r=steveklabnik
steveklabnik May 10, 2015
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
4 changes: 2 additions & 2 deletions src/doc/trpl/guessing-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/match.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/doc/trpl/mutability.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -169,7 +169,7 @@ struct Point {
y: Cell<i32>,
}

let mut point = Point { x: 5, y: Cell::new(6) };
let point = Point { x: 5, y: Cell::new(6) };

point.y.set(7);

Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/ownership.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/primitive-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions src/doc/trpl/references-and-borrowing.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ println!("{}", y);

We get this error:

```text
error: `x` does not live long enough
y = &x;
^
Expand All @@ -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);
}
```
8 changes: 7 additions & 1 deletion src/etc/CONFIGS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# 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)
* [gedit-config](https://github.com/rust-lang/gedit-config)
* [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/))
1 change: 1 addition & 0 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/libcore/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 4 additions & 3 deletions src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,10 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
b: &'v ast::Block,
s: Span,
fn_id: ast::NodeId) {
assert!(self.mode == Mode::Var);
self.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, b));
visit::walk_fn(self, fk, fd, b, s);
self.with_mode(Mode::Var, |v| {
v.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, b));
visit::walk_fn(v, fk, fd, b, s);
})
}

fn visit_pat(&mut self, p: &ast::Pat) {
Expand Down
34 changes: 31 additions & 3 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
```
"##

}
Expand Down Expand Up @@ -149,7 +180,6 @@ register_diagnostics! {
E0060,
E0061,
E0066,
E0067,
E0068,
E0069,
E0070,
Expand Down Expand Up @@ -189,8 +219,6 @@ register_diagnostics! {
E0128,
E0129,
E0130,
E0131,
E0132,
E0141,
E0159,
E0163,
Expand Down
18 changes: 18 additions & 0 deletions src/libstd/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ impl fmt::Display for CharsError {
/// An iterator over the contents of an instance of `BufRead` split on a
/// particular byte.
///
/// See `BufReadExt::split` for more information.
/// See `BufRead::split` for more information.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Split<B> {
buf: B,
Expand Down Expand Up @@ -873,7 +873,7 @@ impl<B: BufRead> Iterator for Split<B> {
/// An iterator over the lines of an instance of `BufRead` split on a newline
/// byte.
///
/// See `BufReadExt::lines` for more information.
/// See `BufRead::lines` for more information.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Lines<B> {
buf: B,
Expand Down
30 changes: 30 additions & 0 deletions src/test/run-pass/issue-25180.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2015 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.

// pretty-expanded FIXME #25180

const EMPTY: &'static Fn() = &|| println!("ICE here");

const ONE_ARGUMENT: &'static Fn(u32) = &|y| println!("{}", y);

const PLUS_21: &'static (Fn(u32) -> u32) = &|y| y + 21;

const MULTI_AND_LOCAL: &'static (Fn(u32, u32) -> u32) = &|x, y| {
let tmp = x + y;
tmp * 2
};

pub fn main() {
EMPTY();
ONE_ARGUMENT(42);
assert!(PLUS_21(21) == 42);
assert!(MULTI_AND_LOCAL(1, 2) == 6);
}