Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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