Skip to content

Commit

Permalink
Auto merge of #28220 - steveklabnik:rollup, r=steveklabnik
Browse files Browse the repository at this point in the history
- Successful merges: #28167, #28202, #28203, #28204, #28205, #28207, #28208, #28209, #28210, #28212, #28213, #28214, #28215, #28216
- Failed merges:
  • Loading branch information
bors committed Sep 4, 2015
2 parents 2727a8e + 6c9549d commit 35b1454
Show file tree
Hide file tree
Showing 31 changed files with 97 additions and 110 deletions.
19 changes: 8 additions & 11 deletions src/doc/grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ type_path_tail : '<' type_expr [ ',' type_expr ] + '>'
## Macros

```antlr
expr_macro_rules : "macro_rules" '!' ident '(' macro_rule * ')' ';'
expr_macro_rules : "macro_rules" '!' ident '(' macro_rule * ')' ';'
| "macro_rules" '!' ident '{' macro_rule * '}' ;
macro_rule : '(' matcher * ')' "=>" '(' transcriber * ')' ';' ;
matcher : '(' matcher * ')' | '[' matcher * ']'
Expand All @@ -306,7 +306,7 @@ transcriber : '(' transcriber * ')' | '[' transcriber * ']'

```antlr
item : vis ? mod_item | fn_item | type_item | struct_item | enum_item
| const_item | static_item | trait_item | impl_item | extern_block ;
| const_item | static_item | trait_item | impl_item | extern_block_item ;
```

### Type Parameters
Expand Down Expand Up @@ -636,31 +636,31 @@ lambda_expr : '|' ident_list '|' expr ;
### While loops

```antlr
while_expr : [ lifetime ':' ] "while" no_struct_literal_expr '{' block '}' ;
while_expr : [ lifetime ':' ] ? "while" no_struct_literal_expr '{' block '}' ;
```

### Infinite loops

```antlr
loop_expr : [ lifetime ':' ] "loop" '{' block '}';
loop_expr : [ lifetime ':' ] ? "loop" '{' block '}';
```

### Break expressions

```antlr
break_expr : "break" [ lifetime ];
break_expr : "break" [ lifetime ] ?;
```

### Continue expressions

```antlr
continue_expr : "continue" [ lifetime ];
continue_expr : "continue" [ lifetime ] ?;
```

### For expressions

```antlr
for_expr : [ lifetime ':' ] "for" pat "in" no_struct_literal_expr '{' block '}' ;
for_expr : [ lifetime ':' ] ? "for" pat "in" no_struct_literal_expr '{' block '}' ;
```

### If expressions
Expand Down Expand Up @@ -688,13 +688,12 @@ match_pat : pat [ '|' pat ] * [ "if" expr ] ? ;
```antlr
if_let_expr : "if" "let" pat '=' expr '{' block '}'
else_tail ? ;
else_tail : "else" [ if_expr | if_let_expr | '{' block '}' ] ;
```

### While let loops

```antlr
while_let_expr : "while" "let" pat '=' expr '{' block '}' ;
while_let_expr : [ lifetime ':' ] ? "while" "let" pat '=' expr '{' block '}' ;
```

### Return expressions
Expand Down Expand Up @@ -754,8 +753,6 @@ return_expr : "return" expr ? ;
```antlr
closure_type := [ 'unsafe' ] [ '<' lifetime-list '>' ] '|' arg-list '|'
[ ':' bound-list ] [ '->' type ]
procedure_type := 'proc' [ '<' lifetime-list '>' ] '(' arg-list ')'
[ ':' bound-list ] [ '->' type ]
lifetime-list := lifetime | lifetime ',' lifetime-list
arg-list := ident ':' type | ident ':' type ',' arg-list
bound-list := bound | bound '+' bound-list
Expand Down
10 changes: 0 additions & 10 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3200,16 +3200,6 @@ let z = match x { &0 => "zero", _ => "some" };
assert_eq!(y, z);
```

A pattern that's just an identifier, like `Nil` in the previous example, could
either refer to an enum variant that's in scope, or bind a new variable. The
compiler resolves this ambiguity by forbidding variable bindings that occur in
`match` patterns from shadowing names of variants that are in scope. For
example, wherever `List` is in scope, a `match` pattern would not be able to
bind `Nil` as a new name. The compiler interprets a variable pattern `x` as a
binding _only_ if there is no variant named `x` in scope. A convention you can
use to avoid conflicts is simply to name variants with upper-case letters, and
local variables with lower-case letters.

Multiple match patterns may be joined with the `|` operator. A range of values
may be specified with `...`. For example:

Expand Down
12 changes: 6 additions & 6 deletions src/doc/trpl/choosing-your-guarantees.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% Choosing your Guarantees

One important feature of Rust as language is that it lets us control the costs and guarantees
One important feature of Rust is that it lets us control the costs and guarantees
of a program.

There are various &ldquo;wrapper type&rdquo; abstractions in the Rust standard library which embody
Expand All @@ -18,9 +18,9 @@ Before proceeding, it is highly recommended that one reads about [ownership][own

## `Box<T>`

[`Box<T>`][box] is pointer which is &ldquo;owned&rdquo;, or a &ldquo;box&rdquo;. While it can hand
out references to the contained data, it is the only owner of the data. In particular, when
something like the following occurs:
[`Box<T>`][box] is an &ldquo;owned&rdquo; pointer, or a &ldquo;box&rdquo;. While it can hand
out references to the contained data, it is the only owner of the data. In particular, consider
the following:

```rust
let x = Box::new(1);
Expand All @@ -40,7 +40,7 @@ allowed to share references to this by the regular borrowing rules, checked at c

