Skip to content

Commit c9992d6

Browse files
committedMay 1, 2025··
Merge commit '03a5b6b976ac121f4233775c49a4bce026065b47' into clippy-subtree-update
2 parents 6e23095 + 03a5b6b commit c9992d6

File tree

109 files changed

+1819
-582
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1819
-582
lines changed
 

‎src/tools/clippy/clippy_lints/src/assigning_clones.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ use clippy_utils::diagnostics::span_lint_and_then;
33
use clippy_utils::mir::{PossibleBorrowerMap, enclosing_mir};
44
use clippy_utils::msrvs::{self, Msrv};
55
use clippy_utils::sugg::Sugg;
6-
use clippy_utils::{is_diag_trait_item, is_in_test, last_path_segment, local_is_initialized, path_to_local};
6+
use clippy_utils::{is_diag_trait_item, is_in_test, last_path_segment, local_is_initialized, path_to_local, sym};
77
use rustc_errors::Applicability;
88
use rustc_hir::{self as hir, Expr, ExprKind};
99
use rustc_lint::{LateContext, LateLintPass};
1010
use rustc_middle::mir;
1111
use rustc_middle::ty::{self, Instance, Mutability};
1212
use rustc_session::impl_lint_pass;
13-
use rustc_span::symbol::sym;
1413
use rustc_span::{Span, SyntaxContext};
1514

1615
declare_clippy_lint! {
@@ -86,9 +85,9 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones {
8685
&& ctxt.is_root()
8786
&& let which_trait = match fn_name {
8887
sym::clone if is_diag_trait_item(cx, fn_id, sym::Clone) => CloneTrait::Clone,
89-
_ if fn_name.as_str() == "to_owned"
90-
&& is_diag_trait_item(cx, fn_id, sym::ToOwned)
91-
&& self.msrv.meets(cx, msrvs::CLONE_INTO) =>
88+
sym::to_owned
89+
if is_diag_trait_item(cx, fn_id, sym::ToOwned)
90+
&& self.msrv.meets(cx, msrvs::CLONE_INTO) =>
9291
{
9392
CloneTrait::ToOwned
9493
},
@@ -112,7 +111,7 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones {
112111
&& resolved_assoc_items.in_definition_order().any(|assoc|
113112
match which_trait {
114113
CloneTrait::Clone => assoc.name() == sym::clone_from,
115-
CloneTrait::ToOwned => assoc.name().as_str() == "clone_into",
114+
CloneTrait::ToOwned => assoc.name() == sym::clone_into,
116115
}
117116
)
118117
&& !clone_source_borrows_from_dest(cx, lhs, rhs.span)

‎src/tools/clippy/clippy_lints/src/attrs/blanket_clippy_restriction_lints.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
use super::BLANKET_CLIPPY_RESTRICTION_LINTS;
22
use super::utils::extract_clippy_lint;
33
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then};
4+
use clippy_utils::sym;
45
use rustc_ast::MetaItemInner;
56
use rustc_lint::{EarlyContext, Level, LintContext};
7+
use rustc_span::DUMMY_SP;
68
use rustc_span::symbol::Symbol;
7-
use rustc_span::{DUMMY_SP, sym};
89

910
pub(super) fn check(cx: &EarlyContext<'_>, name: Symbol, items: &[MetaItemInner]) {
1011
for lint in items {
11-
if let Some(lint_name) = extract_clippy_lint(lint)
12-
&& lint_name.as_str() == "restriction"
13-
&& name != sym::allow
14-
{
12+
if name != sym::allow && extract_clippy_lint(lint) == Some(sym::restriction) {
1513
span_lint_and_help(
1614
cx,
1715
BLANKET_CLIPPY_RESTRICTION_LINTS,

0 commit comments

Comments
 (0)
Please sign in to comment.