]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #13704 : edwardw/rust/doc-hidden, r=alexcrichton
authorbors <bors@rust-lang.org>
Thu, 24 Apr 2014 04:46:34 +0000 (21:46 -0700)
committerbors <bors@rust-lang.org>
Thu, 24 Apr 2014 04:46:34 +0000 (21:46 -0700)
Closes #13698

14 files changed:
1  2 
src/libsyntax/ext/deriving/clone.rs
src/libsyntax/ext/deriving/cmp/eq.rs
src/libsyntax/ext/deriving/cmp/ord.rs
src/libsyntax/ext/deriving/cmp/totaleq.rs
src/libsyntax/ext/deriving/cmp/totalord.rs
src/libsyntax/ext/deriving/decodable.rs
src/libsyntax/ext/deriving/default.rs
src/libsyntax/ext/deriving/encodable.rs
src/libsyntax/ext/deriving/generic.rs
src/libsyntax/ext/deriving/hash.rs
src/libsyntax/ext/deriving/primitive.rs
src/libsyntax/ext/deriving/rand.rs
src/libsyntax/ext/deriving/show.rs
src/libsyntax/ext/deriving/zero.rs

index e0b493cd8d9c0d4371e84dd50cca9223dfcb8258,6db9954820678d942475097346953f3eb0ce40d4..510241588228ce105ba5e86abda2d487220db2ce
@@@ -13,12 -13,15 +13,15 @@@ use codemap::Span
  use ext::base::ExtCtxt;
  use ext::build::AstBuilder;
  use ext::deriving::generic::*;
+ use parse::token::InternedString;
  
  pub fn expand_deriving_clone(cx: &mut ExtCtxt,
                               span: Span,
                               mitem: @MetaItem,
                               item: @Item,
                               push: |@Item|) {
+     let inline = cx.meta_word(span, InternedString::new("inline"));
+     let attrs = vec!(cx.attribute(span, inline));
      let trait_def = TraitDef {
          span: span,
          attributes: Vec::new(),
                  explicit_self: borrowed_explicit_self(),
                  args: Vec::new(),
                  ret_ty: Self,
-                 inline: true,
+                 attributes: attrs,
                  const_nonmatching: false,
 -                combine_substructure: |c, s, sub| cs_clone("Clone", c, s, sub)
 +                combine_substructure: combine_substructure(|c, s, sub| {
 +                    cs_clone("Clone", c, s, sub)
 +                }),
              }
          )
      };
index 35b7e7c1a666e772cb9f249b107579a8911eabca,8a877a2a7a4a35b081836018e5aace6baa9867cb..92b3788c247443c53791a8eecbb6e8480ac52d09
@@@ -13,6 -13,7 +13,7 @@@ use codemap::Span
  use ext::base::ExtCtxt;
  use ext::build::AstBuilder;
  use ext::deriving::generic::*;
