]> git.lizzy.rs Git - rust.git/commit
syntax::ext: Make type errors in deriving point to the field itself.
authorHuon Wilson <dbau.pp+github@gmail.com>
Thu, 7 Nov 2013 07:49:01 +0000 (18:49 +1100)
committerHuon Wilson <dbau.pp+github@gmail.com>
Fri, 8 Nov 2013 09:57:34 +0000 (20:57 +1100)
commit812ea9e169d6edcc138e334e7e2b2cb5f7ba66b3
treebc573c50474ccf53fc5dfbb21c8217beee36d604
parent57d1ed819b9e32a8e915ced9b5e130c299a46bca
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.
13 files changed:
src/libsyntax/ext/deriving/clone.rs
src/libsyntax/ext/deriving/decodable.rs
src/libsyntax/ext/deriving/default.rs
src/libsyntax/ext/deriving/encodable.rs
src/libsyntax/ext/deriving/generic.rs
src/libsyntax/ext/deriving/iter_bytes.rs
src/libsyntax/ext/deriving/rand.rs
src/libsyntax/ext/deriving/to_str.rs
src/libsyntax/ext/deriving/zero.rs
src/test/compile-fail/deriving-field-span-enum-struct-variant.rs [new file with mode: 0644]
src/test/compile-fail/deriving-field-span-enum.rs [new file with mode: 0644]
src/test/compile-fail/deriving-field-span-struct.rs [new file with mode: 0644]
src/test/compile-fail/deriving-field-span-tuple-struct.rs [new file with mode: 0644]