Skip to content

Commit a48fe92

Browse files
committed
---
yaml --- r: 207285 b: refs/heads/master c: 1e53218 h: refs/heads/master i: 207283: 668763c v: v3
1 parent 1fe6e01 commit a48fe92

File tree

27 files changed

+399
-193
lines changed

27 files changed

+399
-193
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 99868f6ba8c3afb56a92e144fe17bdbe018fa8ec
2+
refs/heads/master: 1e532189026671e883b5183ecc64671cf5c5af18
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 857ef6e272e5634cb9f3e6ee50eb6bc2a2e71651
55
refs/heads/try: 7b4ef47b7805a402d756fb8157101f64880a522f

trunk/src/doc/trpl/borrow-and-asref.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ This is because the standard library has `impl Borrow<str> for String`.
4747

4848
For most types, when you want to take an owned or borrowed type, a `&T` is
4949
enough. But one area where `Borrow` is effective is when there’s more than one
50-
kind of borrowed value. Slices are an area where this is especially true: you
51-
can have both an `&[T]` or a `&mut [T]`. If we wanted to accept both of these
52-
types, `Borrow` is up for it:
50+
kind of borrowed value. This is especially true of references and slices: you
51+
can have both an `&T` or a `&mut T`. If we wanted to accept both of these types,
52+
`Borrow` is up for it:
5353

5454
```
5555
use std::borrow::Borrow;

trunk/src/doc/trpl/closures.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ The second is that the syntax is similar, but a bit different. I’ve added spac
5454
here to make them look a little closer:
5555

5656
```rust
57-
fn plus_one_v1 (x: i32 ) -> i32 { x + 1 }
58-
let plus_one_v2 = |x: i32 | -> i32 { x + 1 };
59-
let plus_one_v3 = |x: i32 | x + 1 ;
57+
fn plus_one_v1 (x: i32) -> i32 { x + 1 }
58+
let plus_one_v2 = |x: i32| -> i32 { x + 1 };
59+
let plus_one_v3 = |x: i32| x + 1 ;
6060
```
6161

6262
Small differences, but they’re similar in ways.
@@ -136,7 +136,7 @@ This gives us:
136136
note: `nums` moved into closure environment here because it has type
137137
`[closure(()) -> collections::vec::Vec<i32>]`, which is non-copyable
138138
let takes_nums = || nums;
139-
^~~~~~~
139+
^~~~~~~
140140
```
141141