+ use parse::token::InternedString;
  
  pub fn expand_deriving_eq(cx: &mut ExtCtxt,
                            span: Span,
      }
  
      macro_rules! md (
-         ($name:expr, $f:ident) => {
+         ($name:expr, $f:ident) => { {
+             let inline = cx.meta_word(span, InternedString::new("inline"));
+             let attrs = vec!(cx.attribute(span, inline));
              MethodDef {
                  name: $name,
                  generics: LifetimeBounds::empty(),
                  explicit_self: borrowed_explicit_self(),
                  args: vec!(borrowed_self()),
                  ret_ty: Literal(Path::new(vec!("bool"))),
-                 inline: true,
+                 attributes: attrs,
                  const_nonmatching: true,
 -                combine_substructure: $f
 +                combine_substructure: combine_substructure(|a, b, c| {
 +                    $f(a, b, c)
 +                })
              }
-         }
+         } }
      );
  
      let trait_def = TraitDef {
index afe2d3dae6a71e63a0b4c3cee718e2bec920dea9,2b2a490e5a403932f493f1ec4049cb94c20276e6..dd2f90cfa5fae9ac21880ad8a78513c6567d063d
@@@ -14,6 -14,7 +14,7 @@@ use codemap::Span
  use ext::base::ExtCtxt;
  use ext::build::AstBuilder;
  use ext::deriving::generic::*;
+ use parse::token::InternedString;
  
  pub fn expand_deriving_ord(cx: &mut ExtCtxt,
                             span: Span,
                             item: @Item,
                             push: |@Item|) {
      macro_rules! md (
-         ($name:expr, $op:expr, $equal:expr) => {
+         ($name:expr, $op:expr, $equal:expr) => { {
+             let inline = cx.meta_word(span, InternedString::new("inline"));
+             let attrs = vec!(cx.attribute(span, inline));
              MethodDef {
                  name: $name,
                  generics: LifetimeBounds::empty(),
                  explicit_self: borrowed_explicit_self(),
                  args: vec!(borrowed_self()),
                  ret_ty: Literal(Path::new(vec!("bool"))),
-                 inline: true,
+                 attributes: attrs,
                  const_nonmatching: false,
 -                combine_substructure: |cx, span, substr| cs_op($op, $equal, cx, span, substr)
 +                combine_substructure: combine_substructure(|cx, span, substr| {
 +                    cs_op($op, $equal, cx, span, substr)
 +                })
              }
-         }
+         } }
      );
  
      let trait_def = TraitDef {
index d161f9668505fcccd0d0df6563d91492f06492fa,24e0fc73f2a3d1234e322a2c116013725d9ab1a1..b76caccffecc6095b168fcd4474987124f94bc51
@@@ -13,6 -13,7 +13,7 @@@ use codemap::Span
  use ext::base::ExtCtxt;
  use ext::build::AstBuilder;
  use ext::deriving::generic::*;
+ use parse::token::InternedString;
  
  pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
                                 span: Span,
                         substr)
      }
  
+     let inline = cx.meta_word(span, InternedString::new("inline"));
+     let hidden = cx.meta_word(span, InternedString::new("hidden"));
+     let doc = cx.meta_list(span, InternedString::new("doc"), vec!(hidden));
+     let attrs = vec!(cx.attribute(span, inline),
+                      cx.attribute(span, doc));
      let trait_def = TraitDef {
          span: span,
          attributes: Vec::new(),
                  explicit_self: borrowed_explicit_self(),
                  args: vec!(),
                  ret_ty: nil_ty(),
-                 inline: true,
+                 attributes: attrs,
                  const_nonmatching: true,
 -                combine_substructure: cs_total_eq_assert
 +                combine_substructure: combine_substructure(|a, b, c| {
 +                    cs_total_eq_assert(a, b, c)
 +                })
              }
          )
      };
index 69c413890e902fa3cf449ab3132d7d6d024fffeb,c2e52f7ef7701a8a054112aab68e2c51448b2718..3ca4f9e28626380da776cee61b04e8c3a0d70cf3
@@@ -14,6 -14,7 +14,7 @@@ use codemap::Span
  use ext::base::ExtCtxt;
  use ext::build::AstBuilder;
  use ext::deriving::generic::*;
+ use parse::token::InternedString;
  
  use std::cmp::{Ordering, Equal, Less, Greater};
  
@@@ -22,6 -23,8 +23,8 @@@ pub fn expand_deriving_totalord(cx: &mu
                                  mitem: @MetaItem,
                                  item: @Item,
                                  push: |@Item|) {
+     let inline = cx.meta_word(span, InternedString::new("inline"));
+     let attrs = vec!(cx.attribute(span, inline));
      let trait_def = TraitDef {
          span: span,
          attributes: Vec::new(),
                  explicit_self: borrowed_explicit_self(),
                  args: vec!(borrowed_self()),
                  ret_ty: Literal(Path::new(vec!("std", "cmp", "Ordering"))),
-                 inline: true,
+                 attributes: attrs,
                  const_nonmatching: false,
 -                combine_substructure: cs_cmp
 +                combine_substructure: combine_substructure(|a, b, c| {
 +                    cs_cmp(a, b, c)
 +                }),
              }
          )
      };