[box]: ../std/boxed/struct.Box.html

## `&T` and `&mut T`
## `&T` and `&mut T`

These are immutable and mutable references respectively. They follow the &ldquo;read-write lock&rdquo;
pattern, such that one may either have only one mutable reference to some data, or any number of
Expand Down Expand Up @@ -243,7 +243,7 @@ Many of the types above cannot be used in a threadsafe manner. Particularly, `Rc
`RefCell<T>`, which both use non-atomic reference counts (_atomic_ reference counts are those which
can be incremented from multiple threads without causing a data race), cannot be used this way. This
makes them cheaper to use, but we need thread safe versions of these too. They exist, in the form of
`Arc<T>` and `Mutex<T>`/`RWLock<T>`
`Arc<T>` and `Mutex<T>`/`RwLock<T>`

Note that the non-threadsafe types _cannot_ be sent between threads, and this is checked at compile
time.
Expand Down
10 changes: 5 additions & 5 deletions src/doc/trpl/deref-coercions.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ Vectors can `Deref` to a slice.

## Deref and method calls

`Deref` will also kick in when calling a method. In other words, these are
the same two things in Rust:
`Deref` will also kick in when calling a method. Consider the following
example.

```rust
struct Foo;
Expand All @@ -99,13 +99,13 @@ impl Foo {
fn foo(&self) { println!("Foo"); }
}

let f = Foo;
let f = &&Foo;

f.foo();
```

Even though `f` isn’t a reference, and `foo` takes `&self`, this works.
That’s because these things are the same:
Even though `f` is a `&&Foo` and `foo` takes `&self`, this works. That’s
because these things are the same:

```rust,ignore
f.foo();
Expand Down
4 changes: 2 additions & 2 deletions src/doc/trpl/the-stack-and-the-heap.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ local variables and some other information. This is called a ‘stack frame’,
for the purpose of this tutorial, we’re going to ignore the extra information
and just consider the local variables we’re allocating. So in this case, when
`main()` is run, we’ll allocate a single 32-bit integer for our stack frame.
This is automatically handled for you, as you can see, we didn’t have to write
This is automatically handled for you, as you can see; we didn’t have to write
any special Rust code or anything.

When the function is over, its stack frame gets deallocated. This happens
Expand All @@ -51,7 +51,7 @@ we’ll throw them all away at the same time as well, we can get rid of it very
fast too.

The downside is that we can’t keep values around if we need them for longer
than a single function. We also haven’t talked about what that name, ‘stack’
than a single function. We also haven’t talked about what the word, ‘stack’,
means. To do that, we need a slightly more complicated example:

