Skip to content

Commit 91084bf

Browse files
committed
meow sync
1 parent abd9dca commit 91084bf

File tree

3 files changed

+53
-46
lines changed

3 files changed

+53
-46
lines changed

compiler/rustc_lint/src/late.rs

+36-33
Original file line numberDiff line numberDiff line change
@@ -378,31 +378,31 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
378378

379379
// Now, we'll filtered passes in a way that discards any lint that
380380
let mut filtered_passes: Vec<Box<dyn LateLintPass<'tcx>>> = passes
381-
.into_iter()
382-
.filter(|pass| {
383-
let pass = LintPass::get_lints(pass);
384-
pass.iter().any(|&lint| {
385-
let lint_name =
386-
&lint.name.to_lowercase()
381+
.into_iter()
382+
.filter(|pass| {
383+
let pass = LintPass::get_lints(pass);
384+
pass.iter().any(|&lint| {
385+
let lint_name = &lint.name.to_lowercase()
387386
// Doing some calculations here to account for those separators
388-
[lint.name.find("::").unwrap_or(lint.name.len() - 2) + 2..].to_string();
389-
lints_to_emit.contains(&lint_name) || ( !lints_allowed.contains(&lint_name) && lint.default_level != crate::Level::Allow )
390-
})
391-
// if passes_lints[i].iter().any(|&lint| {
392-
// let symbol =
393-
// &lint.name.to_lowercase()
394-
// // Doing some calculations here to account for those separators
395-
// [lint.name.find("::").unwrap_or(lint.name.len() - 2) + 2..]
396-
397-
// // ^^^ Expensive, but more expensive would be having to
398-
// // cast every element to &str
399-
400-
401-
402-
// (!lints_allowed.contains(&lint.name)
403-
// && lint.default_level != crate::Level::Allow)
387+
[lint.name.find("::").unwrap_or(lint.name.len() - 2) + 2..]
388+
.to_string();
389+
lints_to_emit.contains(&lint_name)
390+
|| (!lints_allowed.contains(&lint_name)
391+
&& lint.default_level != crate::Level::Allow)
392+
})
393+
// if passes_lints[i].iter().any(|&lint| {
394+
// let symbol =
395+
// &lint.name.to_lowercase()
396+
// // Doing some calculations here to account for those separators
397+
// [lint.name.find("::").unwrap_or(lint.name.len() - 2) + 2..]
398+
399+
// // ^^^ Expensive, but more expensive would be having to
400+
// // cast every element to &str
401+
402+
// (!lints_allowed.contains(&lint.name)
403+
// && lint.default_level != crate::Level::Allow)
404404
})
405-
.collect();
405+
.collect();
406406

407407
filtered_passes.push(Box::new(builtin_lints));
408408

@@ -463,27 +463,30 @@ fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) {
463463
.filter(|pass| {
464464
let pass = LintPass::get_lints(pass);
465465
pass.iter().any(|&lint| {
466-
let lint_name =
467-
&lint.name.to_lowercase()
466+
lint.is_externally_loaded ||
467+
{
468+
let lint_name = &lint.name.to_lowercase()
468469
// Doing some calculations here to account for those separators
469-
[lint.name.find("::").unwrap_or(lint.name.len() - 2) + 2..].to_string();
470-
lints_to_emit.contains(&lint_name) ||
471-
(!lints_allowed.contains(lint_name) && lint.default_level != crate::Level::Allow)
470+
[lint.name.find("::").unwrap_or(lint.name.len() - 2) + 2..]
471+
.to_string();
472+
lints_to_emit.contains(&lint_name)
473+
|| (!lints_allowed.contains(lint_name)
474+
&& lint.default_level != crate::Level::Allow)
475+
}
472476
})
473-
// if passes_lints[i].iter().any(|&lint| {
474-
// let symbol =
477+
// if passes_lints[i].iter().any(|&lint| {
478+
// let symbol =
475479
// &lint.name.to_lowercase()
476480
// // Doing some calculations here to account for those separators
477481
// [lint.name.find("::").unwrap_or(lint.name.len() - 2) + 2..]
478482

479483
// // ^^^ Expensive, but more expensive would be having to
480484
// // cast every element to &str
481485

482-
483-
484486
// (!lints_allowed.contains(&lint.name)
485487
// && lint.default_level != crate::Level::Allow)
486-
}).collect();
488+
})
489+
.collect();
487490

