diff options
| author | bors <bors@rust-lang.org> | 2016-05-20 08:44:01 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-05-20 08:44:01 -0700 |
| commit | 0352866da7098bdcc868fbc37246b48778ecf74a (patch) | |
| tree | 88b754ee08a8593f2977cf257d3e2879264be1d2 | |
| parent | 55cabda8d5bc023991aff7f53230a11a539dad80 (diff) | |
| parent | 46de0fadb54dbacd8598237d60ed2a91718806a9 (diff) | |
| download | rust-0352866da7098bdcc868fbc37246b48778ecf74a.tar.gz rust-0352866da7098bdcc868fbc37246b48778ecf74a.zip | |
Auto merge of #33378 - oli-obk:fix/registry_args, r=Manishearth
fix Registry::args for plugins loaded with --extra-plugins r? @Manishearth
| -rw-r--r-- | src/librustc_plugin/registry.rs | 7 | ||||
| -rw-r--r-- | src/test/run-pass-fulldeps/auxiliary/plugin_args.rs | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/librustc_plugin/registry.rs b/src/librustc_plugin/registry.rs index 3cfd6a76dda..dc5a38bb764 100644 --- a/src/librustc_plugin/registry.rs +++ b/src/librustc_plugin/registry.rs @@ -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. diff --git a/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs b/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs index f6e80266a15..99321ad4241 100644 --- a/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs +++ b/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs @@ -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)); |
