Skip to content

Commit

Permalink
Auto merge of #33378 - oli-obk:fix/registry_args, r=Manishearth
Browse files Browse the repository at this point in the history
fix Registry::args for plugins loaded with --extra-plugins

r? @Manishearth
  • Loading branch information
bors committed May 20, 2016
2 parents 55cabda + 46de0fa commit 0352866
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/librustc_plugin/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/auxiliary/plugin_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 0352866

Please sign in to comment.