fn expand_derive_invoc(&mut self, invoc: Invocation, ext: Rc<SyntaxExtension>) -> Expansion {
        let Invocation { expansion_kind: kind, .. } = invoc;
        let (attr, item) = match invoc.kind {
            InvocationKind::Derive { attr, item } => (attr, item),
            _ => unreachable!(),
        };

        attr::mark_used(&attr);
        let titem = derive_attr_trait(self.cx, &attr).unwrap();
        let tname = ast::Ident::with_empty_ctxt(titem.name().unwrap());
        let name = Symbol::intern(&format!("derive({})", tname));
        let mitem = &attr.value;

        self.cx.bt_push(ExpnInfo {
            call_site: attr.span,
            callee: NameAndSpan {
                format: MacroAttribute(attr.name()),
                span: Some(attr.span),
                allow_internal_unstable: false,
            }
        });

        match *ext {
            SyntaxExtension::ProcMacroDerive(ref ext) => {
                let span = Span {
                    expn_id: self.cx.codemap().record_expansion(ExpnInfo {
                        call_site: mitem.span,
                        callee: NameAndSpan {
                            format: MacroAttribute(Symbol::intern(&format!("derive({})", tname))),
                            span: None,
                            allow_internal_unstable: false,
                        },
                    }),
                    ..mitem.span
                };
                return kind.expect_from_annotatables(ext.expand(self.cx, span, &mitem, item));
            }
            SyntaxExtension::BuiltinDerive(func) => {
                let span = Span {
                    expn_id: self.cx.codemap().record_expansion(ExpnInfo {
                        call_site: titem.span,
                        callee: NameAndSpan {
                            format: MacroAttribute(name),
                            span: None,
                            allow_internal_unstable: true,
                        },
                    }),
                    ..titem.span
                };
                let mut items = Vec::new();
                func(self.cx, span, &mitem, &item, &mut |a| {
                    items.push(a)
                });
                items.insert(0, item);
                return kind.expect_from_annotatables(items);
            }
            _ => {
                let msg = &format!("macro `{}` may not be used for derive attributes", name);
                self.cx.span_err(attr.span, &msg);
                kind.dummy(attr.span)
            }
        }
    }
/// Expand a derive invocation. Returns the result of expansion.
Expand a derive invocation. Returns the result of expansion.
Expand a derive invocation . Returns the result of expansion .
fn expand_derive_invoc(&mut self, invoc: Invocation, ext: Rc<SyntaxExtension>) -> Expansion {
        let Invocation { expansion_kind: kind, .. } = invoc;
        let (attr, item) = match invoc.kind {
            InvocationKind::Derive { attr, item } => (attr, item),
            _ => unreachable!(),
        };
        attr::mark_used(&attr);
        let titem = derive_attr_trait(self.cx, &attr).unwrap();
        let tname = ast::Ident::with_empty_ctxt(titem.name().unwrap());
        let name = Symbol::intern(&format!("derive({})", tname));
        let mitem = &attr.value;
        self.cx.bt_push(ExpnInfo {
            call_site: attr.span,
            callee: NameAndSpan {
                format: MacroAttribute(attr.name()),
                span: Some(attr.span),
                allow_internal_unstable: false,
            }
        });
        match *ext {
            SyntaxExtension::ProcMacroDerive(ref ext) => {
                let span = Span {
                    expn_id: self.cx.codemap().record_expansion(ExpnInfo {
                        call_site: mitem.span,
                        callee: NameAndSpan {
                            format: MacroAttribute(Symbol::intern(&format!("derive({})", tname))),
                            span: None,
                            allow_internal_unstable: false,
                        },
                    }),
                    ..mitem.span
                };
                return kind.expect_from_annotatables(ext.expand(self.cx, span, &mitem, item));
            }
            SyntaxExtension::BuiltinDerive(func) => {
                let span = Span {
                    expn_id: self.cx.codemap().record_expansion(ExpnInfo {
                        call_site: titem.span,
                        callee: NameAndSpan {
                            format: MacroAttribute(name),
                            span: None,
                            allow_internal_unstable: true,
                        },
                    }),
                    ..titem.span
                };
                let mut items = Vec::new();
                func(self.cx, span, &mitem, &item, &mut |a| {
                    items.push(a)
                });
                items.insert(0, item);
                return kind.expect_from_annotatables(items);
            }
            _ => {
                let msg = &format!("macro `{}` may not be used for derive attributes", name);
                self.cx.span_err(attr.span, &msg);
                kind.dummy(attr.span)
            }
        }
    }
fn expand_derive_invoc ( & mut self , invoc : Invocation , ext : Rc < SyntaxExtension > ) -> Expansion { let Invocation { expansion_kind : kind , .. } = invoc ; let ( attr , item ) = match invoc . kind { InvocationKind :: Derive { attr , item } => ( attr , item ) , _ => unreachable ! ( ) , } ; attr :: mark_used ( & attr ) ; let titem = derive_attr_trait ( self . cx , & attr ) . unwrap ( ) ; let tname = ast :: Ident :: with_empty_ctxt ( titem . name ( ) . unwrap ( ) ) ; let name = Symbol :: intern ( & format ! ( " " tname ) ) ; let mitem = & attr . value ; self . cx . bt_push ( ExpnInfo { call_site : attr . span , callee : NameAndSpan { format : MacroAttribute ( attr . name ( ) ) , span : Some ( attr . span ) , allow_internal_unstable : false , } } ) ; match * ext { SyntaxExtension :: ProcMacroDerive ( ref ext ) => { let span = Span { expn_id : self . cx . codemap ( ) . record_expansion ( ExpnInfo { call_site : mitem . span , callee : NameAndSpan { format : MacroAttribute ( Symbol :: intern ( & format ! ( " " tname ) ) ) , span : None , allow_internal_unstable : false , } , } ) , .. mitem . span } ; return kind . expect_from_annotatables ( ext . expand ( self . cx , span , & mitem , item ) ) ; } SyntaxExtension :: BuiltinDerive ( func ) => { let span = Span { expn_id : self . cx . codemap ( ) . record_expansion ( ExpnInfo { call_site : titem . span , callee : NameAndSpan { format : MacroAttribute ( name ) , span : None , allow_internal_unstable : true , } , } ) , .. titem . span } ; let mut items = Vec :: new ( ) ; func ( self . cx , span , & mitem , & item , & mut | a | { items . push ( a ) } ) ; items . insert ( 0 , item ) ; return kind . expect_from_annotatables ( items ) ; } _ => { let msg = & format ! ( " " name ) ; self . cx . span_err ( attr . span , & msg ) ; kind . dummy ( attr . span ) } } }
Expand a derive invocation.
Expand a derive invocation .
&mut self
invoc
Invocation
ext
Rc<SyntaxExtension>
&mut self
invoc
Invocation
ext
Rc<SyntaxExtension>