about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-10-07 16:52:53 -0400
committerMark Rousskov <mark.simulacrum@gmail.com>2019-10-17 19:16:41 -0400
commit748eccd48828e430b906ffa6bd3f6abdcc766dc9 (patch)
treeb35a9be093a54af5db1778cb86864082195d35ce /src
parent2121b04751702359f3bf03847040a9907ec2f66f (diff)
downloadrust-748eccd48828e430b906ffa6bd3f6abdcc766dc9.tar.gz
rust-748eccd48828e430b906ffa6bd3f6abdcc766dc9.zip
Lints being from a plugin is dependent on the lint, not the registration
Diffstat (limited to 'src')
-rw-r--r--src/librustc/lint/context.rs17
-rw-r--r--src/librustc/lint/mod.rs5
-rw-r--r--src/librustc_driver/lib.rs5
-rw-r--r--src/librustc_interface/passes.rs4
-rw-r--r--src/librustc_lint/lib.rs15
5 files changed, 23 insertions, 23 deletions
diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs
index c21c45b759c..37f577da8bb 100644
--- a/src/librustc/lint/context.rs
+++ b/src/librustc/lint/context.rs
@@ -50,7 +50,7 @@ use syntax_pos::{MultiSpan, Span, symbol::Symbol};
 pub struct LintStore {
     /// Registered lints. The bool is true if the lint was
     /// added by a plugin.
-    lints: Vec<(&'static Lint, bool)>,
+    lints: Vec<&'static Lint>,
 
     /// Trait objects for each lint pass.
     /// This is only `None` while performing a lint pass.
@@ -152,7 +152,7 @@ impl LintStore {
         }
     }
 
-    pub fn get_lints<'t>(&'t self) -> &'t [(&'static Lint, bool)] {
+    pub fn get_lints<'t>(&'t self) -> &'t [&'static Lint] {
         &self.lints
     }
 
