diff options
| author | bors <bors@rust-lang.org> | 2014-12-17 21:33:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-17 21:33:15 +0000 |
| commit | 22a9f250b5e2de64c13c0f056aec13eb086ef79d (patch) | |
| tree | d996edc2a0a259556be226b4f60437f961fb09b2 /src/libsyntax/ext | |
| parent | 66c297d847ce06a8982d4d322221b17a3cd04f90 (diff) | |
| parent | 5c98952409c9123b5f26b3c620029cd1914a07b6 (diff) | |
auto merge of #19958 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/mod.rs | 30 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/mod.rs | 24 |
2 files changed, 47 insertions, 7 deletions
diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index f40be823a1a..b31758e2d2a 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -388,7 +388,7 @@ impl<'a> TraitDef<'a> { methods: Vec<P<ast::Method>>) -> P<ast::Item> { let trait_path = self.path.to_path(cx, self.span, type_ident, generics); - let Generics { mut lifetimes, ty_params, where_clause: _ } = + let Generics { mut lifetimes, ty_params, mut where_clause } = self.generics.to_generics(cx, self.span, type_ident, generics); let mut ty_params = ty_params.into_vec(); @@ -420,13 +420,33 @@ impl<'a> TraitDef<'a> { ty_param.unbound.clone(), None) })); + + // and similarly for where clauses + where_clause.predicates.extend(generics.where_clause.predicates.iter().map(|clause| { + match *clause { + ast::WherePredicate::BoundPredicate(ref wb) => { + ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate { + id: ast::DUMMY_NODE_ID, + span: self.span, + ident: wb.ident, + bounds: OwnedSlice::from_vec(wb.bounds.iter().map(|b| b.clone()).collect()) + }) + } + ast::WherePredicate::EqPredicate(ref we) => { + ast::WherePredicate::EqPredicate(ast::WhereEqPredicate { + id: ast::DUMMY_NODE_ID, + span: self.span, + path: we.path.clone(), + ty: we.ty.clone() + }) + } + } + })); + let trait_generics = Generics { lifetimes: lifetimes, ty_params: OwnedSlice::from_vec(ty_params), - where_clause: ast::WhereClause { - id: ast::DUMMY_NODE_ID, - predicates: Vec::new(), - }, + where_clause: where_clause }; // Create the reference to the trait. diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index fccef47d1ea..839e99c81d1 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -70,8 +70,28 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt, "Hash" => expand!(hash::expand_deriving_hash), - "Encodable" => expand!(encodable::expand_deriving_encodable), - "Decodable" => expand!(decodable::expand_deriving_decodable), + "RustcEncodable" => { + expand!(encodable::expand_deriving_encodable) + } + "RustcDecodable" => { + expand!(decodable::expand_deriving_decodable) + } + "Encodable" => { + // NOTE: uncomment after a stage0 snap + // cx.span_warn(titem.span, + // "deriving(Encodable) is deprecated \ + // in favor of deriving(RustcEncodable)"); + + expand!(encodable::expand_deriving_encodable) + } + "Decodable" => { + // NOTE: uncomment after a stage0 snap + // cx.span_warn(titem.span, + // "deriving(Decodable) is deprecated \ + // in favor of deriving(RustcDecodable)"); + + expand!(decodable::expand_deriving_decodable) + } "PartialEq" => expand!(eq::expand_deriving_eq), "Eq" => expand!(totaleq::expand_deriving_totaleq), |