index 6d6cdc55d4028825eeff1d001cacb9fb65290576,56fde41635f18befd0c29587f03121448900dd5d..062f198425b28d0ab7289608e18c26c5063e13ef
@@@ -50,11 -50,9 +50,11 @@@ pub fn expand_deriving_decodable(cx: &m
                              Borrowed(None, MutMutable))),
                  ret_ty: Literal(Path::new_(vec!("std", "result", "Result"), None,
                                            vec!(~Self, ~Literal(Path::new_local("__E"))), true)),
-                 inline: false,
+                 attributes: Vec::new(),
                  const_nonmatching: true,
 -                combine_substructure: decodable_substructure,
 +                combine_substructure: combine_substructure(|a, b, c| {
 +                    decodable_substructure(a, b, c)
 +                }),
              })
      };
  
index 633674eff5c18438e010c723dca5d10803a1c83a,e89e25dd26c8337eeb0d7b62688bcd0c9d34b60b..c225906ed2babafcf00398b5b991b8423cd1fcfc
@@@ -13,12 -13,15 +13,15 @@@ use codemap::Span
  use ext::base::ExtCtxt;
  use ext::build::AstBuilder;
  use ext::deriving::generic::*;
+ use parse::token::InternedString;
  
  pub fn expand_deriving_default(cx: &mut ExtCtxt,
                              span: Span,
                              mitem: @MetaItem,
                              item: @Item,
                              push: |@Item|) {
+     let inline = cx.meta_word(span, InternedString::new("inline"));
+     let attrs = vec!(cx.attribute(span, inline));
      let trait_def = TraitDef {
          span: span,
          attributes: Vec::new(),
                  explicit_self: None,
                  args: Vec::new(),
                  ret_ty: Self,
-                 inline: true,
+                 attributes: attrs,
                  const_nonmatching: false,
 -                combine_substructure: default_substructure
 +                combine_substructure: combine_substructure(|a, b, c| {
 +                    default_substructure(a, b, c)
 +                })
              })
      };
      trait_def.expand(cx, mitem, item, push)
index acdef8c864509e47851416f1b5a648fb8703edeb,8fdb994ecdd80ba2142e8cf062abc35395565fe6..ec3d4e0078bc6c5c0037088705bff066048a5c97
@@@ -121,11 -121,9 +121,11 @@@ pub fn expand_deriving_encodable(cx: &m
                                             vec!(~Tuple(Vec::new()),
                                                  ~Literal(Path::new_local("__E"))),
                                             true)),
-                 inline: false,
+                 attributes: Vec::new(),
                  const_nonmatching: true,
 -                combine_substructure: encodable_substructure,
 +                combine_substructure: combine_substructure(|a, b, c| {
 +                    encodable_substructure(a, b, c)
 +                }),
              })
      };
  
