Skip to content

Commit

Permalink
Update deriving to pass around the cx linearly
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Feb 9, 2014
1 parent e9b9067 commit eb774f6
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 132 deletions.
10 changes: 4 additions & 6 deletions src/libsyntax/ext/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
in_items: ~[@Item])
-> ~[@Item] {
let trait_def = TraitDef {
cx: cx, span: span,

span: span,
path: Path::new(~["std", "clone", "Clone"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
Expand All @@ -39,7 +38,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
]
};

trait_def.expand(mitem, in_items)
trait_def.expand(cx, mitem, in_items)
}

pub fn expand_deriving_deep_clone(cx: &mut ExtCtxt,
Expand All @@ -48,8 +47,7 @@ pub fn expand_deriving_deep_clone(cx: &mut ExtCtxt,
in_items: ~[@Item])
-> ~[@Item] {
let trait_def = TraitDef {
cx: cx, span: span,

span: span,
path: Path::new(~["std", "clone", "DeepClone"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
Expand All @@ -69,7 +67,7 @@ pub fn expand_deriving_deep_clone(cx: &mut ExtCtxt,
]
};

trait_def.expand(mitem, in_items)
trait_def.expand(cx, mitem, in_items)
}

fn cs_clone(
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/ext/deriving/cmp/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
);

let trait_def = TraitDef {
cx: cx, span: span,

span: span,
path: Path::new(~["std", "cmp", "Eq"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
Expand All @@ -55,5 +54,5 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
md!("ne", cs_ne)
]
};
trait_def.expand(mitem, in_items)
trait_def.expand(cx, mitem, in_items)
}
5 changes: 2 additions & 3 deletions src/libsyntax/ext/deriving/cmp/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
);

let trait_def = TraitDef {
cx: cx, span: span,

span: span,
path: Path::new(~["std", "cmp", "Ord"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
Expand All @@ -47,7 +46,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
md!("ge", false, true)
]
};
trait_def.expand(mitem, in_items)
trait_def.expand(cx, mitem, in_items)
}

/// Strict inequality.
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/ext/deriving/cmp/totaleq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
}

let trait_def = TraitDef {
cx: cx, span: span,

span: span,
path: Path::new(~["std", "cmp", "TotalEq"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
Expand All @@ -42,5 +41,5 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
}
]
};
trait_def.expand(mitem, in_items)
trait_def.expand(cx, mitem, in_items)
}
5 changes: 2 additions & 3 deletions src/libsyntax/ext/deriving/cmp/totalord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
mitem: @MetaItem,
in_items: ~[@Item]) -> ~[@Item] {
let trait_def = TraitDef {
cx: cx, span: span,

span: span,
path: Path::new(~["std", "cmp", "TotalOrd"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
Expand All @@ -40,7 +39,7 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
]
};

trait_def.expand(mitem, in_items)
trait_def.expand(cx, mitem, in_items)
}


Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/ext/deriving/decodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt,
mitem: @MetaItem,
in_items: ~[@Item]) -> ~[@Item] {
let trait_def = TraitDef {
cx: cx, span: span,

span: span,
path: Path::new_(~["serialize", "Decodable"], None,
~[~Literal(Path::new_local("__D"))], true),
additional_bounds: ~[],
Expand All @@ -50,7 +49,7 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt,
]
};

trait_def.expand(mitem, in_items)
trait_def.expand(cx, mitem, in_items)
}

fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
Expand Down
7 changes: 3 additions & 4 deletions src/libsyntax/ext/deriving/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt,
span: Span,
mitem: @MetaItem,
in_items: ~[@Item])
-> ~[@Item] {
-> ~[@Item] {
let trait_def = TraitDef {
cx: cx, span: span,

span: span,
path: Path::new(~["std", "default", "Default"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
Expand All @@ -38,7 +37,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt,
},
]
};
trait_def.expand(mitem, in_items)
trait_def.expand(cx, mitem, in_items)
}

fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr {
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/ext/deriving/encodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
mitem: @MetaItem,
in_items: ~[@Item]) -> ~[@Item] {
let trait_def = TraitDef {
cx: cx, span: span,

span: span,
path: Path::new_(~["serialize", "Encodable"], None,
~[~Literal(Path::new_local("__E"))], true),
additional_bounds: ~[],
Expand All @@ -111,7 +110,7 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
]
};

trait_def.expand(mitem, in_items)
trait_def.expand(cx, mitem, in_items)
}

fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
Expand Down
Loading

5 comments on commit eb774f6

@bors
Copy link
Contributor

@bors bors commented on eb774f6 Feb 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at nikomatsakis@eb774f6

@bors
Copy link
Contributor

@bors bors commented on eb774f6 Feb 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/issue-11913-borrow-in-aliasable-loc = eb774f6 into auto

@bors
Copy link
Contributor

@bors bors commented on eb774f6 Feb 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/issue-11913-borrow-in-aliasable-loc = eb774f6 merged ok, testing candidate = f0e0d9e

@bors
Copy link
Contributor

@bors bors commented on eb774f6 Feb 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on eb774f6 Feb 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = f0e0d9e

Please sign in to comment.