commit
334fb906ae
81 changed files with 160 additions and 140 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "clippy"
|
||||
version = "0.1.90"
|
||||
version = "0.1.91"
|
||||
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
|
||||
repository = "https://github.com/rust-lang/rust-clippy"
|
||||
readme = "README.md"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "clippy_config"
|
||||
version = "0.1.90"
|
||||
version = "0.1.91"
|
||||
edition = "2024"
|
||||
publish = false
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "clippy_lints"
|
||||
version = "0.1.90"
|
||||
version = "0.1.91"
|
||||
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
|
||||
repository = "https://github.com/rust-lang/rust-clippy"
|
||||
readme = "README.md"
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ use clippy_config::Conf;
|
|||
use clippy_utils::diagnostics::span_lint_and_help;
|
||||
use clippy_utils::msrvs::{self, Msrv};
|
||||
use rustc_ast::ast::{FloatTy, LitFloatType, LitKind};
|
||||
use rustc_attr_data_structures::RustcVersion;
|
||||
use rustc_hir::{HirId, Lit};
|
||||
use rustc_hir::{HirId, Lit, RustcVersion};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::impl_lint_pass;
|
||||
use rustc_span::{Span, symbol};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use clippy_config::types::{
|
|||
};
|
||||
use clippy_utils::diagnostics::span_lint_and_note;
|
||||
use clippy_utils::is_cfg_test;
|
||||
use rustc_attr_data_structures::AttributeKind;
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::{
|
||||
Attribute, FieldDef, HirId, ImplItemId, IsAuto, Item, ItemKind, Mod, OwnerId, QPath, TraitItemId, TyKind, Variant,
|
||||
VariantData,
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones {
|
|||
// That is overly conservative - the lint should fire even if there was no initializer,
|
||||
// but the variable has been initialized before `lhs` was evaluated.
|
||||
&& path_to_local(lhs).is_none_or(|lhs| local_is_initialized(cx, lhs))
|
||||
&& let Some(resolved_impl) = cx.tcx.impl_of_method(resolved_fn.def_id())
|
||||
&& let Some(resolved_impl) = cx.tcx.impl_of_assoc(resolved_fn.def_id())
|
||||
// Derived forms don't implement `clone_from`/`clone_into`.
|
||||
// See https://github.com/rust-lang/rust/pull/98445#issuecomment-1190681305
|
||||
&& !cx.tcx.is_builtin_derived(resolved_impl)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use super::INLINE_ALWAYS;
|
||||
use clippy_utils::diagnostics::span_lint;
|
||||
use rustc_attr_data_structures::{AttributeKind, InlineAttr, find_attr};
|
||||
use rustc_hir::Attribute;
|
||||
use rustc_hir::attrs::{AttributeKind, InlineAttr};
|
||||
use rustc_hir::{Attribute, find_attr};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::Symbol;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use rustc_attr_data_structures::{AttributeKind, ReprAttr, find_attr};
|
||||
use rustc_hir::Attribute;
|
||||
use rustc_hir::attrs::{AttributeKind, ReprAttr};
|
||||
use rustc_hir::{Attribute, find_attr};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::Span;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,9 @@ use clippy_utils::sugg::Sugg;
|
|||
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
||||
use clippy_utils::{eq_expr_value, sym};
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_attr_data_structures::RustcVersion;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::{FnKind, Visitor, walk_expr};
|
||||
use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, UnOp};
|
||||
use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, RustcVersion, UnOp};
|
||||
use rustc_lint::{LateContext, LateLintPass, Level};
|
||||
use rustc_session::impl_lint_pass;
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ fn is_used_as_unaligned(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
|
|||
ExprKind::MethodCall(name, self_arg, ..) if self_arg.hir_id == e.hir_id => {
|
||||
if matches!(name.ident.name, sym::read_unaligned | sym::write_unaligned)
|
||||
&& let Some(def_id) = cx.typeck_results().type_dependent_def_id(parent.hir_id)
|
||||
&& let Some(def_id) = cx.tcx.impl_of_method(def_id)
|
||||
&& let Some(def_id) = cx.tcx.impl_of_assoc(def_id)
|
||||
&& cx.tcx.type_of(def_id).instantiate_identity().is_raw_ptr()
|
||||
{
|
||||
true
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ fn get_const_name_and_ty_name(
|
|||
} else {
|
||||
return None;
|
||||
}
|
||||
} else if let Some(impl_id) = cx.tcx.impl_of_method(method_def_id)
|
||||
} else if let Some(impl_id) = cx.tcx.impl_of_assoc(method_def_id)
|
||||
&& let Some(ty_name) = get_primitive_ty_name(cx.tcx.type_of(impl_id).instantiate_identity())
|
||||
&& matches!(
|
||||
method_name,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use rustc_attr_data_structures::{AttributeKind, ReprAttr, find_attr};
|
||||
use rustc_hir::{HirId, Item, ItemKind};
|
||||
use rustc_hir::attrs::{AttributeKind, ReprAttr};
|
||||
use rustc_hir::{HirId, Item, ItemKind, find_attr};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::layout::LayoutOf;
|
||||
use rustc_middle::ty::{self, FieldDef};
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
|
|||
// * `&self` methods on `&T` can have auto-borrow, but `&self` methods on `T` will take
|
||||
// priority.
|
||||
if let Some(fn_id) = typeck.type_dependent_def_id(hir_id)
|
||||
&& let Some(trait_id) = cx.tcx.trait_of_item(fn_id)
|
||||
&& let Some(trait_id) = cx.tcx.trait_of_assoc(fn_id)
|
||||
&& let arg_ty = cx.tcx.erase_regions(adjusted_ty)
|
||||
&& let ty::Ref(_, sub_ty, _) = *arg_ty.kind()
|
||||
&& let args =
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use rustc_ast::AttrStyle;
|
||||
use rustc_ast::token::CommentKind;
|
||||
use rustc_attr_data_structures::AttributeKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::Attribute;
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::Span;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use rustc_attr_data_structures::AttributeKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::{Attribute, Item, ItemKind};
|
||||
use rustc_lint::LateContext;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ use clippy_utils::{
|
|||
get_path_from_caller_to_method_type, is_adjusted, is_no_std_crate, path_to_local, path_to_local_id,
|
||||
};
|
||||
use rustc_abi::ExternAbi;
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BindingMode, Expr, ExprKind, FnRetTy, GenericArgs, Param, PatKind, QPath, Safety, TyKind};
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::{BindingMode, Expr, ExprKind, FnRetTy, GenericArgs, Param, PatKind, QPath, Safety, TyKind, find_attr};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::source::indent_of;
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Item, ItemKind};
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::{Item, ItemKind, find_attr};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::declare_lint_pass;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::numeric_literal;
|
||||
use rustc_ast::ast::{self, LitFloatType, LitKind};
|
||||
use rustc_ast::ast::{LitFloatType, LitKind};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
|
|
@ -75,10 +75,10 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
|
|||
let digits = count_digits(sym_str);
|
||||
let max = max_digits(fty);
|
||||
let type_suffix = match lit_float_ty {
|
||||
LitFloatType::Suffixed(ast::FloatTy::F16) => Some("f16"),
|
||||
LitFloatType::Suffixed(ast::FloatTy::F32) => Some("f32"),
|
||||
LitFloatType::Suffixed(ast::FloatTy::F64) => Some("f64"),
|
||||
LitFloatType::Suffixed(ast::FloatTy::F128) => Some("f128"),
|
||||
LitFloatType::Suffixed(FloatTy::F16) => Some("f16"),
|
||||
LitFloatType::Suffixed(FloatTy::F32) => Some("f32"),
|
||||
LitFloatType::Suffixed(FloatTy::F64) => Some("f64"),
|
||||
LitFloatType::Suffixed(FloatTy::F128) => Some("f128"),
|
||||
LitFloatType::Unsuffixed => None,
|
||||
};
|
||||
let (is_whole, is_inf, mut float_str) = match fty {
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ use rustc_ast::{
|
|||
FormatArgPosition, FormatArgPositionKind, FormatArgsPiece, FormatArgumentKind, FormatCount, FormatOptions,
|
||||
FormatPlaceholder, FormatTrait,
|
||||
};
|
||||
use rustc_attr_data_structures::{AttributeKind, RustcVersion, find_attr};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_errors::SuggestionStyle::{CompletelyHidden, ShowCode};
|
||||
use rustc_hir::{Expr, ExprKind, LangItem};
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::{Expr, ExprKind, LangItem, RustcVersion, find_attr};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::ty::adjustment::{Adjust, Adjustment};
|
||||
use rustc_middle::ty::{self, GenericArg, List, TraitRef, Ty, TyCtxt, Upcast};
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ use clippy_utils::source::snippet_indent;
|
|||
use clippy_utils::ty::is_must_use_ty;
|
||||
use clippy_utils::visitors::for_each_expr_without_closures;
|
||||
use clippy_utils::{return_ty, trait_ref_of_method};
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::find_attr;
|
||||
use rustc_span::Symbol;
|
||||
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
|
||||
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ fn check_with_condition<'tcx>(
|
|||
ExprKind::Path(QPath::TypeRelative(_, name)) => {
|
||||
if name.ident.name == sym::MIN
|
||||
&& let Some(const_id) = cx.typeck_results().type_dependent_def_id(cond_num_val.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(const_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(const_id)
|
||||
&& let None = cx.tcx.impl_trait_ref(impl_id) // An inherent impl
|
||||
&& cx.tcx.type_of(impl_id).instantiate_identity().is_integral()
|
||||
{
|
||||
|
|
@ -350,7 +350,7 @@ fn check_with_condition<'tcx>(
|
|||
if let ExprKind::Path(QPath::TypeRelative(_, name)) = func.kind
|
||||
&& name.ident.name == sym::min_value
|
||||
&& let Some(func_id) = cx.typeck_results().type_dependent_def_id(func.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(func_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(func_id)
|
||||
&& let None = cx.tcx.impl_trait_ref(impl_id) // An inherent impl
|
||||
&& cx.tcx.type_of(impl_id).instantiate_identity().is_integral()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@ use clippy_config::Conf;
|
|||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::msrvs::Msrv;
|
||||
use clippy_utils::{is_in_const_context, is_in_test};
|
||||
use rustc_attr_data_structures::{RustcVersion, StabilityLevel, StableSince};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::{self as hir, AmbigArg, Expr, ExprKind, HirId, QPath};
|
||||
use rustc_hir::{self as hir, AmbigArg, Expr, ExprKind, HirId, QPath, RustcVersion, StabilityLevel, StableSince};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::impl_lint_pass;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::sugg::DiagExt;
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{TraitFn, TraitItem, TraitItemKind};
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::{TraitFn, TraitItem, TraitItemKind, find_attr};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::declare_lint_pass;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ extern crate rustc_abi;
|
|||
extern crate rustc_arena;
|
||||
extern crate rustc_ast;
|
||||
extern crate rustc_ast_pretty;
|
||||
extern crate rustc_attr_data_structures;
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_errors;
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ impl<'tcx> Visitor<'tcx> for VarVisitor<'_, 'tcx> {
|
|||
.cx
|
||||
.typeck_results()
|
||||
.type_dependent_def_id(expr.hir_id)
|
||||
.and_then(|def_id| self.cx.tcx.trait_of_item(def_id))
|
||||
.and_then(|def_id| self.cx.tcx.trait_of_assoc(def_id))
|
||||
&& ((meth.ident.name == sym::index && self.cx.tcx.lang_items().index_trait() == Some(trait_id))
|
||||
|| (meth.ident.name == sym::index_mut && self.cx.tcx.lang_items().index_mut_trait() == Some(trait_id)))
|
||||
&& !self.check(args_1, args_0, expr)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use clippy_utils::diagnostics::span_lint_hir_and_then;
|
||||
use clippy_utils::source::snippet;
|
||||
use hir::def::{DefKind, Res};
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{self as hir, AmbigArg};
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::{self as hir, AmbigArg, find_attr};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::impl_lint_pass;
|
||||
use rustc_span::Span;
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ use clippy_utils::is_doc_hidden;
|
|||
use clippy_utils::msrvs::{self, Msrv};
|
||||
use clippy_utils::source::snippet_indent;
|
||||
use itertools::Itertools;
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
|
||||
use rustc_hir::{Expr, ExprKind, Item, ItemKind, QPath, TyKind, VariantData};
|
||||
use rustc_hir::{Expr, ExprKind, Item, ItemKind, QPath, TyKind, VariantData, find_attr};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::impl_lint_pass;
|
||||
use rustc_span::Span;
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ impl<'a, 'tcx> SigDropChecker<'a, 'tcx> {
|
|||
if let Some(adt) = ty.ty_adt_def()
|
||||
&& get_attr(
|
||||
self.cx.sess(),
|
||||
self.cx.tcx.get_attrs_unchecked(adt.did()),
|
||||
self.cx.tcx.get_all_attrs(adt.did()),
|
||||
sym::has_significant_drop,
|
||||
)
|
||||
.count()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ pub(super) fn check<'tcx>(
|
|||
bytes_recv: &'tcx hir::Expr<'_>,
|
||||
) {
|
||||
if let Some(bytes_id) = cx.typeck_results().type_dependent_def_id(count_recv.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(bytes_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(bytes_id)
|
||||
&& cx.tcx.type_of(impl_id).instantiate_identity().is_str()
|
||||
&& let ty = cx.typeck_results().expr_ty(bytes_recv).peel_refs()
|
||||
&& (ty.is_str() || is_type_lang_item(cx, ty, hir::LangItem::String))
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ pub(super) fn check<'tcx>(
|
|||
}
|
||||
|
||||
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(method_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(method_id)
|
||||
&& cx.tcx.type_of(impl_id).instantiate_identity().is_str()
|
||||
&& let ExprKind::Lit(Spanned {
|
||||
node: LitKind::Str(ext_literal, ..),
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ pub(super) fn check(
|
|||
if cx
|
||||
.typeck_results()
|
||||
.type_dependent_def_id(expr.hir_id)
|
||||
.and_then(|id| cx.tcx.trait_of_item(id))
|
||||
.and_then(|id| cx.tcx.trait_of_assoc(id))
|
||||
.zip(cx.tcx.lang_items().clone_trait())
|
||||
.is_none_or(|(x, y)| x != y)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ pub(super) fn check<'tcx>(
|
|||
arg: &'tcx hir::Expr<'_>,
|
||||
) {
|
||||
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(method_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(method_id)
|
||||
&& let identity = cx.tcx.type_of(impl_id).instantiate_identity()
|
||||
&& let hir::ExprKind::Lit(Spanned {
|
||||
node: LitKind::Int(Pu128(0), _),
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ pub fn is_clone_like(cx: &LateContext<'_>, method_name: Symbol, method_def_id: h
|
|||
sym::to_string => is_diag_trait_item(cx, method_def_id, sym::ToString),
|
||||
sym::to_vec => cx
|
||||
.tcx
|
||||
.impl_of_method(method_def_id)
|
||||
.impl_of_assoc(method_def_id)
|
||||
.filter(|&impl_did| {
|
||||
cx.tcx.type_of(impl_did).instantiate_identity().is_slice() && cx.tcx.impl_trait_ref(impl_did).is_none()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ pub(super) fn check<'tcx>(
|
|||
let typeck = cx.typeck_results();
|
||||
if let Some(iter_id) = cx.tcx.get_diagnostic_item(sym::Iterator)
|
||||
&& let Some(method_id) = typeck.type_dependent_def_id(expr.hir_id)
|
||||
&& cx.tcx.trait_of_item(method_id) == Some(iter_id)
|
||||
&& cx.tcx.trait_of_assoc(method_id) == Some(iter_id)
|
||||
&& let Some(method_id) = typeck.type_dependent_def_id(cloned_call.hir_id)
|
||||
&& cx.tcx.trait_of_item(method_id) == Some(iter_id)
|
||||
&& cx.tcx.trait_of_assoc(method_id) == Some(iter_id)
|
||||
&& let cloned_recv_ty = typeck.expr_ty_adjusted(cloned_recv)
|
||||
&& let Some(iter_assoc_ty) = cx.get_associated_type(cloned_recv_ty, iter_id, sym::Item)
|
||||
&& matches!(*iter_assoc_ty.kind(), ty::Ref(_, ty, _) if !is_copy(cx, ty))
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ pub(super) fn check<'tcx>(
|
|||
map_expr: &'tcx Expr<'_>,
|
||||
) {
|
||||
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(method_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(method_id)
|
||||
&& is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id).instantiate_identity(), sym::Option)
|
||||
&& let ExprKind::Call(err_path, [err_arg]) = or_expr.kind
|
||||
&& is_res_lang_ctor(cx, path_res(cx, err_path), ResultErr)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ pub(super) fn check(
|
|||
&& is_type_lang_item(cx, cx.typeck_results().expr_ty(collect_expr), LangItem::String)
|
||||
&& let Some(take_id) = cx.typeck_results().type_dependent_def_id(take_expr.hir_id)
|
||||
&& let Some(iter_trait_id) = cx.tcx.get_diagnostic_item(sym::Iterator)
|
||||
&& cx.tcx.trait_of_item(take_id) == Some(iter_trait_id)
|
||||
&& cx.tcx.trait_of_assoc(take_id) == Some(iter_trait_id)
|
||||
&& let Some(repeat_kind) = parse_repeat_arg(cx, repeat_arg)
|
||||
&& let ctxt = collect_expr.span.ctxt()
|
||||
&& ctxt == take_expr.span.ctxt()
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ fn should_run_lint(cx: &LateContext<'_>, e: &hir::Expr<'_>, method_id: DefId) ->
|
|||
return true;
|
||||
}
|
||||
// We check if it's an `Option` or a `Result`.
|
||||
if let Some(id) = cx.tcx.impl_of_method(method_id) {
|
||||
if let Some(id) = cx.tcx.impl_of_assoc(method_id) {
|
||||
let identity = cx.tcx.type_of(id).instantiate_identity();
|
||||
if !is_type_diagnostic_item(cx, identity, sym::Option) && !is_type_diagnostic_item(cx, identity, sym::Result) {
|
||||
return false;
|
||||
|
|
@ -69,7 +69,7 @@ pub(super) fn check(cx: &LateContext<'_>, e: &hir::Expr<'_>, recv: &hir::Expr<'_
|
|||
hir::ExprKind::MethodCall(method, obj, [], _) => {
|
||||
if ident_eq(name, obj) && method.ident.name == sym::clone
|
||||
&& let Some(fn_id) = cx.typeck_results().type_dependent_def_id(closure_expr.hir_id)
|
||||
&& let Some(trait_id) = cx.tcx.trait_of_item(fn_id)
|
||||
&& let Some(trait_id) = cx.tcx.trait_of_assoc(fn_id)
|
||||
&& cx.tcx.lang_items().clone_trait() == Some(trait_id)
|
||||
// no autoderefs
|
||||
&& !cx.typeck_results().expr_adjustments(obj).iter()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use super::MAP_ERR_IGNORE;
|
|||
|
||||
pub(super) fn check(cx: &LateContext<'_>, e: &Expr<'_>, arg: &Expr<'_>) {
|
||||
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(e.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(method_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(method_id)
|
||||
&& is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id).instantiate_identity(), sym::Result)
|
||||
&& let ExprKind::Closure(&Closure {
|
||||
capture_clause: CaptureBy::Ref,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, ex: &'tcx Expr<'tcx>, recv: &'
|
|||
&& let (_, ref_depth, Mutability::Mut) = peel_mid_ty_refs_is_mutable(cx.typeck_results().expr_ty(recv))
|
||||
&& ref_depth >= 1
|
||||
&& let Some(method_id) = cx.typeck_results().type_dependent_def_id(ex.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(method_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(method_id)
|
||||
&& is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id).instantiate_identity(), sym::Mutex)
|
||||
{
|
||||
span_lint_and_sugg(
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ fn is_open_options(cx: &LateContext<'_>, ty: Ty<'_>) -> bool {
|
|||
|
||||
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, recv: &'tcx Expr<'_>) {
|
||||
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(e.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(method_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(method_id)
|
||||
&& is_open_options(cx, cx.tcx.type_of(impl_id).instantiate_identity())
|
||||
{
|
||||
let mut options = Vec::new();
|
||||
|
|
@ -111,7 +111,7 @@ fn get_open_options(
|
|||
// This might be a user defined extension trait with a method like `truncate_write`
|
||||
// which would be a false positive
|
||||
if let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(argument.hir_id)
|
||||
&& cx.tcx.trait_of_item(method_def_id).is_some()
|
||||
&& cx.tcx.trait_of_assoc(method_def_id).is_some()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use super::PATH_BUF_PUSH_OVERWRITE;
|
|||
|
||||
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, arg: &'tcx Expr<'_>) {
|
||||
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(method_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(method_id)
|
||||
&& is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id).instantiate_identity(), sym::PathBuf)
|
||||
&& let ExprKind::Lit(lit) = arg.kind
|
||||
&& let LitKind::Str(ref path_lit, _) = lit.node
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use super::STABLE_SORT_PRIMITIVE;
|
|||
|
||||
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, recv: &'tcx Expr<'_>) {
|
||||
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(e.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(method_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(method_id)
|
||||
&& cx.tcx.type_of(impl_id).instantiate_identity().is_slice()
|
||||
&& let Some(slice_type) = is_slice_of_primitives(cx, recv)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ fn parse_iter_usage<'tcx>(
|
|||
let iter_id = cx.tcx.get_diagnostic_item(sym::Iterator)?;
|
||||
|
||||
match (name.ident.name, args) {
|
||||
(sym::next, []) if cx.tcx.trait_of_item(did) == Some(iter_id) => (IterUsageKind::Nth(0), e.span),
|
||||
(sym::next, []) if cx.tcx.trait_of_assoc(did) == Some(iter_id) => (IterUsageKind::Nth(0), e.span),
|
||||
(sym::next_tuple, []) => {
|
||||
return if paths::ITERTOOLS_NEXT_TUPLE.matches(cx, did)
|
||||
&& let ty::Adt(adt_def, subs) = cx.typeck_results().expr_ty(e).kind()
|
||||
|
|
@ -303,7 +303,7 @@ fn parse_iter_usage<'tcx>(
|
|||
None
|
||||
};
|
||||
},
|
||||
(sym::nth | sym::skip, [idx_expr]) if cx.tcx.trait_of_item(did) == Some(iter_id) => {
|
||||
(sym::nth | sym::skip, [idx_expr]) if cx.tcx.trait_of_assoc(did) == Some(iter_id) => {
|
||||
if let Some(Constant::Int(idx)) = ConstEvalCtxt::new(cx).eval(idx_expr) {
|
||||
let span = if name.ident.as_str() == "nth" {
|
||||
e.span
|
||||
|
|
@ -312,7 +312,7 @@ fn parse_iter_usage<'tcx>(
|
|||
&& next_name.ident.name == sym::next
|
||||
&& next_expr.span.ctxt() == ctxt
|
||||
&& let Some(next_id) = cx.typeck_results().type_dependent_def_id(next_expr.hir_id)
|
||||
&& cx.tcx.trait_of_item(next_id) == Some(iter_id)
|
||||
&& cx.tcx.trait_of_assoc(next_id) == Some(iter_id)
|
||||
{
|
||||
next_expr.span
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use super::SUSPICIOUS_SPLITN;
|
|||
pub(super) fn check(cx: &LateContext<'_>, method_name: Symbol, expr: &Expr<'_>, self_arg: &Expr<'_>, count: u128) {
|
||||
if count <= 1
|
||||
&& let Some(call_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(call_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(call_id)
|
||||
&& cx.tcx.impl_trait_ref(impl_id).is_none()
|
||||
&& let self_ty = cx.tcx.type_of(impl_id).instantiate_identity()
|
||||
&& (self_ty.is_slice() || self_ty.is_str())
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ pub(super) fn check_method(cx: &LateContext<'_>, expr: &Expr<'_>) {
|
|||
pub(super) fn check_function(cx: &LateContext<'_>, expr: &Expr<'_>, callee: &Expr<'_>) {
|
||||
if let ExprKind::Path(ref qpath) = callee.kind
|
||||
&& let Some(item_def_id) = cx.qpath_res(qpath, callee.hir_id).opt_def_id()
|
||||
&& let Some(trait_def_id) = cx.tcx.trait_of_item(item_def_id)
|
||||
&& let Some(trait_def_id) = cx.tcx.trait_of_assoc(item_def_id)
|
||||
{
|
||||
let qpath_spans = match qpath {
|
||||
QPath::Resolved(_, path) => {
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ fn mirrored_exprs(a_expr: &Expr<'_>, a_ident: &Ident, b_expr: &Expr<'_>, b_ident
|
|||
|
||||
fn detect_lint(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, arg: &Expr<'_>) -> Option<LintTrigger> {
|
||||
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(method_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(method_id)
|
||||
&& cx.tcx.type_of(impl_id).instantiate_identity().is_slice()
|
||||
&& let ExprKind::Closure(&Closure { body, .. }) = arg.kind
|
||||
&& let closure_body = cx.tcx.hir_body(body)
|
||||
|
|
|
|||
|
|
@ -694,7 +694,7 @@ fn check_if_applicable_to_argument<'tcx>(cx: &LateContext<'tcx>, arg: &Expr<'tcx
|
|||
sym::to_string => cx.tcx.is_diagnostic_item(sym::to_string_method, method_def_id),
|
||||
sym::to_vec => cx
|
||||
.tcx
|
||||
.impl_of_method(method_def_id)
|
||||
.impl_of_assoc(method_def_id)
|
||||
.filter(|&impl_did| cx.tcx.type_of(impl_did).instantiate_identity().is_slice())
|
||||
.is_some(),
|
||||
_ => false,
|
||||
|
|
@ -734,7 +734,7 @@ fn check_if_applicable_to_argument<'tcx>(cx: &LateContext<'tcx>, arg: &Expr<'tcx
|
|||
fn check_borrow_predicate<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>) {
|
||||
if let ExprKind::MethodCall(_, caller, &[arg], _) = expr.kind
|
||||
&& let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
|
||||
&& cx.tcx.trait_of_item(method_def_id).is_none()
|
||||
&& cx.tcx.trait_of_assoc(method_def_id).is_none()
|
||||
&& let Some(borrow_id) = cx.tcx.get_diagnostic_item(sym::Borrow)
|
||||
&& cx.tcx.predicates_of(method_def_id).predicates.iter().any(|(pred, _)| {
|
||||
if let ClauseKind::Trait(trait_pred) = pred.kind().skip_binder()
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, call_name: Symbo
|
|||
applicability,
|
||||
);
|
||||
}
|
||||
} else if let Some(impl_id) = cx.tcx.impl_of_method(def_id)
|
||||
} else if let Some(impl_id) = cx.tcx.impl_of_assoc(def_id)
|
||||
&& let Some(adt) = cx.tcx.type_of(impl_id).instantiate_identity().ty_adt_def()
|
||||
&& matches!(cx.tcx.get_diagnostic_name(adt.did()), Some(sym::Option | sym::Result))
|
||||
{
|
||||
|
|
@ -131,7 +131,7 @@ fn is_calling_clone(cx: &LateContext<'_>, arg: &hir::Expr<'_>) -> bool {
|
|||
hir::ExprKind::MethodCall(method, obj, [], _) => {
|
||||
if method.ident.name == sym::clone
|
||||
&& let Some(fn_id) = cx.typeck_results().type_dependent_def_id(closure_expr.hir_id)
|
||||
&& let Some(trait_id) = cx.tcx.trait_of_item(fn_id)
|
||||
&& let Some(trait_id) = cx.tcx.trait_of_assoc(fn_id)
|
||||
// We check it's the `Clone` trait.
|
||||
&& cx.tcx.lang_items().clone_trait().is_some_and(|id| id == trait_id)
|
||||
// no autoderefs
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ pub(super) fn check<'tcx>(
|
|||
name_span: Span,
|
||||
) {
|
||||
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_method(method_id)
|
||||
&& let Some(impl_id) = cx.tcx.impl_of_assoc(method_id)
|
||||
&& is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id).instantiate_identity(), sym::Vec)
|
||||
&& let ExprKind::Lit(Spanned {
|
||||
node: LitKind::Int(Pu128(0), _),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use clippy_utils::diagnostics::span_lint;
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{self as hir, Attribute};
|
||||
use rustc_hir::{self as hir, Attribute, find_attr};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::ty::AssocItemContainer;
|
||||
use rustc_session::declare_lint_pass;
|
||||
|
|
|
|||
|
|
@ -417,7 +417,7 @@ fn replace_types<'tcx>(
|
|||
{
|
||||
let projection = projection_predicate
|
||||
.projection_term
|
||||
.with_self_ty(cx.tcx, new_ty)
|
||||
.with_replaced_self_ty(cx.tcx, new_ty)
|
||||
.expect_ty(cx.tcx)
|
||||
.to_ty(cx.tcx);
|
||||
|
||||
|
|
|
|||
|
|
@ -311,11 +311,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
|||
|
||||
/// Functions marked with these attributes must have the exact signature.
|
||||
pub(crate) fn requires_exact_signature(attrs: &[Attribute]) -> bool {
|
||||
attrs.iter().any(|attr| {
|
||||
[sym::proc_macro, sym::proc_macro_attribute, sym::proc_macro_derive]
|
||||
.iter()
|
||||
.any(|&allow| attr.has_name(allow))
|
||||
})
|
||||
attrs.iter().any(Attribute::is_proc_macro_attr)
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::source::{snippet, snippet_with_applicability};
|
||||
use rustc_abi::ExternAbi;
|
||||
use rustc_attr_data_structures::AttributeKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::{Attribute, Item, ItemKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::declare_lint_pass;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ fn check_op(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: bool)
|
|||
ExprKind::MethodCall(_, arg, [], _)
|
||||
if typeck
|
||||
.type_dependent_def_id(expr.hir_id)
|
||||
.and_then(|id| cx.tcx.trait_of_item(id))
|
||||
.and_then(|id| cx.tcx.trait_of_assoc(id))
|
||||
.is_some_and(|id| matches!(cx.tcx.get_diagnostic_name(id), Some(sym::ToString | sym::ToOwned))) =>
|
||||
{
|
||||
(arg, arg.span)
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ fn in_impl<'tcx>(
|
|||
bin_op: DefId,
|
||||
) -> Option<(&'tcx rustc_hir::Ty<'tcx>, &'tcx rustc_hir::Ty<'tcx>)> {
|
||||
if let Some(block) = get_enclosing_block(cx, e.hir_id)
|
||||
&& let Some(impl_def_id) = cx.tcx.impl_of_method(block.hir_id.owner.to_def_id())
|
||||
&& let Some(impl_def_id) = cx.tcx.impl_of_assoc(block.hir_id.owner.to_def_id())
|
||||
&& let item = cx.tcx.hir_expect_item(impl_def_id.expect_local())
|
||||
&& let ItemKind::Impl(item) = &item.kind
|
||||
&& let Some(of_trait) = &item.of_trait
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ use clippy_utils::ty::{for_each_top_level_late_bound_region, is_copy};
|
|||
use clippy_utils::{is_self, is_self_ty};
|
||||
use core::ops::ControlFlow;
|
||||
use rustc_abi::ExternAbi;
|
||||
use rustc_attr_data_structures::{AttributeKind, InlineAttr, find_attr};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::attrs::{AttributeKind, InlineAttr};
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
use rustc_hir::{BindingMode, Body, FnDecl, Impl, ItemKind, MutTy, Mutability, Node, PatKind};
|
||||
use rustc_hir::{BindingMode, Body, FnDecl, Impl, ItemKind, MutTy, Mutability, Node, PatKind, find_attr};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::adjustment::{Adjust, PointerCoercion};
|
||||
use rustc_middle::ty::layout::LayoutOf;
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ fn can_switch_ranges<'tcx>(
|
|||
if let ExprKind::MethodCall(_, receiver, _, _) = parent_expr.kind
|
||||
&& receiver.hir_id == use_ctxt.child_id
|
||||
&& let Some(method_did) = cx.typeck_results().type_dependent_def_id(parent_expr.hir_id)
|
||||
&& let Some(trait_did) = cx.tcx.trait_of_item(method_did)
|
||||
&& let Some(trait_did) = cx.tcx.trait_of_assoc(method_did)
|
||||
&& matches!(
|
||||
cx.tcx.get_diagnostic_name(trait_did),
|
||||
Some(sym::Iterator | sym::IntoIterator | sym::RangeBounds)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_help;
|
||||
use clippy_utils::ty::is_must_use_ty;
|
||||
use clippy_utils::{nth_arg, return_ty};
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
use rustc_hir::{Body, FnDecl, OwnerId, TraitItem, TraitItemKind};
|
||||
use rustc_hir::{Body, FnDecl, OwnerId, TraitItem, TraitItemKind, find_attr};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::Span;
|
||||
|
|
@ -113,7 +113,7 @@ impl<'tcx> LateLintPass<'tcx> for ReturnSelfNotMustUse {
|
|||
) {
|
||||
if matches!(kind, FnKind::Method(_, _))
|
||||
// We are only interested in methods, not in functions or associated functions.
|
||||
&& let Some(impl_def) = cx.tcx.impl_of_method(fn_def.to_def_id())
|
||||
&& let Some(impl_def) = cx.tcx.impl_of_assoc(fn_def.to_def_id())
|
||||
// We don't want this method to be te implementation of a trait because the
|
||||
// `#[must_use]` should be put on the trait definition directly.
|
||||
&& cx.tcx.trait_id_of_impl(impl_def).is_none()
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> {
|
|||
if let Some(adt) = ty.ty_adt_def() {
|
||||
let mut iter = get_attr(
|
||||
self.cx.sess(),
|
||||
self.cx.tcx.get_attrs_unchecked(adt.did()),
|
||||
self.cx.tcx.get_all_attrs(adt.did()),
|
||||
sym::has_significant_drop,
|
||||
);
|
||||
if iter.next().is_some() {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@ use clippy_config::Conf;
|
|||
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg};
|
||||
use clippy_utils::is_from_proc_macro;
|
||||
use clippy_utils::msrvs::Msrv;
|
||||
use rustc_attr_data_structures::{StabilityLevel, StableSince};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{Block, Body, HirId, Path, PathSegment};
|
||||
use rustc_hir::{Block, Body, HirId, Path, PathSegment, StabilityLevel, StableSince};
|
||||
use rustc_lint::{LateContext, LateLintPass, Lint, LintContext};
|
||||
use rustc_session::impl_lint_pass;
|
||||
use rustc_span::symbol::kw;
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ fn check_partial_eq(cx: &LateContext<'_>, method_span: Span, method_def_id: Loca
|
|||
let arg_ty = cx.typeck_results().expr_ty_adjusted(arg);
|
||||
|
||||
if let Some(fn_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
|
||||
&& let Some(trait_id) = cx.tcx.trait_of_item(fn_id)
|
||||
&& let Some(trait_id) = cx.tcx.trait_of_assoc(fn_id)
|
||||
&& trait_id == trait_def_id
|
||||
&& matches_ty(receiver_ty, arg_ty, self_arg, other_arg)
|
||||
{
|
||||
|
|
@ -250,7 +250,7 @@ fn check_to_string(cx: &LateContext<'_>, method_span: Span, method_def_id: Local
|
|||
let is_bad = match expr.kind {
|
||||
ExprKind::MethodCall(segment, _receiver, &[_arg], _) if segment.ident.name == name.name => {
|
||||
if let Some(fn_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
|
||||
&& let Some(trait_id) = cx.tcx.trait_of_item(fn_id)
|
||||
&& let Some(trait_id) = cx.tcx.trait_of_assoc(fn_id)
|
||||
&& trait_id == trait_def_id
|
||||
{
|
||||
true
|
||||
|
|
@ -318,7 +318,7 @@ where
|
|||
&& let ExprKind::Path(qpath) = f.kind
|
||||
&& is_default_method_on_current_ty(self.cx.tcx, qpath, self.implemented_ty_id)
|
||||
&& let Some(method_def_id) = path_def_id(self.cx, f)
|
||||
&& let Some(trait_def_id) = self.cx.tcx.trait_of_item(method_def_id)
|
||||
&& let Some(trait_def_id) = self.cx.tcx.trait_of_assoc(method_def_id)
|
||||
&& self.cx.tcx.is_diagnostic_item(sym::Default, trait_def_id)
|
||||
{
|
||||
span_error(self.cx, self.method_span, expr);
|
||||
|
|
@ -426,7 +426,7 @@ fn check_from(cx: &LateContext<'_>, method_span: Span, method_def_id: LocalDefId
|
|||
if let Some((fn_def_id, node_args)) = fn_def_id_with_node_args(cx, expr)
|
||||
&& let [s1, s2] = **node_args
|
||||
&& let (Some(s1), Some(s2)) = (s1.as_type(), s2.as_type())
|
||||
&& let Some(trait_def_id) = cx.tcx.trait_of_item(fn_def_id)
|
||||
&& let Some(trait_def_id) = cx.tcx.trait_of_assoc(fn_def_id)
|
||||
&& cx.tcx.is_diagnostic_item(sym::Into, trait_def_id)
|
||||
&& get_impl_trait_def_id(cx, method_def_id) == cx.tcx.get_diagnostic_item(sym::From)
|
||||
&& s1 == sig.inputs()[0]
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedIoAmount {
|
|||
/// get desugared to match.
|
||||
fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx hir::Block<'tcx>) {
|
||||
let fn_def_id = block.hir_id.owner.to_def_id();
|
||||
if let Some(impl_id) = cx.tcx.impl_of_method(fn_def_id)
|
||||
if let Some(impl_id) = cx.tcx.impl_of_assoc(fn_def_id)
|
||||
&& let Some(trait_id) = cx.tcx.trait_id_of_impl(impl_id)
|
||||
{
|
||||
// We don't want to lint inside io::Read or io::Write implementations, as the author has more
|
||||
|
|
@ -300,7 +300,7 @@ fn check_io_mode(cx: &LateContext<'_>, call: &hir::Expr<'_>) -> Option<IoOp> {
|
|||
};
|
||||
|
||||
if let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(call.hir_id)
|
||||
&& let Some(trait_def_id) = cx.tcx.trait_of_item(method_def_id)
|
||||
&& let Some(trait_def_id) = cx.tcx.trait_of_assoc(method_def_id)
|
||||
{
|
||||
if let Some(diag_name) = cx.tcx.get_diagnostic_name(trait_def_id) {
|
||||
match diag_name {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use rustc_hir::{
|
|||
FnRetTy, HirId, Lit, PatExprKind, PatKind, QPath, StmtKind, StructTailExpr,
|
||||
};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::ty::{FloatTy, IntTy, UintTy};
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::symbol::{Ident, Symbol};
|
||||
use std::cell::Cell;
|
||||
|
|
@ -337,15 +338,43 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
|||
LitKind::Byte(b) => kind!("Byte({b})"),
|
||||
LitKind::Int(i, suffix) => {
|
||||
let int_ty = match suffix {
|
||||
LitIntType::Signed(int_ty) => format!("LitIntType::Signed(IntTy::{int_ty:?})"),
|
||||
LitIntType::Unsigned(uint_ty) => format!("LitIntType::Unsigned(UintTy::{uint_ty:?})"),
|
||||
LitIntType::Signed(int_ty) => {
|
||||
let t = match int_ty {
|
||||
IntTy::Isize => "Isize",
|
||||
IntTy::I8 => "I8",
|
||||
IntTy::I16 => "I16",
|
||||
IntTy::I32 => "I32",
|
||||
IntTy::I64 => "I64",
|
||||
IntTy::I128 => "I128",
|
||||
};
|
||||
format!("LitIntType::Signed(IntTy::{t})")
|
||||
},
|
||||
LitIntType::Unsigned(uint_ty) => {
|
||||
let t = match uint_ty {
|
||||
UintTy::Usize => "Usize",
|
||||
UintTy::U8 => "U8",
|
||||
UintTy::U16 => "U16",
|
||||
UintTy::U32 => "U32",
|
||||
UintTy::U64 => "U64",
|
||||
UintTy::U128 => "U128",
|
||||
};
|
||||
format!("LitIntType::Unsigned(UintTy::{t})")
|
||||
},
|
||||
LitIntType::Unsuffixed => String::from("LitIntType::Unsuffixed"),
|
||||
};
|
||||
kind!("Int({i}, {int_ty})");
|
||||
},
|
||||
LitKind::Float(_, suffix) => {
|
||||
let float_ty = match suffix {
|
||||
LitFloatType::Suffixed(suffix_ty) => format!("LitFloatType::Suffixed(FloatTy::{suffix_ty:?})"),
|
||||
LitFloatType::Suffixed(suffix_ty) => {
|
||||
let t = match suffix_ty {
|
||||
FloatTy::F16 => "F16",
|
||||
FloatTy::F32 => "F32",
|
||||
FloatTy::F64 => "F64",
|
||||
FloatTy::F128 => "F128",
|
||||
};
|
||||
format!("LitFloatType::Suffixed(FloatTy::{t})")
|
||||
},
|
||||
LitFloatType::Unsuffixed => String::from("LitFloatType::Unsuffixed"),
|
||||
};
|
||||
kind!("Float(_, {float_ty})");
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ use clippy_utils::diagnostics::span_lint;
|
|||
use clippy_utils::paths;
|
||||
use rustc_ast::tokenstream::{TokenStream, TokenTree};
|
||||
use rustc_ast::{AttrStyle, DelimArgs};
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::{
|
||||
AttrArgs, AttrItem, AttrPath, Attribute, HirId, Impl, Item, ItemKind, Path, QPath, TraitRef, Ty, TyKind,
|
||||
AttrArgs, AttrItem, AttrPath, Attribute, HirId, Impl, Item, ItemKind, Path, QPath, TraitRef, Ty, TyKind, find_attr,
|
||||
};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_lint_defs::declare_tool_lint;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
#![allow(clippy::missing_clippy_version_attribute)]
|
||||
|
||||
extern crate rustc_ast;
|
||||
extern crate rustc_attr_data_structures;
|
||||
extern crate rustc_attr_parsing;
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_errors;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "clippy_utils"
|
||||
version = "0.1.90"
|
||||
version = "0.1.91"
|
||||
edition = "2024"
|
||||
description = "Helpful tools for writing lints, provided as they are used in Clippy"
|
||||
repository = "https://github.com/rust-lang/rust-clippy"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ This crate is only guaranteed to build with this `nightly` toolchain:
|
|||
|
||||
<!-- begin autogenerated nightly -->
|
||||
```
|
||||
nightly-2025-07-25
|
||||
nightly-2025-08-07
|
||||
```
|
||||
<!-- end autogenerated nightly -->
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ use crate::source::SpanRangeExt;
|
|||
use crate::{sym, tokenize_with_text};
|
||||
use rustc_ast::attr;
|
||||
use rustc_ast::attr::AttributeExt;
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::find_attr;
|
||||
use rustc_lexer::TokenKind;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::{AdtDef, TyCtxt};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::{clip, is_direct_expn_of, sext, unsext};
|
|||
use rustc_abi::Size;
|
||||
use rustc_apfloat::Float;
|
||||
use rustc_apfloat::ieee::{Half, Quad};
|
||||
use rustc_ast::ast::{self, LitFloatType, LitKind};
|
||||
use rustc_ast::ast::{LitFloatType, LitKind};
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::{
|
||||
BinOpKind, Block, ConstBlock, Expr, ExprKind, HirId, Item, ItemKind, Node, PatExpr, PatExprKind, QPath, UnOp,
|
||||
|
|
@ -309,10 +309,10 @@ pub fn lit_to_mir_constant<'tcx>(lit: &LitKind, ty: Option<Ty<'tcx>>) -> Constan
|
|||
LitKind::Int(n, _) => Constant::Int(n.get()),
|
||||
LitKind::Float(ref is, LitFloatType::Suffixed(fty)) => match fty {
|
||||
// FIXME(f16_f128): just use `parse()` directly when available for `f16`/`f128`
|
||||
ast::FloatTy::F16 => Constant::parse_f16(is.as_str()),
|
||||
ast::FloatTy::F32 => Constant::F32(is.as_str().parse().unwrap()),
|
||||
ast::FloatTy::F64 => Constant::F64(is.as_str().parse().unwrap()),
|
||||
ast::FloatTy::F128 => Constant::parse_f128(is.as_str()),
|
||||
FloatTy::F16 => Constant::parse_f16(is.as_str()),
|
||||
FloatTy::F32 => Constant::F32(is.as_str().parse().unwrap()),
|
||||
FloatTy::F64 => Constant::F64(is.as_str().parse().unwrap()),
|
||||
FloatTy::F128 => Constant::parse_f128(is.as_str()),
|
||||
},
|
||||
LitKind::Float(ref is, LitFloatType::Unsuffixed) => match ty.expect("type of float is known").kind() {
|
||||
ty::Float(FloatTy::F16) => Constant::parse_f16(is.as_str()),
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ impl ops::BitOrAssign for EagernessSuggestion {
|
|||
fn fn_eagerness(cx: &LateContext<'_>, fn_id: DefId, name: Symbol, have_one_arg: bool) -> EagernessSuggestion {
|
||||
use EagernessSuggestion::{Eager, Lazy, NoChange};
|
||||
|
||||
let ty = match cx.tcx.impl_of_method(fn_id) {
|
||||
let ty = match cx.tcx.impl_of_assoc(fn_id) {
|
||||
Some(id) => cx.tcx.type_of(id).instantiate_identity(),
|
||||
None => return Lazy,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
extern crate indexmap;
|
||||
extern crate rustc_abi;
|
||||
extern crate rustc_ast;
|
||||
extern crate rustc_attr_data_structures;
|
||||
extern crate rustc_attr_parsing;
|
||||
extern crate rustc_const_eval;
|
||||
extern crate rustc_data_structures;
|
||||
|
|
@ -91,11 +90,11 @@ use itertools::Itertools;
|
|||
use rustc_abi::Integer;
|
||||
use rustc_ast::ast::{self, LitKind, RangeLimits};
|
||||
use rustc_ast::join_path_syms;
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::packed::Pu128;
|
||||
use rustc_data_structures::unhash::UnindexMap;
|
||||
use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk};
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
|
||||
use rustc_hir::definitions::{DefPath, DefPathData};
|
||||
|
|
@ -106,7 +105,7 @@ use rustc_hir::{
|
|||
CoroutineKind, Destination, Expr, ExprField, ExprKind, FnDecl, FnRetTy, GenericArg, GenericArgs, HirId, Impl,
|
||||
ImplItem, ImplItemKind, Item, ItemKind, LangItem, LetStmt, MatchSource, Mutability, Node, OwnerId, OwnerNode,
|
||||
Param, Pat, PatExpr, PatExprKind, PatKind, Path, PathSegment, QPath, Stmt, StmtKind, TraitFn, TraitItem,
|
||||
TraitItemKind, TraitRef, TyKind, UnOp, def,
|
||||
TraitItemKind, TraitRef, TyKind, UnOp, def, find_attr,
|
||||
};
|
||||
use rustc_lexer::{FrontmatterAllowed, TokenKind, tokenize};
|
||||
use rustc_lint::{LateContext, Level, Lint, LintContext};
|
||||
|
|
@ -349,7 +348,7 @@ pub fn is_ty_alias(qpath: &QPath<'_>) -> bool {
|
|||
/// Checks if the given method call expression calls an inherent method.
|
||||
pub fn is_inherent_method_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
||||
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) {
|
||||
cx.tcx.trait_of_item(method_id).is_none()
|
||||
cx.tcx.trait_of_assoc(method_id).is_none()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
@ -357,7 +356,7 @@ pub fn is_inherent_method_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
|||
|
||||
/// Checks if a method is defined in an impl of a diagnostic item
|
||||
pub fn is_diag_item_method(cx: &LateContext<'_>, def_id: DefId, diag_item: Symbol) -> bool {
|
||||
if let Some(impl_did) = cx.tcx.impl_of_method(def_id)
|
||||
if let Some(impl_did) = cx.tcx.impl_of_assoc(def_id)
|
||||
&& let Some(adt) = cx.tcx.type_of(impl_did).instantiate_identity().ty_adt_def()
|
||||
{
|
||||
return cx.tcx.is_diagnostic_item(diag_item, adt.did());
|
||||
|
|
@ -367,7 +366,7 @@ pub fn is_diag_item_method(cx: &LateContext<'_>, def_id: DefId, diag_item: Symbo
|
|||
|
||||
/// Checks if a method is in a diagnostic item trait
|
||||
pub fn is_diag_trait_item(cx: &LateContext<'_>, def_id: DefId, diag_item: Symbol) -> bool {
|
||||
if let Some(trait_did) = cx.tcx.trait_of_item(def_id) {
|
||||
if let Some(trait_did) = cx.tcx.trait_of_assoc(def_id) {
|
||||
return cx.tcx.is_diagnostic_item(diag_item, trait_did);
|
||||
}
|
||||
false
|
||||
|
|
@ -620,7 +619,7 @@ fn is_default_equivalent_ctor(cx: &LateContext<'_>, def_id: DefId, path: &QPath<
|
|||
|
||||
if let QPath::TypeRelative(_, method) = path
|
||||
&& method.ident.name == sym::new
|
||||
&& let Some(impl_did) = cx.tcx.impl_of_method(def_id)
|
||||
&& let Some(impl_did) = cx.tcx.impl_of_assoc(def_id)
|
||||
&& let Some(adt) = cx.tcx.type_of(impl_did).instantiate_identity().ty_adt_def()
|
||||
{
|
||||
return std_types_symbols.iter().any(|&symbol| {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ pub fn is_format_macro(cx: &LateContext<'_>, macro_def_id: DefId) -> bool {
|
|||
} else {
|
||||
// Allow users to tag any macro as being format!-like
|
||||
// TODO: consider deleting FORMAT_MACRO_DIAG_ITEMS and using just this method
|
||||
get_unique_attr(cx.sess(), cx.tcx.get_attrs_unchecked(macro_def_id), sym::format_args).is_some()
|
||||
get_unique_attr(cx.sess(), cx.tcx.get_all_attrs(macro_def_id), sym::format_args).is_some()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::sym;
|
||||
use rustc_ast::Attribute;
|
||||
use rustc_ast::attr::AttributeExt;
|
||||
use rustc_attr_data_structures::RustcVersion;
|
||||
use rustc_attr_parsing::parse_version;
|
||||
use rustc_hir::RustcVersion;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::Symbol;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
use crate::msrvs::{self, Msrv};
|
||||
use hir::LangItem;
|
||||
use rustc_attr_data_structures::{RustcVersion, StableSince};
|
||||
use rustc_const_eval::check_consts::ConstCx;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{RustcVersion, StableSince};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_infer::traits::Obligation;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
@ -420,11 +420,11 @@ pub fn is_stable_const_fn(cx: &LateContext<'_>, def_id: DefId, msrv: Msrv) -> bo
|
|||
.lookup_const_stability(def_id)
|
||||
.or_else(|| {
|
||||
cx.tcx
|
||||
.trait_of_item(def_id)
|
||||
.trait_of_assoc(def_id)
|
||||
.and_then(|trait_def_id| cx.tcx.lookup_const_stability(trait_def_id))
|
||||
})
|
||||
.is_none_or(|const_stab| {
|
||||
if let rustc_attr_data_structures::StabilityLevel::Stable { since, .. } = const_stab.level {
|
||||
if let rustc_hir::StabilityLevel::Stable { since, .. } = const_stab.level {
|
||||
// Checking MSRV is manually necessary because `rustc` has no such concept. This entire
|
||||
// function could be removed if `rustc` provided a MSRV-aware version of `is_stable_const_fn`.
|
||||
// as a part of an unimplemented MSRV check https://github.com/rust-lang/rust/issues/65262.
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ use core::ops::ControlFlow;
|
|||
use itertools::Itertools;
|
||||
use rustc_abi::VariantIdx;
|
||||
use rustc_ast::ast::Mutability;
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{Expr, FnDecl, LangItem, TyKind};
|
||||
use rustc_hir::{Expr, FnDecl, LangItem, TyKind, find_attr};
|
||||
use rustc_hir_analysis::lower_ty;
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "declare_clippy_lint"
|
||||
version = "0.1.90"
|
||||
version = "0.1.91"
|
||||
edition = "2024"
|
||||
repository = "https://github.com/rust-lang/rust-clippy"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[toolchain]
|
||||
# begin autogenerated nightly
|
||||
channel = "nightly-2025-07-25"
|
||||
channel = "nightly-2025-08-07"
|
||||
# end autogenerated nightly
|
||||
components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
|
||||
profile = "minimal"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ error: unnecessary structure name repetition
|
|||
note: the lint level is defined here
|
||||
--> src/main.rs:6:9
|
||||
|
|
||||
6 | #![deny(clippy::use_self)]
|
||||
6 | #![deny(clippy::use_self)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ error: file is loaded as a module multiple times: `src/b.rs`
|
|||
error: file is loaded as a module multiple times: `src/c.rs`
|
||||
--> src/main.rs:7:1
|
||||
|
|
||||
7 | mod c;
|
||||
7 | mod c;
|
||||
| ^^^^^^ first loaded here
|
||||
8 | / #[path = "c.rs"]
|
||||
9 | | mod c2;
|
||||
8 | / #[path = "c.rs"]
|
||||
9 | | mod c2;
|
||||
| |_______^ loaded again here
|
||||
10 | / #[path = "c.rs"]
|
||||
11 | | mod c3;
|
||||
|
|
@ -44,8 +44,8 @@ error: file is loaded as a module multiple times: `src/from_other_module.rs`
|
|||
|
|
||||
::: src/other_module/mod.rs:1:1
|
||||
|
|
||||
1 | / #[path = "../from_other_module.rs"]
|
||||
2 | | mod m;
|
||||
1 | / #[path = "../from_other_module.rs"]
|
||||
2 | | mod m;
|
||||
| |______^ loaded again here
|
||||
|
|
||||
= help: replace all but one `mod` item with `use` items
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
error: lint group `rust_2018_idioms` has the same priority (0) as a lint
|
||||
--> Cargo.toml:7:1
|
||||
|
|
||||
7 | rust_2018_idioms = "warn"
|
||||
7 | rust_2018_idioms = "warn"
|
||||
| ^^^^^^^^^^^^^^^^ ------ has an implicit priority of 0
|
||||
...
|
||||
12 | unused_attributes = { level = "allow" }
|
||||
|
|
@ -11,8 +11,8 @@ error: lint group `rust_2018_idioms` has the same priority (0) as a lint
|
|||
= note: `#[deny(clippy::lint_groups_priority)]` on by default
|
||||
help: to have lints override the group set `rust_2018_idioms` to a lower priority
|
||||
|
|
||||
7 - rust_2018_idioms = "warn"
|
||||
7 + rust_2018_idioms = { level = "warn", priority = -1 }
|
||||
7 - rust_2018_idioms = "warn"
|
||||
7 + rust_2018_idioms = { level = "warn", priority = -1 }
|
||||
|
|
||||
|
||||
error: lint group `unused` has the same priority (0) as a lint
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ error: this `match` arm has a differing case than its expression
|
|||
LL | "~!@#$%^&*()-_=+Foo" => {},
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: consider changing the case of this arm to respect `to_ascii_lowercase` (notice the capitalization difference)
|
||||
help: consider changing the case of this arm to respect `to_ascii_lowercase` (notice the capitalization)
|
||||
|
|
||||
LL - "~!@#$%^&*()-_=+Foo" => {},
|
||||
LL + "~!@#$%^&*()-_=+foo" => {},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue