]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/ext/deriving/show.rs
Associated types support for deriving::generic::TraitDef
[rust.git] / src / libsyntax / ext / deriving / show.rs
index eceac4e9a8368ff38af02b125baaa07a05b5bb92..ec5941f58f3f02c1aaf49b01a8d3ceafd0970689 100644 (file)
@@ -35,10 +35,10 @@ pub fn expand_deriving_show<F>(cx: &mut ExtCtxt,
     let trait_def = TraitDef {
         span: span,
         attributes: Vec::new(),
-        path: Path::new(vec!("std", "fmt", "Show")),
+        path: Path::new(vec!["std", "fmt", "Debug"]),
         additional_bounds: Vec::new(),
         generics: LifetimeBounds::empty(),
-        methods: vec!(
+        methods: vec![
             MethodDef {
                 name: "fmt",
                 generics: LifetimeBounds::empty(),
@@ -50,7 +50,8 @@ pub fn expand_deriving_show<F>(cx: &mut ExtCtxt,
                     show_substructure(a, b, c)
                 })
             }
-        )
+        ],
+        associated_types: Vec::new(),
     };
     trait_def.expand(cx, mitem, item, push)
 }
@@ -67,7 +68,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
         Struct(_) => substr.type_ident,
         EnumMatching(_, v, _) => v.node.name,
         EnumNonMatchingCollapsed(..) | StaticStruct(..) | StaticEnum(..) => {
-            cx.span_bug(span, "nonsensical .fields in `#[derive(Show)]`")
+            cx.span_bug(span, "nonsensical .fields in `#[derive(Debug)]`")
         }
     };
 
@@ -90,7 +91,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
                 for (i, field) in fields.iter().enumerate() {
                     if i != 0 { format_string.push_str(", "); }
 
-                    format_string.push_str("{}");
+                    format_string.push_str("{:?}");
 
                     exprs.push(field.self_.clone());
                 }
@@ -107,7 +108,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
                     let name = token::get_ident(field.name.unwrap());
                     format_string.push_str(" ");
                     format_string.push_str(name.get());
-                    format_string.push_str(": {}");
+                    format_string.push_str(": {:?}");
 
                     exprs.push(field.self_.clone());
                 }
@@ -127,7 +128,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
     let formatter = substr.nonself_args[0].clone();
 
     let meth = cx.ident_of("write_fmt");
-    let s = token::intern_and_get_ident(format_string[]);
+    let s = token::intern_and_get_ident(&format_string[]);
     let format_string = cx.expr_str(span, s);
 
     // phew, not our responsibility any more!