From 02f081c0b53cad0bcfe1d20ebb892f06ffa996ff Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Mon, 29 Aug 2016 11:14:25 +0000 Subject: [PATCH] Future proof `libsyntax_ext` for `union`. --- src/libsyntax_ext/deriving/bounds.rs | 1 + src/libsyntax_ext/deriving/clone.rs | 1 + src/libsyntax_ext/deriving/cmp/eq.rs | 1 + src/libsyntax_ext/deriving/cmp/ord.rs | 1 + src/libsyntax_ext/deriving/cmp/partial_eq.rs | 1 + src/libsyntax_ext/deriving/cmp/partial_ord.rs | 1 + src/libsyntax_ext/deriving/debug.rs | 1 + src/libsyntax_ext/deriving/decodable.rs | 1 + src/libsyntax_ext/deriving/default.rs | 1 + src/libsyntax_ext/deriving/encodable.rs | 1 + src/libsyntax_ext/deriving/generic/mod.rs | 3 +++ src/libsyntax_ext/deriving/hash.rs | 1 + src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs | 1 + .../run-pass-fulldeps/auxiliary/custom_derive_plugin_attr.rs | 1 + 14 files changed, 16 insertions(+) diff --git a/src/libsyntax_ext/deriving/bounds.rs b/src/libsyntax_ext/deriving/bounds.rs index cfc98bf3687..efb2fe5eb3b 100644 --- a/src/libsyntax_ext/deriving/bounds.rs +++ b/src/libsyntax_ext/deriving/bounds.rs @@ -40,6 +40,7 @@ pub fn expand_deriving_copy(cx: &mut ExtCtxt, additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), is_unsafe: false, + supports_unions: true, methods: Vec::new(), associated_types: Vec::new(), }; diff --git a/src/libsyntax_ext/deriving/clone.rs b/src/libsyntax_ext/deriving/clone.rs index ce8ce2209d8..f1a3a1f41b1 100644 --- a/src/libsyntax_ext/deriving/clone.rs +++ b/src/libsyntax_ext/deriving/clone.rs @@ -80,6 +80,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt, additional_bounds: bounds, generics: LifetimeBounds::empty(), is_unsafe: false, + supports_unions: false, methods: vec![MethodDef { name: "clone", generics: LifetimeBounds::empty(), diff --git a/src/libsyntax_ext/deriving/cmp/eq.rs b/src/libsyntax_ext/deriving/cmp/eq.rs index 2515435abeb..425a47a991b 100644 --- a/src/libsyntax_ext/deriving/cmp/eq.rs +++ b/src/libsyntax_ext/deriving/cmp/eq.rs @@ -50,6 +50,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt, additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), is_unsafe: false, + supports_unions: false, methods: vec![MethodDef { name: "assert_receiver_is_total_eq", generics: LifetimeBounds::empty(), diff --git a/src/libsyntax_ext/deriving/cmp/ord.rs b/src/libsyntax_ext/deriving/cmp/ord.rs index 31194b04fa6..6b2e36e63b6 100644 --- a/src/libsyntax_ext/deriving/cmp/ord.rs +++ b/src/libsyntax_ext/deriving/cmp/ord.rs @@ -32,6 +32,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), is_unsafe: false, + supports_unions: false, methods: vec![MethodDef { name: "cmp", generics: LifetimeBounds::empty(), diff --git a/src/libsyntax_ext/deriving/cmp/partial_eq.rs b/src/libsyntax_ext/deriving/cmp/partial_eq.rs index f70e0cf4ac4..64b8829dad7 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_eq.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_eq.rs @@ -97,6 +97,7 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt, additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), is_unsafe: false, + supports_unions: false, methods: methods, associated_types: Vec::new(), }; diff --git a/src/libsyntax_ext/deriving/cmp/partial_ord.rs b/src/libsyntax_ext/deriving/cmp/partial_ord.rs index 9e9b2f02062..99d60c43c54 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_ord.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_ord.rs @@ -88,6 +88,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt, additional_bounds: vec![], generics: LifetimeBounds::empty(), is_unsafe: false, + supports_unions: false, methods: methods, associated_types: Vec::new(), }; diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index a31c695e360..b974699003b 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -35,6 +35,7 @@ pub fn expand_deriving_debug(cx: &mut ExtCtxt, additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), is_unsafe: false, + supports_unions: false, methods: vec![MethodDef { name: "fmt", generics: LifetimeBounds::empty(), diff --git a/src/libsyntax_ext/deriving/decodable.rs b/src/libsyntax_ext/deriving/decodable.rs index f395f7bd0c4..22b9eb8e754 100644 --- a/src/libsyntax_ext/deriving/decodable.rs +++ b/src/libsyntax_ext/deriving/decodable.rs @@ -62,6 +62,7 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt, additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), is_unsafe: false, + supports_unions: false, methods: vec![MethodDef { name: "decode", generics: LifetimeBounds { diff --git a/src/libsyntax_ext/deriving/default.rs b/src/libsyntax_ext/deriving/default.rs index 449c1ff066b..b15fd2b49a6 100644 --- a/src/libsyntax_ext/deriving/default.rs +++ b/src/libsyntax_ext/deriving/default.rs @@ -32,6 +32,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt, additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), is_unsafe: false, + supports_unions: false, methods: vec![MethodDef { name: "default", generics: LifetimeBounds::empty(), diff --git a/src/libsyntax_ext/deriving/encodable.rs b/src/libsyntax_ext/deriving/encodable.rs index 940fdf03771..a4074184b6e 100644 --- a/src/libsyntax_ext/deriving/encodable.rs +++ b/src/libsyntax_ext/deriving/encodable.rs @@ -138,6 +138,7 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt, additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), is_unsafe: false, + supports_unions: false, methods: vec!( MethodDef { name: "encode", diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index a8b682d8159..5c636d43a71 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -228,6 +228,9 @@ pub struct TraitDef<'a> { /// Is it an `unsafe` trait? pub is_unsafe: bool, + /// Can this trait be derived for unions? + pub supports_unions: bool, + pub methods: Vec>, pub associated_types: Vec<(ast::Ident, Ty<'a>)>, diff --git a/src/libsyntax_ext/deriving/hash.rs b/src/libsyntax_ext/deriving/hash.rs index 81c8e7112db..0941ebca868 100644 --- a/src/libsyntax_ext/deriving/hash.rs +++ b/src/libsyntax_ext/deriving/hash.rs @@ -36,6 +36,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt, additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), is_unsafe: false, + supports_unions: false, methods: vec![MethodDef { name: "hash", generics: LifetimeBounds { diff --git a/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs index 274e430bbea..6b688b006bd 100644 --- a/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs +++ b/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs @@ -49,6 +49,7 @@ fn expand(cx: &mut ExtCtxt, generics: LifetimeBounds::empty(), associated_types: vec![], is_unsafe: false, + supports_unions: false, methods: vec![ MethodDef { name: "total_sum", diff --git a/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin_attr.rs b/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin_attr.rs index 91b4b74797a..c6174745bfc 100644 --- a/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin_attr.rs +++ b/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin_attr.rs @@ -51,6 +51,7 @@ fn expand(cx: &mut ExtCtxt, generics: LifetimeBounds::empty(), associated_types: vec![], is_unsafe: false, + supports_unions: false, methods: vec![ MethodDef { name: "total_sum",