about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-01-05 14:51:03 +0000
committerbors <bors@rust-lang.org>2015-01-05 14:51:03 +0000
commit03268bbf35d3ff2350d987fe7b60375839abdf2e (patch)
tree86ecae7591630a6ccf7a69a47570577a0caea8c6 /src/libsyntax/ext
parent8e83af6e879535c33fd83d247d16619e39e0b951 (diff)
parent0cb7a4062a3c69bb0c54f0c9136889a1006e4f62 (diff)
downloadrust-03268bbf35d3ff2350d987fe7b60375839abdf2e.tar.gz
rust-03268bbf35d3ff2350d987fe7b60375839abdf2e.zip
auto merge of #20514 : alexcrichton/rust/serialize-associated-type, r=aturon
This commit moves the libserialize crate (and will force the hand of the
rustc-serialize crate) to not require the `old_orphan_check` feature gate as
well as using associated types wherever possible. Concretely, the following
changes were made:

* The error type of `Encoder` and `Decoder` is now an associated type, meaning
  that these traits have no type parameters.

* The `Encoder` and `Decoder` type parameters on the `Encodable` and `Decodable`
  traits have moved to the corresponding method of the trait. This movement
  alleviates the dependency on `old_orphan_check` but implies that
  implementations can no longer be specialized for the type of encoder/decoder
  being implemented.

Due to the trait definitions changing, this is a:

[breaking-change]
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/deriving/decodable.rs30
-rw-r--r--src/libsyntax/ext/deriving/encodable.rs32
2 files changed, 32 insertions, 30 deletions
diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs
index 882136cb862..c0631b8350b 100644
--- a/src/libsyntax/ext/deriving/decodable.rs
+++ b/src/libsyntax/ext/deriving/decodable.rs
@@ -52,27 +52,29 @@ fn expand_deriving_decodable_imp<F>(cx: &mut ExtCtxt,
     let trait_def = TraitDef {
         span: span,
         attributes: Vec::new(),
-        path: Path::new_(vec!(krate, "Decodable"), None,
-                         vec!(box Literal(Path::new_local("__D")),
-                              box Literal(Path::new_local("__E"))), true),
+        path: Path::new_(vec!(krate, "Decodable"), None, vec!(), true),
         additional_bounds: Vec::new(),
-        generics: LifetimeBounds {
-            lifetimes: Vec::new(),
-            bounds: vec!(("__D", vec!(Path::new_(
-                            vec!(krate, "Decoder"), None,
-                            vec!(box Literal(Path::new_local("__E"))), true))),
-                         ("__E", vec!()))
-        },
+        generics: LifetimeBounds::empty(),
         methods: vec!(
             MethodDef {
                 name: "decode",
-                generics: LifetimeBounds::empty(),
+                generics: LifetimeBounds {
+                    lifetimes: Vec::new(),
+                    bounds: vec!(("__D", vec!(Path::new_(
+                                    vec!(krate, "Decoder"), None,
+                                    vec!(), true))))
+                },
                 explicit_self: None,
                 args: vec!(Ptr(box Literal(Path::new_local("__D")),
                             Borrowed(None, MutMutable))),
-                ret_ty: Literal(Path::new_(vec!("std", "result", "Result"), None,
-                                          vec!(box Self,
-                                               box Literal(Path::new_local("__E"))), true)),
+                ret_ty: Literal(Path::new_(
+                    vec!("std", "result", "Result"),
+                    None,
+                    vec!(box Self, box Literal(Path::new_(
+                        vec!["__D", "Error"], None, vec![], false
+                    ))),
+                    true
+                )),
                 attributes: Vec::new(),
                 combine_substructure: combine_substructure(|a, b, c| {
                     decodable_substructure(a, b, c, krate)
diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs
index b2c929123d5..4323d2979cc 100644
--- a/src/libsyntax/ext/deriving/encodable.rs
+++ b/src/libsyntax/ext/deriving/encodable.rs
@@ -128,29 +128,29 @@ fn expand_deriving_encodable_imp<F>(cx: &mut ExtCtxt,
     let trait_def = TraitDef {
         span: span,
         attributes: Vec::new(),
-        path: Path::new_(vec!(krate, "Encodable"), None,
-                         vec!(box Literal(Path::new_local("__S")),
-                              box Literal(Path::new_local("__E"))), true),
+        path: Path::new_(vec!(krate, "Encodable"), None, vec!(), true),
         additional_bounds: Vec::new(),
-        generics: LifetimeBounds {
-            lifetimes: Vec::new(),
-            bounds: vec!(("__S", vec!(Path::new_(
-                            vec!(krate, "Encoder"), None,
-                            vec!(box Literal(Path::new_local("__E"))), true))),
-                         ("__E", vec!()))
-        },
+        generics: LifetimeBounds::empty(),
         methods: vec!(
             MethodDef {
                 name: "encode",
-                generics: LifetimeBounds::empty(),
+                generics: LifetimeBounds {
+                    lifetimes: Vec::new(),
+                    bounds: vec!(("__S", vec!(Path::new_(
+                                    vec!(krate, "Encoder"), None,
+                                    vec!(), true))))
+                },
                 explicit_self: borrowed_explicit_self(),
                 args: vec!(Ptr(box Literal(Path::new_local("__S")),
                             Borrowed(None, MutMutable))),
-                ret_ty: Literal(Path::new_(vec!("std", "result", "Result"),
-                                           None,
-                                           vec!(box Tuple(Vec::new()),
-                                                box Literal(Path::new_local("__E"))),
-                                           true)),
+                ret_ty: Literal(Path::new_(
+                    vec!("std", "result", "Result"),
+                    None,
+                    vec!(box Tuple(Vec::new()), box Literal(Path::new_(
+                        vec!["__S", "Error"], None, vec![], false
+                    ))),
+                    true
+                )),
                 attributes: Vec::new(),
                 combine_substructure: combine_substructure(|a, b, c| {
                     encodable_substructure(a, b, c)