index 673745b41e865ec36219401b9dbbff193a12c572,f5bc3319da163391ef758d4fc8ba2b07793df7e0..2b48cd58f50831b1b91a03c2489c9b514c0c4bb1
@@@ -177,8 -177,6 +177,8 @@@ StaticEnum(<ast::EnumDef of C>, ~[(<ide
  
  */
  
 +use std::cell::RefCell;
 +
  use ast;
  use ast::{P, EnumDef, Expr, Ident, Generics, StructDef};
  use ast_util;
@@@ -229,14 -227,13 +229,13 @@@ pub struct MethodDef<'a> 
      /// Return type
      pub ret_ty: Ty<'a>,
  
-     /// Whether to mark this as #[inline]
-     pub inline: bool,
+     pub attributes: Vec<ast::Attribute>,
  
      /// if the value of the nonmatching enums is independent of the
      /// actual enum variants, i.e. can use _ => .. match.
      pub const_nonmatching: bool,
  
 -    pub combine_substructure: CombineSubstructureFunc<'a>,
 +    pub combine_substructure: RefCell<CombineSubstructureFunc<'a>>,
  }
  
  /// All the data about the data structure/method being derived upon.
@@@ -319,11 -316,6 +318,11 @@@ pub type EnumNonMatchFunc<'a> 
             &[@Expr]|: 'a
             -> @Expr;
  
 +pub fn combine_substructure<'a>(f: CombineSubstructureFunc<'a>)
 +    -> RefCell<CombineSubstructureFunc<'a>> {
 +    RefCell::new(f)
 +}
 +
  
  impl<'a> TraitDef<'a> {
      pub fn expand(&self,
@@@ -516,9 -508,8 +515,9 @@@ impl<'a> MethodDef<'a> 
              nonself_args: nonself_args,
              fields: fields
          };
 -        (self.combine_substructure)(cx, trait_.span,
 -                                    &substructure)
 +        let mut f = self.combine_substructure.borrow_mut();
 +        let f: &mut CombineSubstructureFunc = &mut *f;
 +        (*f)(cx, trait_.span, &substructure)
      }
  
      fn get_ret_ty(&self,
          let fn_decl = cx.fn_decl(args, ret_type);
          let body_block = cx.block_expr(body);
  
-         let attrs = if self.inline {
-             vec!(
-                 cx
-                       .attribute(trait_.span,
-                                  cx
-                                        .meta_word(trait_.span,
-                                                   InternedString::new(
-                                                       "inline")))
-             )
-         } else {
-             Vec::new()
-         };
          // Create the method.
          @ast::Method {
              ident: method_ident,
-             attrs: attrs,
+             attrs: self.attributes.clone(),
              generics: fn_generics,
              explicit_self: explicit_self,
              fn_style: ast::NormalFn,
index 9e160b0e35dfc8e292558032a8fc8fe436ff9936,c6f0900d27bd73a90d8d6e76fa6f04b9af86e3c0..d367ae61e0b8f3e86d62e417821d0607620110eb
@@@ -14,6 -14,7 +14,7 @@@ use codemap::Span
  use ext::base::ExtCtxt;
  use ext::build::AstBuilder;
  use ext::deriving::generic::*;
+ use parse::token::InternedString;
  
  pub fn expand_deriving_hash(cx: &mut ExtCtxt,
                              span: Span,
@@@ -34,6 -35,8 +35,8 @@@
           LifetimeBounds::empty(),
           Path::new(vec!("std", "hash", "sip", "SipState")))
      };
+     let inline = cx.meta_word(span, InternedString::new("inline"));
+     let attrs = vec!(cx.attribute(span, inline));
      let hash_trait_def = TraitDef {
          span: span,
          attributes: Vec::new(),
                  explicit_self: borrowed_explicit_self(),
                  args: vec!(Ptr(~Literal(args), Borrowed(None, MutMutable))),
                  ret_ty: nil_ty(),
-                 inline: true,
+                 attributes: attrs,
                  const_nonmatching: false,
 -                combine_substructure: hash_substructure
 +                combine_substructure: combine_substructure(|a, b, c| {
 +                    hash_substructure(a, b, c)
 +                })
              }
          )
      };
index e42a3c67e34ea7201dd86aa0dd917acf80ab49b1,90b011d24e3eacc3b29528272f7ad8d508203f95..0a7aa591657668441b368b0ee3b0eb1d42462ad3
@@@ -21,6 -21,8 +21,8 @@@ pub fn expand_deriving_from_primitive(c
                                        mitem: @MetaItem,
                                        item: @Item,
                                        push: |@Item|) {
+     let inline = cx.meta_word(span, InternedString::new("inline"));
+     let attrs = vec!(cx.attribute(span, inline));
      let trait_def = TraitDef {
          span: span,
          attributes: Vec::new(),
                                             None,
                                             vec!(~Self),
                                             true)),
-                 // liable to cause code-bloat
-                 inline: true,
+                 // #[inline] liable to cause code-bloat
+                 attributes: attrs.clone(),
                  const_nonmatching: false,
 -                combine_substructure: |c, s, sub| cs_from("i64", c, s, sub),
 +                combine_substructure: combine_substructure(|c, s, sub| {
 +                    cs_from("i64", c, s, sub)
 +                }),
              },
              MethodDef {
                  name: "from_u64",
                                             None,
                                             vec!(~Self),
                                             true)),
