about summary refs log tree commit diff
path: root/src/librustc_session
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-05-30 23:08:49 +0200
committerGitHub <noreply@github.com>2020-05-30 23:08:49 +0200
commit320de71cdd016201d9ec6b1a214befccb36e0de5 (patch)
tree94d62744ec76cca7e83797fad3d56754e7195099 /src/librustc_session
parent5f0aefda49581aae96882552592a4881d2c099df (diff)
parentb12489248084f1ea33008e9b77ad2bbd41ee0f7f (diff)
Rollup merge of #72657 - flip1995:impl_lint_pass-ty, r=matthewjasper
Allow types (with lifetimes/generics) in impl_lint_pass

cc https://github.com/rust-lang/rust-clippy/pull/5279#discussion_r430790267

This allows to implement `LintPass` for types with lifetimes and/or generics. The only thing, I'm not sure of is the `LintPass::name` function, which now includes the lifetime(s) (which will be `'_` most of the time) in the name returned for the lint pass, if it exists. But I don't think that this should be a problem, since the `LintPass::name` is never used for output for the user (?).
Diffstat (limited to 'src/librustc_session')
-rw-r--r--src/librustc_session/lint.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/librustc_session/lint.rs b/src/librustc_session/lint.rs
index b16d513d923..8a66fac1e36 100644
--- a/src/librustc_session/lint.rs
+++ b/src/librustc_session/lint.rs
@@ -347,14 +347,14 @@ pub trait LintPass {
     fn name(&self) -> &'static str;
 }
 
-/// Implements `LintPass for $name` with the given list of `Lint` statics.
+/// Implements `LintPass for $ty` with the given list of `Lint` statics.
 #[macro_export]
 macro_rules! impl_lint_pass {
-    ($name:ident => [$($lint:expr),* $(,)?]) => {
-        impl $crate::lint::LintPass for $name {
-            fn name(&self) -> &'static str { stringify!($name) }
+    ($ty:ty => [$($lint:expr),* $(,)?]) => {
+        impl $crate::lint::LintPass for $ty {
+            fn name(&self) -> &'static str { stringify!($ty) }
         }
-        impl $name {
+        impl $ty {
             pub fn get_lints() -> $crate::lint::LintArray { $crate::lint_array!($($lint),*) }
         }
     };