Skip to content

Commit eb774f6

Browse files
committed
Update deriving to pass around the cx linearly
1 parent e9b9067 commit eb774f6

15 files changed

+157
-132
lines changed

src/libsyntax/ext/deriving/clone.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
2020
in_items: ~[@Item])
2121
-> ~[@Item] {
2222
let trait_def = TraitDef {
23-
cx: cx, span: span,
24-
23+
span: span,
2524
path: Path::new(~["std", "clone", "Clone"]),
2625
additional_bounds: ~[],
2726
generics: LifetimeBounds::empty(),
@@ -39,7 +38,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
3938
]
4039
};
4140

42-
trait_def.expand(mitem, in_items)
41+
trait_def.expand(cx, mitem, in_items)
4342
}
4443

4544
pub fn expand_deriving_deep_clone(cx: &mut ExtCtxt,
@@ -48,8 +47,7 @@ pub fn expand_deriving_deep_clone(cx: &mut ExtCtxt,
4847
in_items: ~[@Item])
4948
-> ~[@Item] {
5049
let trait_def = TraitDef {
51-
cx: cx, span: span,
52-
50+
span: span,
5351
path: Path::new(~["std", "clone", "DeepClone"]),
5452
additional_bounds: ~[],
5553
generics: LifetimeBounds::empty(),
@@ -69,7 +67,7 @@ pub fn expand_deriving_deep_clone(cx: &mut ExtCtxt,
6967
]
7068
};
7169

72-
trait_def.expand(mitem, in_items)
70+
trait_def.expand(cx, mitem, in_items)
7371
}
7472

7573
fn cs_clone(

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
4545
);
4646

4747
let trait_def = TraitDef {
48-
cx: cx, span: span,
49-
48+
span: span,
5049
path: Path::new(~["std", "cmp", "Eq"]),
5150
additional_bounds: ~[],
5251
generics: LifetimeBounds::empty(),
@@ -55,5 +54,5 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
5554
md!("ne", cs_ne)
5655
]
5756
};
58-
trait_def.expand(mitem, in_items)
57+
trait_def.expand(cx, mitem, in_items)
5958
}

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
3535
);
3636

3737
let trait_def = TraitDef {
38-
cx: cx, span: span,
39-
38+
span: span,
4039
path: Path::new(~["std", "cmp", "Ord"]),
4140
additional_bounds: ~[],
4241
generics: LifetimeBounds::empty(),
@@ -47,7 +46,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
4746
md!("ge", false, true)
4847
]
4948
};
50-
trait_def.expand(mitem, in_items)
49+
trait_def.expand(cx, mitem, in_items)
5150
}
5251

5352
/// Strict inequality.

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
2424
}
2525

2626
let trait_def = TraitDef {
27-
cx: cx, span: span,
28-
27+
span: span,
2928
path: Path::new(~["std", "cmp", "TotalEq"]),
3029
additional_bounds: ~[],
3130
generics: LifetimeBounds::empty(),
@@ -42,5 +41,5 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
4241
}
4342
]
4443
};
45-
trait_def.expand(mitem, in_items)
44+
trait_def.expand(cx, mitem, in_items)
4645
}

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
2121
mitem: @MetaItem,
2222
in_items: ~[@Item]) -> ~[@Item] {
2323
let trait_def = TraitDef {
24-
cx: cx, span: span,
25-
24+
span: span,
2625
path: Path::new(~["std", "cmp", "TotalOrd"]),
2726
additional_bounds: ~[],
2827
generics: LifetimeBounds::empty(),
@@ -40,7 +39,7 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
4039
]
4140
};
4241

43-
trait_def.expand(mitem, in_items)
42+
trait_def.expand(cx, mitem, in_items)
4443
}
4544

4645

src/libsyntax/ext/deriving/decodable.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt,
2626
mitem: @MetaItem,
2727
in_items: ~[@Item]) -> ~[@Item] {
2828
let trait_def = TraitDef {
29-
cx: cx, span: span,
30-
29+
span: span,
3130
path: Path::new_(~["serialize", "Decodable"], None,
3231
~[~Literal(Path::new_local("__D"))], true),
3332
additional_bounds: ~[],
@@ -50,7 +49,7 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt,
5049
]
5150
};
5251

53-
trait_def.expand(mitem, in_items)
52+
trait_def.expand(cx, mitem, in_items)
5453
}
5554

5655
fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,

src/libsyntax/ext/deriving/default.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt,
1818
span: Span,
1919
mitem: @MetaItem,
2020
in_items: ~[@Item])
21-
-> ~[@Item] {
21+
-> ~[@Item] {
2222
let trait_def = TraitDef {
23-
cx: cx, span: span,
24-
23+
span: span,
2524
path: Path::new(~["std", "default", "Default"]),
2625
additional_bounds: ~[],
2726
generics: LifetimeBounds::empty(),
@@ -38,7 +37,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt,
3837
},
3938
]
4039
};
41-
trait_def.expand(mitem, in_items)
40+
trait_def.expand(cx, mitem, in_items)
4241
}
4342

4443
fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr {

src/libsyntax/ext/deriving/encodable.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
8787
mitem: @MetaItem,
8888
in_items: ~[@Item]) -> ~[@Item] {
8989
let trait_def = TraitDef {
90-
cx: cx, span: span,
91-
90+
span: span,
9291
path: Path::new_(~["serialize", "Encodable"], None,
9392
~[~Literal(Path::new_local("__E"))], true),
9493
additional_bounds: ~[],
@@ -111,7 +110,7 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
111110
]
112111
};
113112

114-
trait_def.expand(mitem, in_items)
113+
trait_def.expand(cx, mitem, in_items)
115114
}
116115

117116
fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,

0 commit comments

Comments
 (0)