Skip to content

Commit 09a8794

Browse files
committed
syntax::deriving: add the cx and span to the TraitDef to reduce duplication.
1 parent aa4455e commit 09a8794

File tree

14 files changed

+251
-226
lines changed

14 files changed

+251
-226
lines changed

src/libsyntax/ext/deriving/clone.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub fn expand_deriving_clone(cx: @ExtCtxt,
2020
in_items: ~[@item])
2121
-> ~[@item] {
2222
let trait_def = TraitDef {
23+
cx: cx, span: span,
24+
2325
path: Path::new(~["std", "clone", "Clone"]),
2426
additional_bounds: ~[],
2527
generics: LifetimeBounds::empty(),
@@ -37,7 +39,7 @@ pub fn expand_deriving_clone(cx: @ExtCtxt,
3739
]
3840
};
3941

40-
trait_def.expand(cx, span, mitem, in_items)
42+
trait_def.expand(mitem, in_items)
4143
}
4244

4345
pub fn expand_deriving_deep_clone(cx: @ExtCtxt,
@@ -46,6 +48,8 @@ pub fn expand_deriving_deep_clone(cx: @ExtCtxt,
4648
in_items: ~[@item])
4749
-> ~[@item] {
4850
let trait_def = TraitDef {
51+
cx: cx, span: span,
52+
4953
path: Path::new(~["std", "clone", "DeepClone"]),
5054
additional_bounds: ~[],
5155
generics: LifetimeBounds::empty(),
@@ -65,7 +69,7 @@ pub fn expand_deriving_deep_clone(cx: @ExtCtxt,
6569
]
6670
};
6771

68-
trait_def.expand(cx, span, mitem, in_items)
72+
trait_def.expand(mitem, in_items)
6973
}
7074

7175
fn cs_clone(

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ pub fn expand_deriving_eq(cx: @ExtCtxt,
4545
);
4646

4747
let trait_def = TraitDef {
48+
cx: cx, span: span,
49+
4850
path: Path::new(~["std", "cmp", "Eq"]),
4951
additional_bounds: ~[],
5052
generics: LifetimeBounds::empty(),
@@ -53,5 +55,5 @@ pub fn expand_deriving_eq(cx: @ExtCtxt,
5355
md!("ne", cs_ne)
5456
]
5557
};
56-
trait_def.expand(cx, span, mitem, in_items)
58+
trait_def.expand(mitem, in_items)
5759
}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ pub fn expand_deriving_ord(cx: @ExtCtxt,
3535
);
3636

3737
let trait_def = TraitDef {
38+
cx: cx, span: span,
39+
3840
path: Path::new(~["std", "cmp", "Ord"]),
3941
additional_bounds: ~[],
4042
generics: LifetimeBounds::empty(),
@@ -45,7 +47,7 @@ pub fn expand_deriving_ord(cx: @ExtCtxt,
4547
md!("ge", false, true)
4648
]
4749
};
48-
trait_def.expand(cx, span, mitem, in_items)
50+
trait_def.expand(mitem, in_items)
4951
}
5052

5153
/// Strict inequality.

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub fn expand_deriving_totaleq(cx: @ExtCtxt,
2424
}
2525

2626
let trait_def = TraitDef {
27+
cx: cx, span: span,
28+
2729
path: Path::new(~["std", "cmp", "TotalEq"]),
2830
additional_bounds: ~[],
2931
generics: LifetimeBounds::empty(),
@@ -40,5 +42,5 @@ pub fn expand_deriving_totaleq(cx: @ExtCtxt,
4042
}
4143
]
4244
};
43-
trait_def.expand(cx, span, mitem, in_items)
45+
trait_def.expand(mitem, in_items)
4446
}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ pub fn expand_deriving_totalord(cx: @ExtCtxt,
2121
mitem: @MetaItem,
2222
in_items: ~[@item]) -> ~[@item] {
2323
let trait_def = TraitDef {
24+
cx: cx, span: span,
25+
2426
path: Path::new(~["std", "cmp", "TotalOrd"]),
2527
additional_bounds: ~[],
2628
generics: LifetimeBounds::empty(),
@@ -38,7 +40,7 @@ pub fn expand_deriving_totalord(cx: @ExtCtxt,
3840
]
3941
};
4042

41-
trait_def.expand(cx, span, mitem, in_items)
43+
trait_def.expand(mitem, in_items)
4244
}
4345

4446

src/libsyntax/ext/deriving/decodable.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub fn expand_deriving_decodable(cx: @ExtCtxt,
2424
mitem: @MetaItem,
2525
in_items: ~[@item]) -> ~[@item] {
2626
let trait_def = TraitDef {
27+
cx: cx, span: span,
28+
2729
path: Path::new_(~["extra", "serialize", "Decodable"], None,
2830
~[~Literal(Path::new_local("__D"))], true),
2931
additional_bounds: ~[],
@@ -46,7 +48,7 @@ pub fn expand_deriving_decodable(cx: @ExtCtxt,
4648
]
4749
};
4850

49-
trait_def.expand(cx, span, mitem, in_items)
51+
trait_def.expand(mitem, in_items)
5052
}
5153

5254
fn decodable_substructure(cx: @ExtCtxt, span: Span,

src/libsyntax/ext/deriving/default.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub fn expand_deriving_default(cx: @ExtCtxt,
2020
in_items: ~[@item])
2121
-> ~[@item] {
2222
let trait_def = TraitDef {
23+
cx: cx, span: span,
24+
2325
path: Path::new(~["std", "default", "Default"]),
2426
additional_bounds: ~[],
2527
generics: LifetimeBounds::empty(),
@@ -36,7 +38,7 @@ pub fn expand_deriving_default(cx: @ExtCtxt,
3638
},
3739
]
3840
};
39-
trait_def.expand(cx, span, mitem, in_items)
41+
trait_def.expand(mitem, in_items)
4042
}
4143

4244
fn default_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {

src/libsyntax/ext/deriving/encodable.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ pub fn expand_deriving_encodable(cx: @ExtCtxt,
8686
mitem: @MetaItem,
8787
in_items: ~[@item]) -> ~[@item] {
8888
let trait_def = TraitDef {
89+
cx: cx, span: span,
90+
8991
path: Path::new_(~["extra", "serialize", "Encodable"], None,
9092
~[~Literal(Path::new_local("__E"))], true),
9193
additional_bounds: ~[],
@@ -108,7 +110,7 @@ pub fn expand_deriving_encodable(cx: @ExtCtxt,
108110
]
109111
};
110112

111-
trait_def.expand(cx, span, mitem, in_items)
113+
trait_def.expand(mitem, in_items)
112114
}
113115

114116
fn encodable_substructure(cx: @ExtCtxt, span: Span,

0 commit comments

Comments
 (0)