about summary refs log tree commit diff
path: root/src/libsyntax/ext/deriving/clone.rs
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2013-11-07 18:49:01 +1100
committerHuon Wilson <dbau.pp+github@gmail.com>2013-11-08 20:57:34 +1100
commit812ea9e169d6edcc138e334e7e2b2cb5f7ba66b3 (patch)
treebc573c50474ccf53fc5dfbb21c8217beee36d604 /src/libsyntax/ext/deriving/clone.rs
parent57d1ed819b9e32a8e915ced9b5e130c299a46bca (diff)
downloadrust-812ea9e169d6edcc138e334e7e2b2cb5f7ba66b3.tar.gz
rust-812ea9e169d6edcc138e334e7e2b2cb5f7ba66b3.zip
syntax::ext: Make type errors in deriving point to the field itself.
This rearranges the deriving code so that #[deriving] a trait on a field
that doesn't implement that trait will point to the field in question,
e.g.

    struct NotEq; // doesn't implement Eq

    #[deriving(Eq)]
    struct Foo {
        ok: int,
        also_ok: ~str,
        bad: NotEq // error points here.
    }

Unfortunately, this means the error is disconnected from the `deriving`
itself but there's no current way to pass that information through to
rustc except via the spans, at the moment.

Fixes #7724.
Diffstat (limited to 'src/libsyntax/ext/deriving/clone.rs')
-rw-r--r--src/libsyntax/ext/deriving/clone.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs
index 5b107a49175..6ff39351448 100644
--- a/src/libsyntax/ext/deriving/clone.rs
+++ b/src/libsyntax/ext/deriving/clone.rs
@@ -94,21 +94,21 @@ fn cs_clone(
     }
 
     match *all_fields {
-        [(None, _, _), .. _] => {
+        [FieldInfo { name: None, _ }, .. _] => {
             // enum-like
-            let subcalls = all_fields.map(|&(_, self_f, _)| subcall(self_f));
+            let subcalls = all_fields.map(|field| subcall(field.self_));
             cx.expr_call_ident(span, ctor_ident, subcalls)
         },
         _ => {
             // struct-like
-            let fields = do all_fields.map |&(o_id, self_f, _)| {
-                let ident = match o_id {
+            let fields = do all_fields.map |field| {
+                let ident = match field.name {
                     Some(i) => i,
                     None => cx.span_bug(span,
                                         format!("unnamed field in normal struct in `deriving({})`",
                                              name))
                 };
-                cx.field_imm(span, ident, subcall(self_f))
+                cx.field_imm(span, ident, subcall(field.self_))
             };
 
             if fields.is_empty() {