Skip to content

Commit

Permalink
inconsistent_qualification: don't lint in macro definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Jun 24, 2024
1 parent aebc37f commit c3a4838
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/restriction/inconsistent_qualification/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ impl<'tcx> LateLintPass<'tcx> for InconsistentQualification {
fn check_path(&mut self, cx: &LateContext<'tcx>, path: &Path<'tcx>, hir_id: HirId) {
// smoelius: On the Dylint source code itself, simply checking
// `path.span.in_derive_expansion()` isn't sufficient to prevent false positives.
if !cx
.tcx
.hir()
.parent_iter(hir_id)
.any(|(hir_id, _)| cx.tcx.hir().span(hir_id).in_derive_expansion())
if !path.span.from_expansion()
&& !cx
.tcx
.hir()
.parent_iter(hir_id)
.any(|(hir_id, _)| cx.tcx.hir().span(hir_id).in_derive_expansion())
&& let node = cx.tcx.hir_node(hir_id)
&& !matches!(
node,
Expand Down
10 changes: 10 additions & 0 deletions examples/restriction/inconsistent_qualification/ui/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,13 @@ mod underscore_import {
}
}
}

macro_rules! check_ld_preload {
() => {
assert_eq!(Err(std::env::VarError::NotPresent), var("LD_PRELOAD"));
};
}

fn foo() {
check_ld_preload!();
}

0 comments on commit c3a4838

Please sign in to comment.