Skip to content

Commit 44b6aca

Browse files
committed
Avoid linting in external/proc macro
1 parent d38fa1a commit 44b6aca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

clippy_lints/src/std_instead_of_core.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
2+
use clippy_utils::is_from_proc_macro;
23
use rustc_errors::Applicability;
34
use rustc_hir::def::Res;
45
use rustc_hir::def_id::DefId;
56
use rustc_hir::{HirId, Path, PathSegment};
6-
use rustc_lint::{LateContext, LateLintPass};
7+
use rustc_lint::{LateContext, LateLintPass, LintContext};
8+
use rustc_middle::lint::in_external_macro;
79
use rustc_session::{declare_tool_lint, impl_lint_pass};
810
use rustc_span::symbol::kw;
911
use rustc_span::{sym, Span};
@@ -99,6 +101,8 @@ impl<'tcx> LateLintPass<'tcx> for StdReexports {
99101
if let Res::Def(_, def_id) = path.res
100102
&& let Some(first_segment) = get_first_segment(path)
101103
&& is_stable(cx, def_id)
104+
&& !in_external_macro(cx.sess(), path.span)
105+
&& !is_from_proc_macro(cx, &first_segment.ident)
102106
{
103107
let (lint, used_mod, replace_with) = match first_segment.ident.name {
104108
sym::std => match cx.tcx.crate_name(def_id.krate) {

0 commit comments

Comments
 (0)