Do not lint use_self
in proc macro expansion
This commit is contained in:
parent
5652ccbc0f
commit
c433d542cf
@ -1,6 +1,6 @@
|
||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::ty::same_type_and_consts;
|
||||
use clippy_utils::{meets_msrv, msrvs};
|
||||
use clippy_utils::{is_from_proc_macro, meets_msrv, msrvs};
|
||||
use if_chain::if_chain;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
@ -87,7 +87,7 @@ enum StackItem {
|
||||
const SEGMENTS_MSG: &str = "segments should be composed of at least 1 element";
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for UseSelf {
|
||||
fn check_item(&mut self, _cx: &LateContext<'_>, item: &Item<'_>) {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &Item<'tcx>) {
|
||||
if matches!(item.kind, ItemKind::OpaqueTy(_)) {
|
||||
// skip over `ItemKind::OpaqueTy` in order to lint `foo() -> impl <..>`
|
||||
return;
|
||||
@ -103,6 +103,7 @@ fn check_item(&mut self, _cx: &LateContext<'_>, item: &Item<'_>) {
|
||||
if parameters.as_ref().map_or(true, |params| {
|
||||
!params.parenthesized && !params.args.iter().any(|arg| matches!(arg, GenericArg::Lifetime(_)))
|
||||
});
|
||||
if !is_from_proc_macro(cx, item); // expensive, should be last check
|
||||
then {
|
||||
StackItem::Check {
|
||||
impl_id: item.def_id,
|
||||
|
@ -608,3 +608,12 @@ mod issue8845 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod issue6902 {
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub enum Foo {
|
||||
Bar = 1,
|
||||
}
|
||||
}
|
||||
|
@ -608,3 +608,12 @@ fn use_crate(&self) -> u8 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod issue6902 {
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub enum Foo {
|
||||
Bar = 1,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user