X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftools%2Fclippy%2Fclippy_lints%2Fsrc%2Fneedless_arbitrary_self_type.rs;h=9838d3cad9f02d537732033a0435ffa73281ea1f;hb=7a626cf7ce908a1c210cc91a043c4c4a23d42b62;hp=fe3c4455be5e210821463f7628fdcb5dcc950279;hpb=7c1283a0686893ee7d906168c40d905db909d3a3;p=rust.git diff --git a/src/tools/clippy/clippy_lints/src/needless_arbitrary_self_type.rs b/src/tools/clippy/clippy_lints/src/needless_arbitrary_self_type.rs index fe3c4455be5..9838d3cad9f 100644 --- a/src/tools/clippy/clippy_lints/src/needless_arbitrary_self_type.rs +++ b/src/tools/clippy/clippy_lints/src/needless_arbitrary_self_type.rs @@ -1,5 +1,4 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::in_macro; use if_chain::if_chain; use rustc_ast::ast::{BindingMode, Lifetime, Mutability, Param, PatKind, Path, TyKind}; use rustc_errors::Applicability; @@ -9,13 +8,13 @@ use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** The lint checks for `self` in fn parameters that + /// ### What it does + /// The lint checks for `self` in fn parameters that /// specify the `Self`-type explicitly - /// **Why is this bad?** Increases the amount and decreases the readability of code + /// ### Why is this bad? + /// Increases the amount and decreases the readability of code /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```rust /// enum ValType { /// I32, @@ -53,6 +52,7 @@ /// } /// } /// ``` + #[clippy::version = "1.47.0"] pub NEEDLESS_ARBITRARY_SELF_TYPE, complexity, "type of `self` parameter is already by default `Self`" @@ -78,7 +78,7 @@ fn check_param_inner(cx: &EarlyContext<'_>, path: &Path, span: Span, binding_mod let self_param = match (binding_mode, mutbl) { (Mode::Ref(None), Mutability::Mut) => "&mut self".to_string(), (Mode::Ref(Some(lifetime)), Mutability::Mut) => { - if in_macro(lifetime.ident.span) { + if lifetime.ident.span.from_expansion() { applicability = Applicability::HasPlaceholders; "&'_ mut self".to_string() } else { @@ -87,7 +87,7 @@ fn check_param_inner(cx: &EarlyContext<'_>, path: &Path, span: Span, binding_mod }, (Mode::Ref(None), Mutability::Not) => "&self".to_string(), (Mode::Ref(Some(lifetime)), Mutability::Not) => { - if in_macro(lifetime.ident.span) { + if lifetime.ident.span.from_expansion() { applicability = Applicability::HasPlaceholders; "&'_ self".to_string() } else { @@ -114,7 +114,7 @@ fn check_param_inner(cx: &EarlyContext<'_>, path: &Path, span: Span, binding_mod impl EarlyLintPass for NeedlessArbitrarySelfType { fn check_param(&mut self, cx: &EarlyContext<'_>, p: &Param) { // Bail out if the parameter it's not a receiver or was not written by the user - if !p.is_self() || in_macro(p.span) { + if !p.is_self() || p.span.from_expansion() { return; }