Skip to content

Commit

Permalink
Move proc-macro crate check from register_lint to lint itself
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Aug 9, 2023
1 parent 0811fab commit dcea774
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 10 additions & 0 deletions src/atomic_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ impl_lint_pass!(AtomicContext<'_> => [ATOMIC_CONTEXT]);

impl<'tcx> LateLintPass<'tcx> for AtomicContext<'tcx> {
fn check_crate(&mut self, _: &LateContext<'tcx>) {
// Skip checks for proc-macro crates.
if self
.cx
.sess
.crate_types()
.contains(&rustc_session::config::CrateType::ProcMacro)
{
return;
}

use rustc_hir::intravisit as hir_visit;
use rustc_hir::*;

Expand Down
10 changes: 1 addition & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,7 @@ impl Callbacks for MyCallbacks {
original_optimized_mir(tcx, def_id)
};
});
config.register_lints = Some(Box::new(move |sess, lint_store| {
// Skip checks for proc-macro crates.
if sess
.crate_types()
.contains(&rustc_session::config::CrateType::ProcMacro)
{
return;
}

config.register_lints = Some(Box::new(move |_, lint_store| {
lint_store.register_lints(&[&INCORRECT_ATTRIBUTE]);
lint_store.register_lints(&[&infallible_allocation::INFALLIBLE_ALLOCATION]);
lint_store.register_lints(&[&atomic_context::ATOMIC_CONTEXT]);
Expand Down

0 comments on commit dcea774

Please sign in to comment.