about summary refs log tree commit diff
path: root/src/libsyntax/ext/deriving/cmp
diff options
context:
space:
mode:
authorEdward Wang <edward.yu.wang@gmail.com>2014-04-23 22:43:45 +0800
committerEdward Wang <edward.yu.wang@gmail.com>2014-04-23 22:43:45 +0800
commit2cf1e4b0ceb4db8ab48144407f3afa9ccd8ced2c (patch)
tree6d3f5726096ad4d928f0499629aea4cee0623a5d /src/libsyntax/ext/deriving/cmp
parente049a7003b686002d5c091ec0465d07e5c5ff7a6 (diff)
downloadrust-2cf1e4b0ceb4db8ab48144407f3afa9ccd8ced2c.tar.gz
rust-2cf1e4b0ceb4db8ab48144407f3afa9ccd8ced2c.zip
Honor hidden doc attribute of derivable trait methods
Closes #13698
Diffstat (limited to 'src/libsyntax/ext/deriving/cmp')
-rw-r--r--src/libsyntax/ext/deriving/cmp/eq.rs9
-rw-r--r--src/libsyntax/ext/deriving/cmp/ord.rs9
-rw-r--r--src/libsyntax/ext/deriving/cmp/totaleq.rs8
-rw-r--r--src/libsyntax/ext/deriving/cmp/totalord.rs5
4 files changed, 23 insertions, 8 deletions
diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs
index 975b8885de7..8a877a2a7a4 100644
--- a/src/libsyntax/ext/deriving/cmp/eq.rs
+++ b/src/libsyntax/ext/deriving/cmp/eq.rs
@@ -13,6 +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,
@@ -31,18 +32,20 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
     }
 
     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
             }
-        }
+        } }
     );
 
     let trait_def = TraitDef {
diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs
index 5605c0b6107..2b2a490e5a4 100644
--- a/src/libsyntax/ext/deriving/cmp/ord.rs
+++ b/src/libsyntax/ext/deriving/cmp/ord.rs
@@ -14,6 +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,
@@ -21,18 +22,20 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
                            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)
             }
-        }
+        } }
     );
 
     let trait_def = TraitDef {
diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs
index 33512b3df5e..24e0fc73f2a 100644
--- a/src/libsyntax/ext/deriving/cmp/totaleq.rs
+++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs
@@ -13,6 +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,
@@ -33,6 +34,11 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
                        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(),
@@ -46,7 +52,7 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
                 explicit_self: borrowed_explicit_self(),
                 args: vec!(),
                 ret_ty: nil_ty(),
-                inline: true,
+                attributes: attrs,
                 const_nonmatching: true,
                 combine_substructure: cs_total_eq_assert
             }
diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs
index a584f8abe05..c2e52f7ef77 100644
--- a/src/libsyntax/ext/deriving/cmp/totalord.rs
+++ b/src/libsyntax/ext/deriving/cmp/totalord.rs
@@ -14,6 +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 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
                                 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(),
@@ -35,7 +38,7 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
                 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
             }