Skip to content

Commit 4784074

Browse files
committed
Move name field from AssocItem to AssocKind variants.
To accurately reflect that RPITIT assoc items don't have a name. This avoids the use of `kw::Empty` to mean "no name", which is error prone. Helps with rust-lang#137978.
1 parent 67dc0d0 commit 4784074

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

clippy_lints/src/assigning_clones.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones {
111111
// Only suggest if `clone_from`/`clone_into` is explicitly implemented
112112
&& resolved_assoc_items.in_definition_order().any(|assoc|
113113
match which_trait {
114-
CloneTrait::Clone => assoc.name == sym::clone_from,
115-
CloneTrait::ToOwned => assoc.name.as_str() == "clone_into",
114+
CloneTrait::Clone => assoc.name() == sym::clone_from,
115+
CloneTrait::ToOwned => assoc.name().as_str() == "clone_into",
116116
}
117117
)
118118
&& !clone_source_borrows_from_dest(cx, lhs, rhs.span)

clippy_lints/src/methods/double_ended_iterator_last.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &'_ Expr<'_>, self_expr: &'_ Exp
2424
&& let Ok(Some(fn_def)) = Instance::try_resolve(cx.tcx, cx.typing_env(), id, args)
2525
// find the provided definition of Iterator::last
2626
&& let Some(item) = cx.tcx.get_diagnostic_item(sym::Iterator)
27-
&& let Some(last_def) = cx.tcx.provided_trait_methods(item).find(|m| m.name.as_str() == "last")
27+
&& let Some(last_def) = cx.tcx.provided_trait_methods(item).find(|m| m.name().as_str() == "last")
2828
// if the resolved method is the same as the provided definition
2929
&& fn_def.def_id() == last_def.def_id
3030
{

clippy_lints/src/missing_trait_methods.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingTraitMethods {
8181
cx,
8282
MISSING_TRAIT_METHODS,
8383
cx.tcx.def_span(item.owner_id),
84-
format!("missing trait method provided by default: `{}`", assoc.name),
84+
format!("missing trait method provided by default: `{}`", assoc.name()),
8585
|diag| {
8686
diag.span_help(cx.tcx.def_span(assoc.def_id), "implement the method");
8787
},

clippy_lints/src/same_name_method.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
8585
.associated_items(did)
8686
.in_definition_order()
8787
.filter(|assoc_item| assoc_item.is_fn())
88-
.map(|assoc_item| assoc_item.name)
88+
.map(|assoc_item| assoc_item.name())
8989
.collect()
9090
} else {
9191
BTreeSet::new()

clippy_lints/src/unconditional_recursion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ impl UnconditionalRecursion {
322322
.in_definition_order()
323323
// We're not interested in foreign implementations of the `Default` trait.
324324
.find(|item| {
325-
item.is_fn() && item.def_id.is_local() && item.name == kw::Default
325+
item.is_fn() && item.def_id.is_local() && item.name() == kw::Default
326326
})
327327
&& let Some(body_node) = cx.tcx.hir_get_if_local(assoc_item.def_id)
328328
&& let Some(body_id) = body_node.body_id()

0 commit comments

Comments
 (0)