Skip to content

Commit 84320a4

Browse files
committed
auto merge of #14277 : pczarn/rust/manual-grammar, r=alexcrichton
The grammar for use declarations was outdated. Corrected some other mistakes.
2 parents 6291955 + 6674913 commit 84320a4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/doc/rust.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -848,11 +848,11 @@ extern crate foo = "some/where/rust-foo#foo:1.0"; // a full crate ID for externa
848848
##### Use declarations
849849

850850
~~~~ {.notrust .ebnf .gram}
851-
use_decl : "pub" ? "use" ident [ '=' path
852-
| "::" path_glob ] ;
851+
use_decl : "pub" ? "use" [ ident '=' path
852+
| path_glob ] ;
853853
854-
path_glob : ident [ "::" path_glob ] ?
855-
| '*'
854+
path_glob : ident [ "::" [ path_glob
855+
| '*' ] ] ?
856856
| '{' ident [ ',' ident ] * '}' ;
857857
~~~~
858858

@@ -1743,7 +1743,7 @@ import public items from their destination, not private items.
17431743
attribute : '#' '!' ? '[' meta_item ']' ;
17441744
meta_item : ident [ '=' literal
17451745
| '(' meta_seq ')' ] ? ;
1746-
meta_seq : meta_item [ ',' meta_seq ]* ;
1746+
meta_seq : meta_item [ ',' meta_seq ] ? ;
17471747
~~~~
17481748

17491749
Static entities in Rust — crates, modules and items — may have _attributes_
@@ -3027,11 +3027,11 @@ then any `else` block is executed.
30273027
### Match expressions
30283028

30293029
~~~~ {.notrust .ebnf .gram}
3030-
match_expr : "match" expr '{' match_arm [ '|' match_arm ] * '}' ;
3030+
match_expr : "match" expr '{' match_arm * '}' ;
30313031
3032-
match_arm : match_pat "=>" [ expr "," | '{' block '}' ] ;
3032+
match_arm : attribute * match_pat "=>" [ expr "," | '{' block '}' ] ;
30333033
3034-
match_pat : pat [ ".." pat ] ? [ "if" expr ] ;
3034+
match_pat : pat [ '|' pat ] * [ "if" expr ] ? ;
30353035
~~~~
30363036

30373037
A `match` expression branches on a *pattern*. The exact form of matching that
@@ -3137,7 +3137,7 @@ using the `ref` keyword,
31373137
or to a mutable reference using `ref mut`.
31383138

31393139
Subpatterns can also be bound to variables by the use of the syntax
3140-
`variable @ pattern`.
3140+
`variable @ subpattern`.
31413141
For example:
31423142

31433143
~~~~

0 commit comments

Comments
 (0)