-                 // liable to cause code-bloat
-                 inline: true,
+                 // #[inline] liable to cause code-bloat
+                 attributes: attrs,
                  const_nonmatching: false,
 -                combine_substructure: |c, s, sub| cs_from("u64", c, s, sub),
 +                combine_substructure: combine_substructure(|c, s, sub| {
 +                    cs_from("u64", c, s, sub)
 +                }),
              })
      };
  
index 09c3abf42b8cd9920ff54a96f64a5a94e00dd7ca,597e0959de2df8a4a7ebeeb62580f2c2b7ce6146..23877dd29ea79d6c55e909cb7309e8ea33e2416d
@@@ -41,11 -41,9 +41,11 @@@ pub fn expand_deriving_rand(cx: &mut Ex
                          Borrowed(None, ast::MutMutable))
                  ),
                  ret_ty: Self,
-                 inline: false,
+                 attributes: Vec::new(),
                  const_nonmatching: false,
 -                combine_substructure: rand_substructure
 +                combine_substructure: combine_substructure(|a, b, c| {
 +                    rand_substructure(a, b, c)
 +                })
              }
          )
      };
index 7098d0dd6efea4218051b6f8e678d938288eb3d9,153374fbc1630d60a8547fdf62e0fc2700eb5f51..b9725361538d1fbc9500d63f640b07711ab9cab1
@@@ -42,11 -42,9 +42,11 @@@ pub fn expand_deriving_show(cx: &mut Ex
                  explicit_self: borrowed_explicit_self(),
                  args: vec!(fmtr),
                  ret_ty: Literal(Path::new(vec!("std", "fmt", "Result"))),
-                 inline: false,
+                 attributes: Vec::new(),
                  const_nonmatching: false,
 -                combine_substructure: show_substructure
 +                combine_substructure: combine_substructure(|a, b, c| {
 +                    show_substructure(a, b, c)
 +                })
              }
          )
      };
index 0aeeabcaeabb0d25a96dd49ecfe2cdd559b0a3b8,cbb113f15f707169479f425690151da9a1296c31..449851dd3ea5913aecc03654a5d5f5f55958c801
@@@ -13,12 -13,15 +13,15 @@@ use codemap::Span
  use ext::base::ExtCtxt;
  use ext::build::AstBuilder;
  use ext::deriving::generic::*;
+ use parse::token::InternedString;
  
  pub fn expand_deriving_zero(cx: &mut ExtCtxt,
                              span: Span,
                              mitem: @MetaItem,
                              item: @Item,
                              push: |@Item|) {
+     let inline = cx.meta_word(span, InternedString::new("inline"));
+     let attrs = vec!(cx.attribute(span, inline));
      let trait_def = TraitDef {
          span: span,
          attributes: Vec::new(),
                  explicit_self: None,
                  args: Vec::new(),
                  ret_ty: Self,
-                 inline: true,
+                 attributes: attrs.clone(),
                  const_nonmatching: false,
 -                combine_substructure: zero_substructure
 +                combine_substructure: combine_substructure(|a, b, c| {
 +                    zero_substructure(a, b, c)
 +                })
              },
              MethodDef {
                  name: "is_zero",
                  explicit_self: borrowed_explicit_self(),
                  args: Vec::new(),
                  ret_ty: Literal(Path::new(vec!("bool"))),
-                 inline: true,
+                 attributes: attrs,
                  const_nonmatching: false,
 -                combine_substructure: |cx, span, substr| {
 +                combine_substructure: combine_substructure(|cx, span, substr| {
                      cs_and(|cx, span, _, _| cx.span_bug(span,
                                                          "Non-matching enum \
                                                           variant in \
                                                           deriving(Zero)"),
                             cx, span, substr)
 -                }
 +                })
              }
          )
      };