Future proof libsyntax_ext for union.
This commit is contained in:
@@ -40,6 +40,7 @@ pub fn expand_deriving_copy(cx: &mut ExtCtxt,
|
|||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
supports_unions: true,
|
||||||
methods: Vec::new(),
|
methods: Vec::new(),
|
||||||
associated_types: Vec::new(),
|
associated_types: Vec::new(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
|
|||||||
additional_bounds: bounds,
|
additional_bounds: bounds,
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
supports_unions: false,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: "clone",
|
name: "clone",
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
|
|||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
supports_unions: false,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: "assert_receiver_is_total_eq",
|
name: "assert_receiver_is_total_eq",
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
|
|||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
supports_unions: false,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: "cmp",
|
name: "cmp",
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt,
|
|||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
supports_unions: false,
|
||||||
methods: methods,
|
methods: methods,
|
||||||
associated_types: Vec::new(),
|
associated_types: Vec::new(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt,
|
|||||||
additional_bounds: vec![],
|
additional_bounds: vec![],
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
supports_unions: false,
|
||||||
methods: methods,
|
methods: methods,
|
||||||
associated_types: Vec::new(),
|
associated_types: Vec::new(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ pub fn expand_deriving_debug(cx: &mut ExtCtxt,
|
|||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
supports_unions: false,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: "fmt",
|
name: "fmt",
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt,
|
|||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
supports_unions: false,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: "decode",
|
name: "decode",
|
||||||
generics: LifetimeBounds {
|
generics: LifetimeBounds {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt,
|
|||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
supports_unions: false,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: "default",
|
name: "default",
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt,
|
|||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
supports_unions: false,
|
||||||
methods: vec!(
|
methods: vec!(
|
||||||
MethodDef {
|
MethodDef {
|
||||||
name: "encode",
|
name: "encode",
|
||||||
|
|||||||
@@ -228,6 +228,9 @@ pub struct TraitDef<'a> {
|
|||||||
/// Is it an `unsafe` trait?
|
/// Is it an `unsafe` trait?
|
||||||
pub is_unsafe: bool,
|
pub is_unsafe: bool,
|
||||||
|
|
||||||
|
/// Can this trait be derived for unions?
|
||||||
|
pub supports_unions: bool,
|
||||||
|
|
||||||
pub methods: Vec<MethodDef<'a>>,
|
pub methods: Vec<MethodDef<'a>>,
|
||||||
|
|
||||||
pub associated_types: Vec<(ast::Ident, Ty<'a>)>,
|
pub associated_types: Vec<(ast::Ident, Ty<'a>)>,
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt,
|
|||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
supports_unions: false,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: "hash",
|
name: "hash",
|
||||||
generics: LifetimeBounds {
|
generics: LifetimeBounds {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ fn expand(cx: &mut ExtCtxt,
|
|||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
associated_types: vec![],
|
associated_types: vec![],
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
supports_unions: false,
|
||||||
methods: vec![
|
methods: vec![
|
||||||
MethodDef {
|
MethodDef {
|
||||||
name: "total_sum",
|
name: "total_sum",
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ fn expand(cx: &mut ExtCtxt,
|
|||||||
generics: LifetimeBounds::empty(),
|
generics: LifetimeBounds::empty(),
|
||||||
associated_types: vec![],
|
associated_types: vec![],
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
supports_unions: false,
|
||||||
methods: vec![
|
methods: vec![
|
||||||
MethodDef {
|
MethodDef {
|
||||||
name: "total_sum",
|
name: "total_sum",
|
||||||
|
|||||||
Reference in New Issue
Block a user