142142
`Vec<T>` has ownership over its contents, and therefore, when we refer to it
@@ -352,8 +352,8 @@ error: the trait `core::marker::Sized` is not implemented for the type
352352
factory() -> (Fn(i32) -> Vec<i32>) {
353353
^~~~~~~~~~~~~~~~~~~~~
354354
note: `core::ops::Fn(i32) -> collections::vec::Vec<i32>` does not have a constant size known at compile-time
355-
fa ctory() -> (Fn(i32) -> Vec<i32>) {
356-
^~~~~~~~~~~~~~~~~~~~~
355+
factory() -> (Fn(i32) -> Vec<i32>) {
356+
^~~~~~~~~~~~~~~~~~~~~
357357
358358
```
359359

trunk/src/doc/trpl/references-and-borrowing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ We can’t modify `v` because it’s borrowed by the loop.
297297
References must live as long as the resource they refer to. Rust will check the
298298
scopes of your references to ensure that this is true.
299299

300-
If Rust didn’t check that this property, we could accidentally use a reference
300+
If Rust didn’t check this property, we could accidentally use a reference
301301
which was invalid. For example:
302302

303303
```rust,ignore

trunk/src/doc/trpl/traits.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,17 @@ won’t have its methods:
183183

184184
```rust,ignore
185185
let mut f = std::fs::File::open("foo.txt").ok().expect("Couldn’t open foo.txt");
186-
let result = f.write("whatever".as_bytes());
186+
let buf = b"whatever"; // byte string literal. buf: &[u8; 8]
187+
let result = f.write(buf);
187188
# result.unwrap(); // ignore the error
188189
```
189190

190191
Here’s the error:
191192

192193
```text
193194
error: type `std::fs::File` does not implement any method in scope named `write`
194-
195-
let result = f.write(b"whatever");
196-
^~~~~~~~~~~~~~~~~~
195+
let result = f.write(buf);
196+
^~~~~~~~~~
197197
```
198198

199199
We need to `use` the `Write` trait first:
@@ -202,7 +202,8 @@ We need to `use` the `Write` trait first:
202202
use std::io::Write;
203203
204204
let mut f = std::fs::File::open("foo.txt").ok().expect("Couldn’t open foo.txt");
205-
let result = f.write("whatever".as_bytes());
205+
let buf = b"whatever";
206+
let result = f.write(buf);
206207
# result.unwrap(); // ignore the error
207208
```
208209

trunk/src/grammar/lexer.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ r/# {
311311
<str>\x22 { BEGIN(suffix); return LIT_STR; }
312312

313313
<str><<EOF>> { return -1; }
314-
<str>\\[n\nrt\\\x27\x220] { yymore(); }
314+
<str>\\[n\nr\rt\\\x27\x220] { yymore(); }
315315
<str>\\x[0-9a-fA-F]{2} { yymore(); }
316316
<str>\\u\{[0-9a-fA-F]?{6}\} { yymore(); }
317317
<str>\\[^n\nrt\\\x27\x220] { return -1; }

trunk/src/grammar/parser-lalr.y

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,16 @@ item_const
289289
;
290290

291291
item_macro
292-
: path_expr '!' maybe_ident parens_delimited_token_trees ';'
293-
| path_expr '!' maybe_ident braces_delimited_token_trees
294-
| path_expr '!' maybe_ident brackets_delimited_token_trees ';'
292+
: path_expr '!' maybe_ident parens_delimited_token_trees ';' { $$ = mk_node("ItemMacro", 3, $1, $3, $4); }
293+
| path_expr '!' maybe_ident braces_delimited_token_trees { $$ = mk_node("ItemMacro", 3, $1, $3, $4); }
294+
| path_expr '!' maybe_ident brackets_delimited_token_trees ';'{ $$ = mk_node("ItemMacro", 3, $1, $3, $4); }
295295
;
296296

297297
view_item
298298
: use_item
299299
| extern_fn_item
300300
| EXTERN CRATE ident ';' { $$ = mk_node("ViewItemExternCrate", 1, $3); }
301-
| EXTERN CRATE str AS ident ';' { $$ = mk_node("ViewItemExternCrate", 2, $3, $5); }
301+
| EXTERN CRATE ident AS ident ';' { $$ = mk_node("ViewItemExternCrate", 2, $3, $5); }
302302
;
303303

304304
extern_fn_item
@@ -312,8 +312,11 @@ use_item
312312
view_path
313313
: path_no_types_allowed { $$ = mk_node("ViewPathSimple", 1, $1); }
314314
| path_no_types_allowed MOD_SEP '{' '}' { $$ = mk_node("ViewPathList", 2, $1, mk_atom("ViewPathListEmpty")); }
315+
| MOD_SEP '{' '}' { $$ = mk_node("ViewPathList", 1, mk_atom("ViewPathListEmpty")); }
315316
| path_no_types_allowed MOD_SEP '{' idents_or_self '}' { $$ = mk_node("ViewPathList", 2, $1, $4); }
317+
| MOD_SEP '{' idents_or_self '}' { $$ = mk_node("ViewPathList", 1, $3); }
316318
| path_no_types_allowed MOD_SEP '{' idents_or_self ',' '}' { $$ = mk_node("ViewPathList", 2, $1, $4); }
319+
| MOD_SEP '{' idents_or_self ',' '}' { $$ = mk_node("ViewPathList", 1, $3); }
317320
| path_no_types_allowed MOD_SEP '*' { $$ = mk_node("ViewPathGlob", 1, $1); }
318321
| '{' '}' { $$ = mk_atom("ViewPathListEmpty"); }
319322
| '{' idents_or_self '}' { $$ = mk_node("ViewPathList", 1, $2); }
@@ -333,7 +336,7 @@ block_item
333336
;
334337

335338
maybe_ty_ascription
336-
: ':' ty { $$ = $2; }
339+
: ':' ty_sum { $$ = $2; }
337340
| %empty { $$ = mk_none(); }
338341
;
339342

@@ -511,7 +514,7 @@ trait_item
511514
;
512515

513516
trait_const
514-
: maybe_outer_attrs CONST ident maybe_const_default ';' { $$ = mk_node("ConstTraitItem", 3, $1, $3, $4); }
517+
: maybe_outer_attrs CONST ident maybe_ty_ascription maybe_const_default ';' { $$ = mk_node("ConstTraitItem", 4, $1, $3, $4, $5); }
515518
;
516519

517520
maybe_const_default
@@ -590,11 +593,11 @@ item_impl
590593
{
591594
$$ = mk_node("ItemImpl", 6, $1, $3, 5, $6, $9, $10);
592595
}
593-
| maybe_unsafe IMPL generic_params trait_ref FOR ty maybe_where_clause '{' maybe_inner_attrs maybe_impl_items '}'
596+
| maybe_unsafe IMPL generic_params trait_ref FOR ty_sum maybe_where_clause '{' maybe_inner_attrs maybe_impl_items '}'
594597
{
595598
$$ = mk_node("ItemImpl", 6, $3, $4, $6, $7, $9, $10);
596599
}
597-
| maybe_unsafe IMPL generic_params '!' trait_ref FOR ty maybe_where_clause '{' maybe_inner_attrs maybe_impl_items '}'
600+
| maybe_unsafe IMPL generic_params '!' trait_ref FOR ty_sum maybe_where_clause '{' maybe_inner_attrs maybe_impl_items '}'
598601
{
599602
$$ = mk_node("ItemImplNeg", 7, $1, $3, $5, $7, $8, $10, $11);
600603
}
@@ -620,7 +623,7 @@ impl_items
620623

621624
impl_item
622625
: impl_method
623-
| item_macro
626+
| attrs_and_vis item_macro { $$ = mk_node("ImplMacroItem", 2, $1, $2); }
624627
| impl_const
625628
| impl_type
626629
;
@@ -698,7 +701,7 @@ params
698701
;
699702

700703
param
701-
: pat ':' ty { $$ = mk_node("Arg", 2, $1, $3); }
704+
: pat ':' ty_sum { $$ = mk_node("Arg", 2, $1, $3); }
702705
;
703706

704707
inferrable_params
@@ -909,6 +912,11 @@ pat
909912
| ident '@' pat { $$ = mk_node("PatIdent", 3, mk_node("BindByValue", 1, mk_atom("MutImmutable")), $1, $3); }
910913
| binding_mode ident '@' pat { $$ = mk_node("PatIdent", 3, $1, $2, $4); }
911914
| BOX pat { $$ = mk_node("PatUniq", 1, $2); }
915+
| '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident { $$ = mk_node("PatQualifiedPath", 3, $2, $3, $6); }
916+
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident
917+
{
918+
$$ = mk_node("PatQualifiedPath", 3, mk_node("PatQualifiedPath", 3, $2, $3, $6), $7, $10);
919+
}
912920
;
913921

914922
pats_or
@@ -981,11 +989,11 @@ pat_vec_elts
981989
ty
982990
: ty_prim
983991
| ty_closure
984-
| '<' ty_sum AS trait_ref '>' MOD_SEP ident { $$ = mk_node("TyQualifiedPath", 3, $2, $4, $7); }
985-
| SHL ty_sum AS trait_ref '>' MOD_SEP ident AS trait_ref '>' MOD_SEP ident { $$ = mk_node("TyQualifiedPath", 3, mk_node("TyQualifiedPath", 3, $2, $4, $7), $9, $12); }
986-
| '(' ty_sums ')' { $$ = mk_node("TyTup", 1, $2); }
987-
| '(' ty_sums ',' ')' { $$ = mk_node("TyTup", 1, $2); }
988-
| '(' ')' { $$ = mk_atom("TyNil"); }
992+
| '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident { $$ = mk_node("TyQualifiedPath", 3, $2, $3, $6); }
993+
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident { $$ = mk_node("TyQualifiedPath", 3, mk_node("TyQualifiedPath", 3, $2, $3, $6), $7, $10); }
994+
| '(' ty_sums ')' { $$ = mk_node("TyTup", 1, $2); }
995+
| '(' ty_sums ',' ')' { $$ = mk_node("TyTup", 1, $2); }
996+
| '(' ')' { $$ = mk_atom("TyNil"); }
989997
;
990998

991999
ty_prim
@@ -1551,11 +1559,7 @@ nonblock_prefix_expr
15511559
;
15521560

15531561
expr_qualified_path
1554-
: '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident
1555-
{
1556-
$$ = mk_node("ExprQualifiedPath", 3, $2, $3, $6);
1557-
}
1558-
| '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args
1562+
: '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_qpath_params
15591563
{
15601564
$$ = mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7);
15611565
}
@@ -1576,6 +1580,11 @@ expr_qualified_path
15761580
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7), $8, $11, $12);
15771581
}
15781582

1583+
maybe_qpath_params
1584+
: MOD_SEP generic_args { $$ = $2; }
1585+
| %empty { $$ = mk_none(); }
1586+
;
1587+
15791588
maybe_as_trait_ref
15801589
: AS trait_ref { $$ = $2; }
15811590
| %empty { $$ = mk_none(); }
@@ -1666,8 +1675,10 @@ block_expr
16661675

16671676
full_block_expr
16681677
: block_expr
1669-
| full_block_expr '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
1670-
| full_block_expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
1678+
| full_block_expr '.' path_generic_args_with_colons %prec IDENT { $$ = mk_node("ExprField", 2, $1, $3); }
1679+
| full_block_expr '.' path_generic_args_with_colons '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 3, $1, $3, $5); }
1680+
| full_block_expr '.' path_generic_args_with_colons '(' maybe_exprs ')' { $$ = mk_node("ExprCall", 3, $1, $3, $5); }
1681+
| full_block_expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
16711682
;
16721683

16731684
expr_match

trunk/src/grammar/verify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
111111
"LIT_BINARY_RAW" => token::Literal(token::BinaryRaw(Name(0), 0), None),
112112
"QUESTION" => token::Question,
113113
"SHEBANG" => token::Shebang(Name(0)),
114-
_ => panic!("Bad token str `{}`", val),
114+
_ => continue,
115115
};
116116

117117
res.insert(num.to_string(), tok);

0 commit comments

Comments
 (0)