Auto merge of #33378 - oli-obk:fix/registry_args, r=Manishearth
fix Registry::args for plugins loaded with --extra-plugins r? @Manishearth
This commit is contained in:
commit
0352866da7
@ -92,8 +92,11 @@ impl<'a> Registry<'a> {
|
||||
/// ```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.
|
||||
|
@ -45,7 +45,7 @@ impl TTMacroExpander for Expander {
|
||||
|
||||
#[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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user