Auto merge of #11589 - koka831:fix/10198, r=giraffate
std_instead_of_core: avoid lint inside of proc-macro - fixes https://github.com/rust-lang/rust-clippy/issues/10198 note: The lint for the reported `thiserror::Error` has been suppressed by [Don't lint unstable moves in std_instead_of_core](https://github.com/rust-lang/rust-clippy/pull/9545/files#diff-2cb8a24429cf9d9898de901450d640115503a10454d692dddc6a073a299fbb7eR29) because `thiserror::Error` internally implements `std::error::Error for (derived struct)`. changelog: [`std_intead_of_core`]: avoid linting inside proc-macro I confirmed this change fixes the problem: <details> <summary>test result without the change</summary> ```console error: used import from `std` instead of `core` --> tests/ui/std_instead_of_core.rs:65:14 | LL | #[derive(ImplStructWithStdDisplay)] | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the derive macro `ImplStructWithStdDisplay` (in Nightly builds, run with -Z macro-backtrace for more info) ``` </details>
This commit is contained in:
commit
81400e2db8
5 changed files with 50 additions and 12 deletions
|
|
@ -1,9 +1,11 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::is_from_proc_macro;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{HirId, Path, PathSegment};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::symbol::kw;
|
||||
use rustc_span::{sym, Span};
|
||||
|
|
@ -99,6 +101,8 @@ impl<'tcx> LateLintPass<'tcx> for StdReexports {
|
|||
if let Res::Def(_, def_id) = path.res
|
||||
&& let Some(first_segment) = get_first_segment(path)
|
||||
&& is_stable(cx, def_id)
|
||||
&& !in_external_macro(cx.sess(), path.span)
|
||||
&& !is_from_proc_macro(cx, &first_segment.ident)
|
||||
{
|
||||
let (lint, used_mod, replace_with) = match first_segment.ident.name {
|
||||
sym::std => match cx.tcx.crate_name(def_id.krate) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue