/// ```no_run
/// #![plugin(my_plugin_name(... args ...))]
/// ```
- pub fn args<'b>(&'b self) -> &'b Vec<P<ast::MetaItem>> {
- self.args_hidden.as_ref().expect("args not set")
+ ///
+ /// Returns empty slice in case the plugin was loaded
+ /// with `--extra-plugins`
+ pub fn args<'b>(&'b self) -> &'b [P<ast::MetaItem>] {
+ self.args_hidden.as_ref().map(|v| &v[..]).unwrap_or(&[])
}
/// Register a syntax extension of any kind.
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
- let args = reg.args().clone();
+ let args = reg.args().to_owned();
reg.register_syntax_extension(token::intern("plugin_args"),
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
NormalTT(Box::new(Expander { args: args, }), None, false));