Skip to content

Commit 748eccd

Browse files
Lints being from a plugin is dependent on the lint, not the registration
1 parent 2121b04 commit 748eccd

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

src/librustc/lint/context.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use syntax_pos::{MultiSpan, Span, symbol::Symbol};
5050
pub struct LintStore {
5151
/// Registered lints. The bool is true if the lint was
5252
/// added by a plugin.
53-
lints: Vec<(&'static Lint, bool)>,
53+
lints: Vec<&'static Lint>,
5454

5555
/// Trait objects for each lint pass.
5656
/// This is only `None` while performing a lint pass.
@@ -152,7 +152,7 @@ impl LintStore {
152152
}
153153
}
154154

155-
pub fn get_lints<'t>(&'t self) -> &'t [(&'static Lint, bool)] {
155+
pub fn get_lints<'t>(&'t self) -> &'t [&'static Lint] {
156156
&self.lints
157157
}
158158

@@ -169,33 +169,30 @@ impl LintStore {
169169
}
170170

171171
pub fn register_early_pass(&mut self,
172-
from_plugin: bool,
173172
register_only: bool,
174173
pass: EarlyLintPassObject) {
175-
self.push_lints(from_plugin, &pass.get_lints());
174+
self.push_lints(&pass.get_lints());
176175
if !register_only {
177176
self.early_passes.as_mut().unwrap().push(pass);
178177
}
179178
}
180179

181180
pub fn register_pre_expansion_pass(
182181
&mut self,
183-
from_plugin: bool,
184182
register_only: bool,
185183
pass: EarlyLintPassObject,
186184
) {
187-
self.push_lints(from_plugin, &pass.get_lints());
185+
self.push_lints(&pass.get_lints());
188186
if !register_only {
189187
self.pre_expansion_passes.as_mut().unwrap().push(pass);
190188
}
191189
}
192190

193191
pub fn register_late_pass(&mut self,
194-
from_plugin: bool,
195192
register_only: bool,
196193
per_module: bool,
197194
pass: LateLintPassObject) {
198-
self.push_lints(from_plugin, &pass.get_lints());
195+
self.push_lints(&pass.get_lints());
199196
if !register_only {
200197
if per_module {
201198
self.late_module_passes.push(pass);
@@ -206,9 +203,9 @@ impl LintStore {
206203
}
207204

208205
// Helper method for register_early/late_pass
209-
fn push_lints(&mut self, from_plugin: bool, lints: &[&'static Lint]) {
206+
fn push_lints(&mut self, lints: &[&'static Lint]) {
210207
for lint in lints {
211-
self.lints.push((lint, from_plugin));
208+
self.lints.push(lint);
212209

213210
let id = LintId::of(lint);
214211
if self.by_name.insert(lint.name_lower(), Id(id)).is_some() {

src/librustc/lint/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ pub struct Lint {
7676

7777
/// `true` if this lint is reported even inside expansions of external macros.
7878
pub report_in_external_macro: bool,
79+
80+
pub is_plugin: bool,
7981
}
8082

8183
impl Lint {
@@ -117,6 +119,7 @@ macro_rules! declare_lint {
117119
desc: $desc,
118120
edition_lint_opts: None,
119121
report_in_external_macro: $external,
122+
is_plugin: false,
120123
};
121124
);
122125
($vis: vis $NAME: ident, $Level: ident, $desc: expr,
@@ -128,6 +131,7 @@ macro_rules! declare_lint {
128131
desc: $desc,
129132
edition_lint_opts: Some(($lint_edition, $crate::lint::Level::$edition_level)),
130133
report_in_external_macro: false,
134+
is_plugin: false,
131135
};
132136
);
133137
}
@@ -156,6 +160,7 @@ macro_rules! declare_tool_lint {
156160
desc: $desc,
157161
edition_lint_opts: None,
158162
report_in_external_macro: $external,
163+
is_plugin: true,
159164
};
160165
);
161166
}

src/librustc_driver/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,7 @@ Available lint options:
835835
836836
");
837837

838-
fn sort_lints(sess: &Session, lints: Vec<(&'static Lint, bool)>) -> Vec<&'static Lint> {
839-
let mut lints: Vec<_> = lints.into_iter().map(|(x, _)| x).collect();
838+
fn sort_lints(sess: &Session, mut lints: Vec<&'static Lint>) -> Vec<&'static Lint> {
840839
// The sort doesn't case-fold but it's doubtful we care.
841840
lints.sort_by_cached_key(|x: &&Lint| (x.default_level(sess), x.name));
842841
lints
@@ -852,7 +851,7 @@ Available lint options:
852851
let (plugin, builtin): (Vec<_>, _) = lint_store.get_lints()
853852
.iter()
854853
.cloned()
855-
.partition(|&(_, p)| p);
854+
.partition(|&lint| lint.is_plugin);
856855
let plugin = sort_lints(sess, plugin);
857856
let builtin = sort_lints(sess, builtin);
858857

src/librustc_interface/passes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,10 @@ pub fn register_plugins<'a>(
299299

300300
let mut ls = sess.lint_store.borrow_mut();
301301
for pass in early_lint_passes {
302-
ls.register_early_pass(true, false, pass);
302+
ls.register_early_pass(false, pass);
303303
}
304304
for pass in late_lint_passes {
305-
ls.register_late_pass(true, false, false, pass);
305+
ls.register_late_pass(false, false, pass);
306306
}
307307

308308
for (name, (to, deprecated_name)) in lint_groups {

src/librustc_lint/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool)
205205

206206
macro_rules! register_pass {
207207
($method:ident, $constructor:expr, [$($args:expr),*]) => (
208-
store.$method(false, false, $($args,)* box $constructor);
208+
store.$method(false, $($args,)* box $constructor);
209209
)
210210
}
211211

@@ -224,16 +224,15 @@ pub fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool)
224224
late_lint_mod_passes!(register_passes, [register_late_pass, [true]]);
225225
} else {
226226
store.register_pre_expansion_pass(
227-
false,
228227
true,
229228
box BuiltinCombinedPreExpansionLintPass::new()
230229
);
231-
store.register_early_pass(false, true, box BuiltinCombinedEarlyLintPass::new());
230+
store.register_early_pass(true, box BuiltinCombinedEarlyLintPass::new());
232231
store.register_late_pass(
233-
false, true, true, box BuiltinCombinedModuleLateLintPass::new()
232+
true, true, box BuiltinCombinedModuleLateLintPass::new()
234233
);
235234
store.register_late_pass(
236-
false, true, false, box BuiltinCombinedLateLintPass::new()
235+
true, false, box BuiltinCombinedLateLintPass::new()
237236
);
238237
}
239238

@@ -492,9 +491,9 @@ pub fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool)
492491
}
493492

494493
pub fn register_internals(store: &mut lint::LintStore) {
495-
store.register_early_pass(false, false, box DefaultHashTypes::new());
496-
store.register_early_pass(false, false, box LintPassImpl);
497-
store.register_late_pass(false, false, false, box TyTyKind);
494+
store.register_early_pass(false, box DefaultHashTypes::new());
495+
store.register_early_pass(false, box LintPassImpl);
496+
store.register_late_pass(false, false, box TyTyKind);
498497
store.register_group(
499498
false,
500499
"rustc::internal",

0 commit comments

Comments
 (0)