@@ -169,10 +169,9 @@ impl LintStore {
     }
 
     pub fn register_early_pass(&mut self,
-                               from_plugin: bool,
                                register_only: bool,
                                pass: EarlyLintPassObject) {
-        self.push_lints(from_plugin, &pass.get_lints());
+        self.push_lints(&pass.get_lints());
         if !register_only {
             self.early_passes.as_mut().unwrap().push(pass);
         }
@@ -180,22 +179,20 @@ impl LintStore {
 
     pub fn register_pre_expansion_pass(
         &mut self,
-        from_plugin: bool,
         register_only: bool,
         pass: EarlyLintPassObject,
     ) {
-        self.push_lints(from_plugin, &pass.get_lints());
+        self.push_lints(&pass.get_lints());
         if !register_only {
             self.pre_expansion_passes.as_mut().unwrap().push(pass);
         }
     }
 
     pub fn register_late_pass(&mut self,
-                              from_plugin: bool,
                               register_only: bool,
                               per_module: bool,
                               pass: LateLintPassObject) {
-        self.push_lints(from_plugin, &pass.get_lints());
+        self.push_lints(&pass.get_lints());
         if !register_only {
             if per_module {
                 self.late_module_passes.push(pass);
@@ -206,9 +203,9 @@ impl LintStore {
     }
 
     // Helper method for register_early/late_pass
-    fn push_lints(&mut self, from_plugin: bool, lints: &[&'static Lint]) {
+    fn push_lints(&mut self, lints: &[&'static Lint]) {
         for lint in lints {
-            self.lints.push((lint, from_plugin));
+            self.lints.push(lint);
 
             let id = LintId::of(lint);
             if self.by_name.insert(lint.name_lower(), Id(id)).is_some() {
diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs
index 7443cca822a..455dc06a1ef 100644
--- a/src/librustc/lint/mod.rs
+++ b/src/librustc/lint/mod.rs
@@ -76,6 +76,8 @@ pub struct Lint {
 
     /// `true` if this lint is reported even inside expansions of external macros.
     pub report_in_external_macro: bool,
+
+    pub is_plugin: bool,
 }
 
 impl Lint {
@@ -117,6 +119,7 @@ macro_rules! declare_lint {
             desc: $desc,
             edition_lint_opts: None,
             report_in_external_macro: $external,
+            is_plugin: false,
         };
     );
     ($vis: vis $NAME: ident, $Level: ident, $desc: expr,
@@ -128,6 +131,7 @@ macro_rules! declare_lint {
             desc: $desc,
             edition_lint_opts: Some(($lint_edition, $crate::lint::Level::$edition_level)),
             report_in_external_macro: false,
+            is_plugin: false,
         };
     );
 }
@@ -156,6 +160,7 @@ macro_rules! declare_tool_lint {
             desc: $desc,
             edition_lint_opts: None,
             report_in_external_macro: $external,
+            is_plugin: true,
         };
     );
 }
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index f33cb4e215d..5af1e8faccc 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -835,8 +835,7 @@ Available lint options:
 
 ");
 
-    fn sort_lints(sess: &Session, lints: Vec<(&'static Lint, bool)>) -> Vec<&'static Lint> {
-        let mut lints: Vec<_> = lints.into_iter().map(|(x, _)| x).collect();
+    fn sort_lints(sess: &Session, mut lints: Vec<&'static Lint>) -> Vec<&'static Lint> {
         // The sort doesn't case-fold but it's doubtful we care.
         lints.sort_by_cached_key(|x: &&Lint| (x.default_level(sess), x.name));
         lints
@@ -852,7 +851,7 @@ Available lint options:
     let (plugin, builtin): (Vec<_>, _) = lint_store.get_lints()
                                                    .iter()
                                                    .cloned()
-                                                   .partition(|&(_, p)| p);
+                                                   .partition(|&lint| lint.is_plugin);
     let plugin = sort_lints(sess, plugin);
     let builtin = sort_lints(sess, builtin);
 
diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs
index 280ac45803b..2684650c3a9 100644
--- a/src/librustc_interface/passes.rs
+++ b/src/librustc_interface/passes.rs
@@ -299,10 +299,10 @@ pub fn register_plugins<'a>(
 
     let mut ls = sess.lint_store.borrow_mut();
     for pass in early_lint_passes {
-        ls.register_early_pass(true, false, pass);
+        ls.register_early_pass(false, pass);
     }
     for pass in late_lint_passes {
-        ls.register_late_pass(true, false, false, pass);
+        ls.register_late_pass(false, false, pass);
     }
 
     for (name, (to, deprecated_name)) in lint_groups {
diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs
index 5c70e9f8a1a..2c39ba02451 100644
--- a/src/librustc_lint/lib.rs
+++ b/src/librustc_lint/lib.rs
@@ -205,7 +205,7 @@ pub fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool)
 
     macro_rules! register_pass {
         ($method:ident, $constructor:expr, [$($args:expr),*]) => (
-            store.$method(false, false, $($args,)* box $constructor);
+            store.$method(false, $($args,)* box $constructor);
         )
     }
 
@@ -224,16 +224,15 @@ pub fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool)
         late_lint_mod_passes!(register_passes, [register_late_pass, [true]]);
     } else {
         store.register_pre_expansion_pass(
-            false,
             true,
             box BuiltinCombinedPreExpansionLintPass::new()
         );
-        store.register_early_pass(false, true, box BuiltinCombinedEarlyLintPass::new());
+        store.register_early_pass(true, box BuiltinCombinedEarlyLintPass::new());
         store.register_late_pass(
-            false, true, true, box BuiltinCombinedModuleLateLintPass::new()
+            true, true, box BuiltinCombinedModuleLateLintPass::new()
         );
         store.register_late_pass(
-            false, true, false, box BuiltinCombinedLateLintPass::new()
+            true, false, box BuiltinCombinedLateLintPass::new()
         );
     }
 
@@ -492,9 +491,9 @@ pub fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool)
 }
 
 pub fn register_internals(store: &mut lint::LintStore) {
-    store.register_early_pass(false, false, box DefaultHashTypes::new());
-    store.register_early_pass(false, false, box LintPassImpl);
-    store.register_late_pass(false, false, false, box TyTyKind);
+    store.register_early_pass(false, box DefaultHashTypes::new());
+    store.register_early_pass(false, box LintPassImpl);
+    store.register_late_pass(false, false, box TyTyKind);
     store.register_group(
         false,
         "rustc::internal",