```rust
Expand Down
8 changes: 4 additions & 4 deletions src/grammar/RustLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ tokens {
BINOPEQ, AT, DOT, DOTDOT, DOTDOTDOT, COMMA, SEMI, COLON,
MOD_SEP, RARROW, FAT_ARROW, LPAREN, RPAREN, LBRACKET, RBRACKET,
LBRACE, RBRACE, POUND, DOLLAR, UNDERSCORE, LIT_CHAR, LIT_BYTE,
LIT_INTEGER, LIT_FLOAT, LIT_STR, LIT_STR_RAW, LIT_BINARY,
LIT_BINARY_RAW, QUESTION, IDENT, LIFETIME, WHITESPACE, DOC_COMMENT,
LIT_INTEGER, LIT_FLOAT, LIT_STR, LIT_STR_RAW, LIT_BYTE_STR,
LIT_BYTE_STR_RAW, QUESTION, IDENT, LIFETIME, WHITESPACE, DOC_COMMENT,
COMMENT, SHEBANG, UTF8_BOM
}

Expand Down Expand Up @@ -148,8 +148,8 @@ LIT_STR
: '"' ('\\\n' | '\\\r\n' | '\\' CHAR_ESCAPE | .)*? '"' SUFFIX?
;

LIT_BINARY : 'b' LIT_STR ;
LIT_BINARY_RAW : 'b' LIT_STR_RAW ;
LIT_BYTE_STR : 'b' LIT_STR ;
LIT_BYTE_STR_RAW : 'b' LIT_STR_RAW ;

/* this is a bit messy */

Expand Down
8 changes: 4 additions & 4 deletions src/grammar/lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ while { return WHILE; }
<ltorchar><<EOF>> { BEGIN(INITIAL); return -1; }

b\x22 { BEGIN(bytestr); yymore(); }
<bytestr>\x22 { BEGIN(suffix); return LIT_BINARY; }
<bytestr>\x22 { BEGIN(suffix); return LIT_BYTE_STR; }

<bytestr><<EOF>> { return -1; }
<bytestr>\\[n\nrt\\\x27\x220] { yymore(); }
Expand All @@ -210,7 +210,7 @@ b\x22 { BEGIN(bytestr); yymore(); }
<bytestr>(.|\n) { yymore(); }

br\x22 { BEGIN(rawbytestr_nohash); yymore(); }
<rawbytestr_nohash>\x22 { BEGIN(suffix); return LIT_BINARY_RAW; }
<rawbytestr_nohash>\x22 { BEGIN(suffix); return LIT_BYTE_STR_RAW; }
<rawbytestr_nohash>(.|\n) { yymore(); }
<rawbytestr_nohash><<EOF>> { return -1; }

Expand All @@ -228,7 +228,7 @@ br/# {
end_hashes++;
if (end_hashes == num_hashes) {
BEGIN(INITIAL);
return LIT_BINARY_RAW;
return LIT_BYTE_STR_RAW;
}
}
yymore();
Expand All @@ -237,7 +237,7 @@ br/# {
end_hashes = 1;
if (end_hashes == num_hashes) {
BEGIN(INITIAL);
return LIT_BINARY_RAW;
return LIT_BYTE_STR_RAW;
}
yymore();
}
Expand Down
12 changes: 6 additions & 6 deletions src/grammar/parser-lalr.y
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ extern char *yytext;
%token LIT_FLOAT
%token LIT_STR
%token LIT_STR_RAW
%token LIT_BINARY
%token LIT_BINARY_RAW
%token LIT_BYTE_STR
%token LIT_BYTE_STR_RAW
%token IDENT
%token UNDERSCORE
%token LIFETIME
Expand Down Expand Up @@ -1772,8 +1772,8 @@ lit
str
: LIT_STR { $$ = mk_node("LitStr", 1, mk_atom(yytext), mk_atom("CookedStr")); }
| LIT_STR_RAW { $$ = mk_node("LitStr", 1, mk_atom(yytext), mk_atom("RawStr")); }
| LIT_BINARY { $$ = mk_node("LitBinary", 1, mk_atom(yytext), mk_atom("BinaryStr")); }
| LIT_BINARY_RAW { $$ = mk_node("LitBinary", 1, mk_atom(yytext), mk_atom("RawBinaryStr")); }
| LIT_BYTE_STR { $$ = mk_node("LitByteStr", 1, mk_atom(yytext), mk_atom("ByteStr")); }
| LIT_BYTE_STR_RAW { $$ = mk_node("LitByteStr", 1, mk_atom(yytext), mk_atom("RawByteStr")); }
;

maybe_ident
Expand Down Expand Up @@ -1815,8 +1815,8 @@ unpaired_token
| LIT_FLOAT { $$ = mk_atom(yytext); }
| LIT_STR { $$ = mk_atom(yytext); }
| LIT_STR_RAW { $$ = mk_atom(yytext); }
| LIT_BINARY { $$ = mk_atom(yytext); }
| LIT_BINARY_RAW { $$ = mk_atom(yytext); }
| LIT_BYTE_STR { $$ = mk_atom(yytext); }
| LIT_BYTE_STR_RAW { $$ = mk_atom(yytext); }
| IDENT { $$ = mk_atom(yytext); }
| UNDERSCORE { $$ = mk_atom(yytext); }
| LIFETIME { $$ = mk_atom(yytext); }
Expand Down
4 changes: 2 additions & 2 deletions src/grammar/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ enum Token {
LIT_FLOAT,
LIT_STR,
LIT_STR_RAW,
LIT_BINARY,
LIT_BINARY_RAW,
LIT_BYTE_STR,
LIT_BYTE_STR_RAW,
IDENT,
UNDERSCORE,
LIFETIME,
Expand Down
16 changes: 8 additions & 8 deletions src/grammar/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
"OR" => token::BinOp(token::Or),
"GT" => token::Gt,
"LE" => token::Le,
"LIT_BINARY" => token::Literal(token::Binary(Name(0)), None),
"LIT_BINARY_RAW" => token::Literal(token::BinaryRaw(Name(0), 0), None),
"LIT_BYTE_STR" => token::Literal(token::ByteStr(Name(0)), None),
"LIT_BYTE_STR_RAW" => token::Literal(token::ByteStrRaw(Name(0), 0), None),
"QUESTION" => token::Question,
"SHEBANG" => token::Shebang(Name(0)),
_ => continue,
Expand Down Expand Up @@ -137,8 +137,8 @@ fn str_to_binop(s: &str) -> token::BinOpToken {
}
}

/// Assuming a string/binary literal, strip out the leading/trailing
/// hashes and surrounding quotes/raw/binary prefix.
/// Assuming a string/byte string literal, strip out the leading/trailing
/// hashes and surrounding quotes/raw/byte prefix.
fn fix(mut lit: &str) -> ast::Name {
if lit.char_at(0) == 'r' {
if lit.char_at(1) == 'b' {
Expand Down Expand Up @@ -205,8 +205,8 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, token::Token>, surrogate_
token::DocComment(..) => token::DocComment(nm),
token::Literal(token::Integer(..), n) => token::Literal(token::Integer(nm), n),
token::Literal(token::Float(..), n) => token::Literal(token::Float(nm), n),
token::Literal(token::Binary(..), n) => token::Literal(token::Binary(nm), n),
token::Literal(token::BinaryRaw(..), n) => token::Literal(token::BinaryRaw(fix(content),
token::Literal(token::ByteStr(..), n) => token::Literal(token::ByteStr(nm), n),
token::Literal(token::ByteStrRaw(..), n) => token::Literal(token::ByteStrRaw(fix(content),
count(content)), n),
token::Ident(..) => token::Ident(ast::Ident { name: nm, ctxt: 0 },
token::ModName),
Expand Down Expand Up @@ -340,8 +340,8 @@ fn main() {
token::Literal(token::Float(..), _),
token::Literal(token::Str_(..), _),
token::Literal(token::StrRaw(..), _),
token::Literal(token::Binary(..), _),
token::Literal(token::BinaryRaw(..), _),
token::Literal(token::ByteStr(..), _),
token::Literal(token::ByteStrRaw(..), _),
token::Ident(..),
token::Lifetime(..),
token::Interpolated(..),
Expand Down
14 changes: 7 additions & 7 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
//! fn main() {
//! // Create a reference counted Owner.
//! let gadget_owner : Rc<Owner> = Rc::new(
//! Owner { name: String::from("Gadget Man") }
//! Owner { name: String::from("Gadget Man") }
//! );
//!
//! // Create Gadgets belonging to gadget_owner. To increment the reference
Expand Down Expand Up @@ -102,13 +102,13 @@
//!
//! struct Owner {
//! name: String,
//! gadgets: RefCell<Vec<Weak<Gadget>>>
//! gadgets: RefCell<Vec<Weak<Gadget>>>,
//! // ...other fields
//! }
//!
//! struct Gadget {
//! id: i32,
//! owner: Rc<Owner>
//! owner: Rc<Owner>,
//! // ...other fields
//! }
//!
Expand All @@ -117,10 +117,10 @@
//! // Owner's vector of Gadgets inside a RefCell so that we can mutate it
//! // through a shared reference.
//! let gadget_owner : Rc<Owner> = Rc::new(
//! Owner {
//! name: "Gadget Man".to_string(),
//! gadgets: RefCell::new(Vec::new())
//! }
//! Owner {
//! name: "Gadget Man".to_string(),
//! gadgets: RefCell::new(Vec::new()),
//! }
//! );
//!
//! // Create Gadgets belonging to gadget_owner as before.
Expand Down
Loading

0 comments on commit 35b1454

Please sign in to comment.