488491
let pass = RuntimeCombinedLateLintPass { passes: &mut filtered_passes[..] };
489492
late_lint_crate_inner(tcx, context, pass);

compiler/rustc_lint/src/levels.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_ast as ast;
1717
use rustc_ast_pretty::pprust;
1818
use rustc_data_structures::{
1919
fx::FxIndexMap,
20-
sync::{join, par_for_each_in, Lock, Lrc},
20+
sync::{join, Lock, Lrc},
2121
};
2222
use rustc_errors::{Diag, DiagMessage, LintDiagnostic, MultiSpan};
2323
use rustc_feature::{Features, GateIssue};
@@ -491,11 +491,9 @@ impl<'tcx> LintLevelMinimum<'tcx> {
491491
fn process_opts(&mut self) {
492492
for (lint, level) in &self.tcx.sess.opts.lint_opts {
493493
if *level == Level::Allow {
494-
self.lints_allowed
495-
.with_lock(|lints_allowed| lints_allowed.push(lint.to_string()));
494+
self.lints_allowed.with_lock(|lints_allowed| lints_allowed.push(lint.to_string()));
496495
} else {
497-
self.lints_to_emit
498-
.with_lock(|lints_to_emit| lints_to_emit.push(lint.to_string()));
496+
self.lints_to_emit.with_lock(|lints_to_emit| lints_to_emit.push(lint.to_string()));
499497
}
500498
}
501499
}
@@ -504,18 +502,18 @@ impl<'tcx> LintLevelMinimum<'tcx> {
504502
join(
505503
|| {
506504
self.tcx.sess.psess.lints_that_can_emit.with_lock(|vec| {
507-
par_for_each_in(vec, |lint_symbol| {
505+
for lint_symbol in vec {
508506
self.lints_to_emit
509507
.with_lock(|lints_to_emit| lints_to_emit.push(lint_symbol.to_string()));
510-
});
508+
}
511509
});
512510
},
513511
|| {
514512
self.tcx.sess.psess.lints_allowed.with_lock(|vec| {
515-
par_for_each_in(vec, |lint_symbol| {
513+
for lint_symbol in vec {
516514
self.lints_allowed
517515
.with_lock(|lints_allowed| lints_allowed.push(lint_symbol.to_string()));
518-
});
516+
}
519517
});
520518
},
521519
);

compiler/rustc_parse/src/parser/attr.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,14 @@ impl<'a> Parser<'a> {
148148
if let ast::NestedMetaItem::MetaItem(ref meta_item) = meta_list {
149149
if meta_item.path.segments.len() == 1 {
150150
self.psess.lints_that_can_emit.with_lock(|lints_that_can_emit| {
151-
lints_that_can_emit.push(meta_list.ident().unwrap().name.as_str().to_string());
151+
lints_that_can_emit
152+
.push(meta_list.ident().unwrap().name.as_str().to_string());
152153
})
153154
} else {
154155
self.psess.lints_that_can_emit.with_lock(|lints_that_can_emit| {
155-
lints_that_can_emit.push(meta_item.path.segments[1].ident.name.as_str().to_string());
156+
lints_that_can_emit.push(
157+
meta_item.path.segments[1].ident.name.as_str().to_string(),
158+
);
156159
})
157160
}
158161
}
@@ -163,11 +166,14 @@ impl<'a> Parser<'a> {
163166
if let ast::NestedMetaItem::MetaItem(ref meta_item) = meta_list {
164167
if meta_item.path.segments.len() == 1 {
165168
self.psess.lints_allowed.with_lock(|lints_allowed| {
166-
lints_allowed.push(meta_list.name_or_empty().as_str().to_string())
169+
lints_allowed
170+
.push(meta_list.name_or_empty().as_str().to_string())
167171
})
168172
} else {
169173
self.psess.lints_allowed.with_lock(|lints_allowed| {
170-
lints_allowed.push(meta_item.path.segments[1].ident.name.as_str().to_string());
174+
lints_allowed.push(
175+
meta_item.path.segments[1].ident.name.as_str().to_string(),
176+
);
171177
})
172178
}
173179
}

0 commit comments

Comments
 (0)