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 #137978.
This commit is contained in:
parent
89e93a51c8
commit
78599d83e7
43 changed files with 276 additions and 231 deletions
|
|
@ -111,8 +111,8 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones {
|
|||
// Only suggest if `clone_from`/`clone_into` is explicitly implemented
|
||||
&& resolved_assoc_items.in_definition_order().any(|assoc|
|
||||
match which_trait {
|
||||
CloneTrait::Clone => assoc.name == sym::clone_from,
|
||||
CloneTrait::ToOwned => assoc.name.as_str() == "clone_into",
|
||||
CloneTrait::Clone => assoc.name() == sym::clone_from,
|
||||
CloneTrait::ToOwned => assoc.name().as_str() == "clone_into",
|
||||
}
|
||||
)
|
||||
&& !clone_source_borrows_from_dest(cx, lhs, rhs.span)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &'_ Expr<'_>, self_expr: &'_ Exp
|
|||
&& let Ok(Some(fn_def)) = Instance::try_resolve(cx.tcx, cx.typing_env(), id, args)
|
||||
// find the provided definition of Iterator::last
|
||||
&& let Some(item) = cx.tcx.get_diagnostic_item(sym::Iterator)
|
||||
&& let Some(last_def) = cx.tcx.provided_trait_methods(item).find(|m| m.name.as_str() == "last")
|
||||
&& let Some(last_def) = cx.tcx.provided_trait_methods(item).find(|m| m.name().as_str() == "last")
|
||||
// if the resolved method is the same as the provided definition
|
||||
&& fn_def.def_id() == last_def.def_id
|
||||
{
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingTraitMethods {
|
|||
cx,
|
||||
MISSING_TRAIT_METHODS,
|
||||
cx.tcx.def_span(item.owner_id),
|
||||
format!("missing trait method provided by default: `{}`", assoc.name),
|
||||
format!("missing trait method provided by default: `{}`", assoc.name()),
|
||||
|diag| {
|
||||
diag.span_help(cx.tcx.def_span(assoc.def_id), "implement the method");
|
||||
},
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
|
|||
.associated_items(did)
|
||||
.in_definition_order()
|
||||
.filter(|assoc_item| assoc_item.is_fn())
|
||||
.map(|assoc_item| assoc_item.name)
|
||||
.map(|assoc_item| assoc_item.name())
|
||||
.collect()
|
||||
} else {
|
||||
BTreeSet::new()
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ impl UnconditionalRecursion {
|
|||
.in_definition_order()
|
||||
// We're not interested in foreign implementations of the `Default` trait.
|
||||
.find(|item| {
|
||||
item.is_fn() && item.def_id.is_local() && item.name == kw::Default
|
||||
item.is_fn() && item.def_id.is_local() && item.name() == kw::Default
|
||||
})
|
||||
&& let Some(body_node) = cx.tcx.hir_get_if_local(assoc_item.def_id)
|
||||
&& let Some(body_id) = body_node.body_id()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue