Skip to content

Commit 4e1a098

Browse files
committed
auto merge of #13704 : edwardw/rust/doc-hidden, r=alexcrichton
Closes #13698
2 parents 0e750ad + 2cf1e4b commit 4e1a098

File tree

14 files changed

+52
-37
lines changed

14 files changed

+52
-37
lines changed

src/libsyntax/ext/deriving/clone.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use parse::token::InternedString;
1617

1718
pub fn expand_deriving_clone(cx: &mut ExtCtxt,
1819
span: Span,
1920
mitem: @MetaItem,
2021
item: @Item,
2122
push: |@Item|) {
23+
let inline = cx.meta_word(span, InternedString::new("inline"));
24+
let attrs = vec!(cx.attribute(span, inline));
2225
let trait_def = TraitDef {
2326
span: span,
2427
attributes: Vec::new(),
@@ -32,7 +35,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
3235
explicit_self: borrowed_explicit_self(),
3336
args: Vec::new(),
3437
ret_ty: Self,
35-
inline: true,
38+
attributes: attrs,
3639
const_nonmatching: false,
3740
combine_substructure: combine_substructure(|c, s, sub| {
3841
cs_clone("Clone", c, s, sub)

src/libsyntax/ext/deriving/cmp/eq.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use parse::token::InternedString;
1617

1718
pub fn expand_deriving_eq(cx: &mut ExtCtxt,
1819
span: Span,
@@ -31,20 +32,22 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
3132
}
3233

3334
macro_rules! md (
34-
($name:expr, $f:ident) => {
35+
($name:expr, $f:ident) => { {
36+
let inline = cx.meta_word(span, InternedString::new("inline"));
37+
let attrs = vec!(cx.attribute(span, inline));
3538
MethodDef {
3639
name: $name,
3740
generics: LifetimeBounds::empty(),
3841
explicit_self: borrowed_explicit_self(),
3942
args: vec!(borrowed_self()),
4043
ret_ty: Literal(Path::new(vec!("bool"))),
41-
inline: true,
44+
attributes: attrs,
4245
const_nonmatching: true,
4346
combine_substructure: combine_substructure(|a, b, c| {
4447
$f(a, b, c)
4548
})
4649
}
47-
}
50+
} }
4851
);
4952

5053
let trait_def = TraitDef {

src/libsyntax/ext/deriving/cmp/ord.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,30 @@ use codemap::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::build::AstBuilder;
1616
use ext::deriving::generic::*;
17+
use parse::token::InternedString;
1718

1819
pub fn expand_deriving_ord(cx: &mut ExtCtxt,
1920
span: Span,
2021
mitem: @MetaItem,
2122
item: @Item,
2223
push: |@Item|) {
2324
macro_rules! md (
24-
($name:expr, $op:expr, $equal:expr) => {
25+
($name:expr, $op:expr, $equal:expr) => { {
26+
let inline = cx.meta_word(span, InternedString::new("inline"));
27+
let attrs = vec!(cx.attribute(span, inline));
2528
MethodDef {
2629
name: $name,
2730
generics: LifetimeBounds::empty(),
2831
explicit_self: borrowed_explicit_self(),
2932
args: vec!(borrowed_self()),
3033
ret_ty: Literal(Path::new(vec!("bool"))),
31-
inline: true,
34+
attributes: attrs,
3235
const_nonmatching: false,
3336
combine_substructure: combine_substructure(|cx, span, substr| {
3437
cs_op($op, $equal, cx, span, substr)
3538
})
3639
}
37-
}
40+
} }
3841
);
3942

4043
let trait_def = TraitDef {

src/libsyntax/ext/deriving/cmp/totaleq.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use parse::token::InternedString;
1617

1718
pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
1819
span: Span,
@@ -33,6 +34,11 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
3334
substr)
3435
}
3536

37+
let inline = cx.meta_word(span, InternedString::new("inline"));
38+
let hidden = cx.meta_word(span, InternedString::new("hidden"));
39+
let doc = cx.meta_list(span, InternedString::new("doc"), vec!(hidden));
40+
let attrs = vec!(cx.attribute(span, inline),
41+
cx.attribute(span, doc));
3642
let trait_def = TraitDef {
3743
span: span,
3844
attributes: Vec::new(),
@@ -46,7 +52,7 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
4652
explicit_self: borrowed_explicit_self(),
4753
args: vec!(),
4854
ret_ty: nil_ty(),
49-
inline: true,
55+
attributes: attrs,
5056
const_nonmatching: true,
5157
combine_substructure: combine_substructure(|a, b, c| {
5258
cs_total_eq_assert(a, b, c)

src/libsyntax/ext/deriving/cmp/totalord.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use codemap::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::build::AstBuilder;
1616
use ext::deriving::generic::*;
17+
use parse::token::InternedString;
1718

1819
use std::cmp::{Ordering, Equal, Less, Greater};
1920

@@ -22,6 +23,8 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
2223
mitem: @MetaItem,
2324
item: @Item,
2425
push: |@Item|) {
26+
let inline = cx.meta_word(span, InternedString::new("inline"));
27+
let attrs = vec!(cx.attribute(span, inline));
2528
let trait_def = TraitDef {
2629
span: span,
2730
attributes: Vec::new(),
@@ -35,7 +38,7 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
3538
explicit_self: borrowed_explicit_self(),
3639
args: vec!(borrowed_self()),
3740
ret_ty: Literal(Path::new(vec!("std", "cmp", "Ordering"))),
38-
inline: true,
41+
attributes: attrs,
3942
const_nonmatching: false,
4043
combine_substructure: combine_substructure(|a, b, c| {
4144
cs_cmp(a, b, c)

src/libsyntax/ext/deriving/decodable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt,
5050
Borrowed(None, MutMutable))),
5151
ret_ty: Literal(Path::new_(vec!("std", "result", "Result"), None,
5252
vec!(~Self, ~Literal(Path::new_local("__E"))), true)),
53-
inline: false,
53+
attributes: Vec::new(),
5454
const_nonmatching: true,
5555
combine_substructure: combine_substructure(|a, b, c| {
5656
decodable_substructure(a, b, c)

src/libsyntax/ext/deriving/default.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use parse::token::InternedString;
1617

1718
pub fn expand_deriving_default(cx: &mut ExtCtxt,
1819
span: Span,
1920
mitem: @MetaItem,
2021
item: @Item,
2122
push: |@Item|) {
23+
let inline = cx.meta_word(span, InternedString::new("inline"));
24+
let attrs = vec!(cx.attribute(span, inline));
2225
let trait_def = TraitDef {
2326
span: span,
2427
attributes: Vec::new(),
@@ -32,7 +35,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt,
3235
explicit_self: None,
3336
args: Vec::new(),
3437
ret_ty: Self,
35-
inline: true,
38+
attributes: attrs,
3639
const_nonmatching: false,
3740
combine_substructure: combine_substructure(|a, b, c| {
3841
default_substructure(a, b, c)

src/libsyntax/ext/deriving/encodable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
121121
vec!(~Tuple(Vec::new()),
122122
~Literal(Path::new_local("__E"))),
123123
true)),
124-
inline: false,
124+
attributes: Vec::new(),
125125
const_nonmatching: true,
126126
combine_substructure: combine_substructure(|a, b, c| {
127127
encodable_substructure(a, b, c)

src/libsyntax/ext/deriving/generic.rs

+2-16
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ pub struct MethodDef<'a> {
229229
/// Return type
230230
pub ret_ty: Ty<'a>,
231231

232-
/// Whether to mark this as #[inline]
233-
pub inline: bool,
232+
pub attributes: Vec<ast::Attribute>,
234233

235234
/// if the value of the nonmatching enums is independent of the
236235
/// actual enum variants, i.e. can use _ => .. match.
@@ -612,23 +611,10 @@ impl<'a> MethodDef<'a> {
612611
let fn_decl = cx.fn_decl(args, ret_type);
613612
let body_block = cx.block_expr(body);
614613

615-
let attrs = if self.inline {
616-
vec!(
617-
cx
618-
.attribute(trait_.span,
619-
cx
620-
.meta_word(trait_.span,
621-
InternedString::new(
622-
"inline")))
623-
)
624-
} else {
625-
Vec::new()
626-
};
627-
628614
// Create the method.
629615
@ast::Method {
630616
ident: method_ident,
631-
attrs: attrs,
617+
attrs: self.attributes.clone(),
632618
generics: fn_generics,
633619
explicit_self: explicit_self,
634620
fn_style: ast::NormalFn,

src/libsyntax/ext/deriving/hash.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use codemap::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::build::AstBuilder;
1616
use ext::deriving::generic::*;
17+
use parse::token::InternedString;
1718

1819
pub fn expand_deriving_hash(cx: &mut ExtCtxt,
1920
span: Span,
@@ -34,6 +35,8 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt,
3435
LifetimeBounds::empty(),
3536
Path::new(vec!("std", "hash", "sip", "SipState")))
3637
};
38+
let inline = cx.meta_word(span, InternedString::new("inline"));
39+
let attrs = vec!(cx.attribute(span, inline));
3740
let hash_trait_def = TraitDef {
3841
span: span,
3942
attributes: Vec::new(),
@@ -47,7 +50,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt,
4750
explicit_self: borrowed_explicit_self(),
4851
args: vec!(Ptr(~Literal(args), Borrowed(None, MutMutable))),
4952
ret_ty: nil_ty(),
50-
inline: true,
53+
attributes: attrs,
5154
const_nonmatching: false,
5255
combine_substructure: combine_substructure(|a, b, c| {
5356
hash_substructure(a, b, c)

src/libsyntax/ext/deriving/primitive.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,
2121
mitem: @MetaItem,
2222
item: @Item,
2323
push: |@Item|) {
24+
let inline = cx.meta_word(span, InternedString::new("inline"));
25+
let attrs = vec!(cx.attribute(span, inline));
2426
let trait_def = TraitDef {
2527
span: span,
2628
attributes: Vec::new(),
@@ -38,8 +40,8 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,
3840
None,
3941
vec!(~Self),
4042
true)),
41-
// liable to cause code-bloat
42-
inline: true,
43+
// #[inline] liable to cause code-bloat
44+
attributes: attrs.clone(),
4345
const_nonmatching: false,
4446
combine_substructure: combine_substructure(|c, s, sub| {
4547
cs_from("i64", c, s, sub)
@@ -55,8 +57,8 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,
5557
None,
5658
vec!(~Self),
5759
true)),
58-
// liable to cause code-bloat
59-
inline: true,
60+
// #[inline] liable to cause code-bloat
61+
attributes: attrs,
6062
const_nonmatching: false,
6163
combine_substructure: combine_substructure(|c, s, sub| {
6264
cs_from("u64", c, s, sub)

src/libsyntax/ext/deriving/rand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn expand_deriving_rand(cx: &mut ExtCtxt,
4141
Borrowed(None, ast::MutMutable))
4242
),
4343
ret_ty: Self,
44-
inline: false,
44+
attributes: Vec::new(),
4545
const_nonmatching: false,
4646
combine_substructure: combine_substructure(|a, b, c| {
4747
rand_substructure(a, b, c)

src/libsyntax/ext/deriving/show.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn expand_deriving_show(cx: &mut ExtCtxt,
4242
explicit_self: borrowed_explicit_self(),
4343
args: vec!(fmtr),
4444
ret_ty: Literal(Path::new(vec!("std", "fmt", "Result"))),
45-
inline: false,
45+
attributes: Vec::new(),
4646
const_nonmatching: false,
4747
combine_substructure: combine_substructure(|a, b, c| {
4848
show_substructure(a, b, c)

src/libsyntax/ext/deriving/zero.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use parse::token::InternedString;
1617

1718
pub fn expand_deriving_zero(cx: &mut ExtCtxt,
1819
span: Span,
1920
mitem: @MetaItem,
2021
item: @Item,
2122
push: |@Item|) {
23+
let inline = cx.meta_word(span, InternedString::new("inline"));
24+
let attrs = vec!(cx.attribute(span, inline));
2225
let trait_def = TraitDef {
2326
span: span,
2427
attributes: Vec::new(),
@@ -32,7 +35,7 @@ pub fn expand_deriving_zero(cx: &mut ExtCtxt,
3235
explicit_self: None,
3336
args: Vec::new(),
3437
ret_ty: Self,
35-
inline: true,
38+
attributes: attrs.clone(),
3639
const_nonmatching: false,
3740
combine_substructure: combine_substructure(|a, b, c| {
3841
zero_substructure(a, b, c)
@@ -44,7 +47,7 @@ pub fn expand_deriving_zero(cx: &mut ExtCtxt,
4447
explicit_self: borrowed_explicit_self(),
4548
args: Vec::new(),
4649
ret_ty: Literal(Path::new(vec!("bool"))),
47-
inline: true,
50+
attributes: attrs,
4851
const_nonmatching: false,
4952
combine_substructure: combine_substructure(|cx, span, substr| {
5053
cs_and(|cx, span, _, _| cx.span_bug(span,

0 commit comments

Comments
 (0)