about summary refs log tree commit diff
path: root/src/libsyntax_ext
diff options
context:
space:
mode:
authorRyan Cumming <etaoins@gmail.com>2018-01-22 20:58:21 +1100
committerRyan Cumming <etaoins@gmail.com>2018-01-22 21:09:14 +1100
commite1bffbdf66cecc442e8d9e20642df82a155e2aa0 (patch)
tree20993bc098ba56634b9bba7c813269cff0a0be9b /src/libsyntax_ext
parentbc072ed0ca8e2e9f8c79fb04e85b47b5c0e8d6ae (diff)
downloadrust-e1bffbdf66cecc442e8d9e20642df82a155e2aa0.tar.gz
rust-e1bffbdf66cecc442e8d9e20642df82a155e2aa0.zip
Fix spurious warning on empty proc macro crates
While attempting to reproduce rust-lang/rust#47086 I noticed the
following warning:

```shell
> rustc /dev/null --crate-type proc-macro
warning: unused variable: `registrar`
 --> /dev/null:0:1
```

As there are no macros to register the automatically generated registrar
function for the crate has no body. As a result its `registrar` argument
is unused triggering the above warning.

The warning is confusing and not easily actionable by the developer. It
could also be triggered legitimately by e.g. having all of the macros in
a crate #[cfg]'ed out.

Fix by naming the generated argument `_registrar` inside
`mk_registrar()`. This suppresses the unused variable warning.
Diffstat (limited to 'src/libsyntax_ext')
-rw-r--r--src/libsyntax_ext/proc_macro_registrar.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsyntax_ext/proc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_registrar.rs
index 8c5276e1d74..0ba21e6b366 100644
--- a/src/libsyntax_ext/proc_macro_registrar.rs
+++ b/src/libsyntax_ext/proc_macro_registrar.rs
@@ -381,7 +381,7 @@ fn mk_registrar(cx: &mut ExtCtxt,
 
     let __internal = Ident::from_str("__internal");
     let registry = Ident::from_str("Registry");
-    let registrar = Ident::from_str("registrar");
+    let registrar = Ident::from_str("_registrar");
     let register_custom_derive = Ident::from_str("register_custom_derive");
     let register_attr_proc_macro = Ident::from_str("register_attr_proc_macro");
     let register_bang_proc_macro = Ident::from_str("register_bang_proc_macro");