]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #14043 : sanxiyn/rust/attr-reference, r=alexcrichton
authorbors <bors@rust-lang.org>
Fri, 9 May 2014 11:36:33 +0000 (04:36 -0700)
committerbors <bors@rust-lang.org>
Fri, 9 May 2014 11:36:33 +0000 (04:36 -0700)
Attribute grammar in reference manual allowed `#[foo, bar]`, which does not match parser behavior.

Also rename nonterminals to match parser code.

Fix #13825.

1  2 
src/doc/rust.md

diff --combined src/doc/rust.md
index e4c95538d3012199035ed6530b8f5f212b31539e,e15ce5c4f9364aa10bcf0596048c72fbf0042439..0e5af8626f8e8a24066e7c29c2695814f2fba274
@@@ -1741,10 -1741,10 +1741,10 @@@ import public items from their destinat
  ## Attributes
  
  ~~~~ {.notrust .ebnf .gram}
- attribute : '#' '!' ? '[' attr_list ']' ;
- attr_list : attr [ ',' attr_list ]* ;
- attr : ident [ '=' literal
             | '(' attr_list ')' ] ? ;
+ attribute : '#' '!' ? '[' meta_item ']' ;
+ meta_item : ident [ '=' literal
+                   | '(' meta_seq ')' ] ? ;
meta_seq : meta_item [ ',' meta_seq ]* ;
  ~~~~
  
  Static entities in Rust &mdash; crates, modules and items &mdash; may have _attributes_
@@@ -3598,18 -3598,18 +3598,18 @@@ and the cast expression in `main`
  Within the body of an item that has type parameter declarations, the names of its type parameters are types:
  
  ~~~~
 -fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> ~[B] {
 +fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> Vec<B> {
      if xs.len() == 0 {
 -       return ~[];
 +       return vec![];
      }
      let first: B = f(xs[0].clone());
 -    let rest: ~[B] = map(f, xs.slice(1, xs.len()));
 -    return ~[first] + rest;
 +    let rest: Vec<B> = map(f, xs.slice(1, xs.len()));
 +    return vec![first].append(rest.as_slice());
  }
  ~~~~
  
  Here, `first` has type `B`, referring to `map`'s `B` type parameter;
 -and `rest` has type `~[B]`, a vector type with element type `B`.
 +and `rest` has type `Vec<B>`, a vector type with element type `B`.
  
  ### Self types