<commit_before>use crate::utils::span_lint_and_help;
use if_chain::if_chain;
use rustc_ast::ast::{Param, TyKind};
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};

declare_clippy_lint! {
    /// **What it does:** The lint checks for `self` fn fn parameters that explicitly
    /// specify the `Self`-type explicitly
    /// **Why is this bad?** Increases the amount and decreases the readability of code
    ///
    /// **Known problems:** None
    ///
    /// **Example:**
    /// ```rust
    /// impl ValType {
    ///     pub fn bytes(self: Self) -> usize {
    ///         match self {
    ///             Self::I32 | Self::F32 => 4,
    ///             Self::I64 | Self::F64 => 8,
    ///         }
    ///     }
    /// }
    /// ```
    ///
    /// Could be rewritten as
    ///
    /// ```rust
    /// impl ValType {
    ///     pub fn bytes(self) -> usize {
    ///         match self {
    ///             Self::I32 | Self::F32 => 4,
    ///             Self::I64 | Self::F64 => 8,
    ///         }
    ///     }
    /// }
    /// ```
    pub NEEDLESS_FN_SELF_TYPE,
    style,
    "type of `self` parameter is already by default `Self`"
}

declare_lint_pass!(NeedlessFnSelfType => [NEEDLESS_FN_SELF_TYPE]);

impl EarlyLintPass for NeedlessFnSelfType {
    fn check_param(&mut self, cx: &EarlyContext<'_>, p: &Param) {
        if_chain! {
            if p.is_self();
            if let TyKind::Path(None, path) = &p.ty.kind;
            if let Some(segment) = path.segments.first();<commit_msg>fix doc<commit_after>use crate::utils::span_lint_and_help;
use if_chain::if_chain;
use rustc_ast::ast::{Param, TyKind};
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};

declare_clippy_lint! {
    /// **What it does:** The lint checks for `self` fn fn parameters that explicitly
    /// specify the `Self`-type explicitly
    /// **Why is this bad?** Increases the amount and decreases the readability of code
    ///
    /// **Known problems:** None
    ///
    /// **Example:**
    /// ```rust
    /// enum ValType {
    ///     I32,
    ///     I64,
    ///     F32,
    ///     F64,
    /// }
    ///
    /// impl ValType {
    ///     pub fn bytes(self: Self) -> usize {
    ///         match self {
    ///             Self::I32 | Self::F32 => 4,
    ///             Self::I64 | Self::F64 => 8,
    ///         }
    ///     }
    /// }
    /// ```
    ///
    /// Could be rewritten as
    ///
    /// ```rust
    /// enum ValType {
    ///     I32,
    ///     I64,
    ///     F32,
    ///     F64,
    /// }
    ///
    /// impl ValType {
    ///     pub fn bytes(self) -> usize {
    ///         match self {
    ///             Self::I32 | Self::F32 => 4,
    ///             Self::I64 | Self::F64 => 8,
    ///         }
    ///     }
    /// }
    /// ```
    pub NEEDLESS_FN_SELF_TYPE,
    style,
    "type of `self` parameter is already by default `Self`"
}

declare_lint_pass!(NeedlessFnSelfType => [NEEDLESS_FN_SELF_TYPE]);

impl EarlyLintPass for NeedlessFnSelfType {
    fn check_param(&mut self, cx: &EarlyContext<'_>, p: &Param) {
        if_chain! {
            if p.is_self();
            if let TyKind::Path(None, path) = &p.ty.kind;
            if let Some(segment) = path.segments.first();
{'fraction_non_alphanumeric': 0.17696460707858427, 'fraction_numerical': 0.016796640671865627, 'mean_word_length': 1.609546165884194, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7137755', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1095, 'n_words': 252}