Skip to content

MultiItemDecorator should take &Annotatable #25683

Closed
@Manishearth

Description

@Manishearth
pub trait ItemDecorator {
    fn expand(&self, ecx: &mut ExtCtxt, sp: Span, meta_item: &MetaItem, item: &Item, push: &mut FnMut(P<Item>));
}

is deprecated in favor of

pub trait MultiItemDecorator {
    fn expand(&self, ecx: &mut ExtCtxt, sp: Span, meta_item: &MetaItem, item: Annotatable, push: &mut FnMut(Annotatable));
}

The new version takes the thing being decorated by-move, and this is achieved by a clone. The clone is totally unnecessary; a decorator doesn't modify the original item and should be fine with a simple reference to it.

This probably causes a lot of unnecessary clones since MultiDecorators are used everywhere in the form of #[derive].

Should we make this &Annotatable and remove the clone?

cc @nrc @huonw

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-pluginsArea: compiler plugins, doc.rust-lang.org/nightly/unstable-book/language-features/plugin.htmlC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions