]> git.lizzy.rs Git - rust.git/commit
derive: improve hygiene for type parameters (see #2810)
authorAlex Burka <aburka@seas.upenn.edu>
Tue, 8 Mar 2016 18:24:28 +0000 (13:24 -0500)
committerAlex Burka <aburka@seas.upenn.edu>
Mon, 14 Mar 2016 20:59:55 +0000 (16:59 -0400)
commit8355389e3e9d299d90ea78197c0e5b6c2162a957
tree6f0853fad3dbb342f9c3801d20882f19145be12e
parentfd4fa62885d7b7319a7cf88e834fa1016ac9ae5c
derive: improve hygiene for type parameters (see #2810)

When deriving Hash, RustcEncodable and RustcDecodable, the syntax extension
needs a type parameter to use in the inner method. They used to use __H, __S
and __D respectively. If this conflicts with a type parameter already declared
for the item, bad times result (see the test). There is no hygiene for type
parameters, but this commit introduces a better heuristic by concatenating the
names of all extant type parameters (and prepending __H).
src/libsyntax_ext/deriving/cmp/ord.rs
src/libsyntax_ext/deriving/decodable.rs
src/libsyntax_ext/deriving/encodable.rs
src/libsyntax_ext/deriving/hash.rs
src/libsyntax_ext/deriving/mod.rs
src/test/run-pass/deriving-hash.rs