Skip to content

Commit b074019

Browse files
committed
Rename trait_of_item -> trait_of_assoc
1 parent 31b6b66 commit b074019

17 files changed

+24
-24
lines changed

clippy_lints/src/dereference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
364364
// * `&self` methods on `&T` can have auto-borrow, but `&self` methods on `T` will take
365365
// priority.
366366
if let Some(fn_id) = typeck.type_dependent_def_id(hir_id)
367-
&& let Some(trait_id) = cx.tcx.trait_of_item(fn_id)
367+
&& let Some(trait_id) = cx.tcx.trait_of_assoc(fn_id)
368368
&& let arg_ty = cx.tcx.erase_regions(adjusted_ty)
369369
&& let ty::Ref(_, sub_ty, _) = *arg_ty.kind()
370370
&& let args =

clippy_lints/src/loops/needless_range_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ impl<'tcx> Visitor<'tcx> for VarVisitor<'_, 'tcx> {
317317
.cx
318318
.typeck_results()
319319
.type_dependent_def_id(expr.hir_id)
320-
.and_then(|def_id| self.cx.tcx.trait_of_item(def_id))
320+
.and_then(|def_id| self.cx.tcx.trait_of_assoc(def_id))
321321
&& ((meth.ident.name == sym::index && self.cx.tcx.lang_items().index_trait() == Some(trait_id))
322322
|| (meth.ident.name == sym::index_mut && self.cx.tcx.lang_items().index_mut_trait() == Some(trait_id)))
323323
&& !self.check(args_1, args_0, expr)

clippy_lints/src/methods/clone_on_copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(super) fn check(
2828
if cx
2929
.typeck_results()
3030
.type_dependent_def_id(expr.hir_id)
31-
.and_then(|id| cx.tcx.trait_of_item(id))
31+
.and_then(|id| cx.tcx.trait_of_assoc(id))
3232
.zip(cx.tcx.lang_items().clone_trait())
3333
.is_none_or(|(x, y)| x != y)
3434
{

clippy_lints/src/methods/iter_overeager_cloned.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ pub(super) fn check<'tcx>(
4444
let typeck = cx.typeck_results();
4545
if let Some(iter_id) = cx.tcx.get_diagnostic_item(sym::Iterator)
4646
&& let Some(method_id) = typeck.type_dependent_def_id(expr.hir_id)
47-
&& cx.tcx.trait_of_item(method_id) == Some(iter_id)
47+
&& cx.tcx.trait_of_assoc(method_id) == Some(iter_id)
4848
&& let Some(method_id) = typeck.type_dependent_def_id(cloned_call.hir_id)
49-
&& cx.tcx.trait_of_item(method_id) == Some(iter_id)
49+
&& cx.tcx.trait_of_assoc(method_id) == Some(iter_id)
5050
&& let cloned_recv_ty = typeck.expr_ty_adjusted(cloned_recv)
5151
&& let Some(iter_assoc_ty) = cx.get_associated_type(cloned_recv_ty, iter_id, sym::Item)
5252
&& matches!(*iter_assoc_ty.kind(), ty::Ref(_, ty, _) if !is_copy(cx, ty))

clippy_lints/src/methods/manual_str_repeat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub(super) fn check(
5959
&& is_type_lang_item(cx, cx.typeck_results().expr_ty(collect_expr), LangItem::String)
6060
&& let Some(take_id) = cx.typeck_results().type_dependent_def_id(take_expr.hir_id)
6161
&& let Some(iter_trait_id) = cx.tcx.get_diagnostic_item(sym::Iterator)
62-
&& cx.tcx.trait_of_item(take_id) == Some(iter_trait_id)
62+
&& cx.tcx.trait_of_assoc(take_id) == Some(iter_trait_id)
6363
&& let Some(repeat_kind) = parse_repeat_arg(cx, repeat_arg)
6464
&& let ctxt = collect_expr.span.ctxt()
6565
&& ctxt == take_expr.span.ctxt()

clippy_lints/src/methods/map_clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub(super) fn check(cx: &LateContext<'_>, e: &hir::Expr<'_>, recv: &hir::Expr<'_
6969
hir::ExprKind::MethodCall(method, obj, [], _) => {
7070
if ident_eq(name, obj) && method.ident.name == sym::clone
7171
&& let Some(fn_id) = cx.typeck_results().type_dependent_def_id(closure_expr.hir_id)
72-
&& let Some(trait_id) = cx.tcx.trait_of_item(fn_id)
72+
&& let Some(trait_id) = cx.tcx.trait_of_assoc(fn_id)
7373
&& cx.tcx.lang_items().clone_trait() == Some(trait_id)
7474
// no autoderefs
7575
&& !cx.typeck_results().expr_adjustments(obj).iter()

clippy_lints/src/methods/open_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn get_open_options(
111111
// This might be a user defined extension trait with a method like `truncate_write`
112112
// which would be a false positive
113113
if let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(argument.hir_id)
114-
&& cx.tcx.trait_of_item(method_def_id).is_some()
114+
&& cx.tcx.trait_of_assoc(method_def_id).is_some()
115115
{
116116
return false;
117117
}

clippy_lints/src/methods/str_splitn.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ fn parse_iter_usage<'tcx>(
286286
let iter_id = cx.tcx.get_diagnostic_item(sym::Iterator)?;
287287

288288
match (name.ident.name, args) {
289-
(sym::next, []) if cx.tcx.trait_of_item(did) == Some(iter_id) => (IterUsageKind::Nth(0), e.span),
289+
(sym::next, []) if cx.tcx.trait_of_assoc(did) == Some(iter_id) => (IterUsageKind::Nth(0), e.span),
290290
(sym::next_tuple, []) => {
291291
return if paths::ITERTOOLS_NEXT_TUPLE.matches(cx, did)
292292
&& let ty::Adt(adt_def, subs) = cx.typeck_results().expr_ty(e).kind()
@@ -303,7 +303,7 @@ fn parse_iter_usage<'tcx>(
303303
None
304304
};
305305
},
306-
(sym::nth | sym::skip, [idx_expr]) if cx.tcx.trait_of_item(did) == Some(iter_id) => {
306+
(sym::nth | sym::skip, [idx_expr]) if cx.tcx.trait_of_assoc(did) == Some(iter_id) => {
307307
if let Some(Constant::Int(idx)) = ConstEvalCtxt::new(cx).eval(idx_expr) {
308308
let span = if name.ident.as_str() == "nth" {
309309
e.span
@@ -312,7 +312,7 @@ fn parse_iter_usage<'tcx>(
312312
&& next_name.ident.name == sym::next
313313
&& next_expr.span.ctxt() == ctxt
314314
&& let Some(next_id) = cx.typeck_results().type_dependent_def_id(next_expr.hir_id)
315-
&& cx.tcx.trait_of_item(next_id) == Some(iter_id)
315+
&& cx.tcx.trait_of_assoc(next_id) == Some(iter_id)
316316
{
317317
next_expr.span
318318
} else {

clippy_lints/src/methods/unnecessary_fallible_conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub(super) fn check_method(cx: &LateContext<'_>, expr: &Expr<'_>) {
165165
pub(super) fn check_function(cx: &LateContext<'_>, expr: &Expr<'_>, callee: &Expr<'_>) {
166166
if let ExprKind::Path(ref qpath) = callee.kind
167167
&& let Some(item_def_id) = cx.qpath_res(qpath, callee.hir_id).opt_def_id()
168-
&& let Some(trait_def_id) = cx.tcx.trait_of_item(item_def_id)
168+
&& let Some(trait_def_id) = cx.tcx.trait_of_assoc(item_def_id)
169169
{
170170
let qpath_spans = match qpath {
171171
QPath::Resolved(_, path) => {

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ fn check_if_applicable_to_argument<'tcx>(cx: &LateContext<'tcx>, arg: &Expr<'tcx
734734
fn check_borrow_predicate<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>) {
735735
if let ExprKind::MethodCall(_, caller, &[arg], _) = expr.kind
736736
&& let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
737-
&& cx.tcx.trait_of_item(method_def_id).is_none()
737+
&& cx.tcx.trait_of_assoc(method_def_id).is_none()
738738
&& let Some(borrow_id) = cx.tcx.get_diagnostic_item(sym::Borrow)
739739
&& cx.tcx.predicates_of(method_def_id).predicates.iter().any(|(pred, _)| {
740740
if let ClauseKind::Trait(trait_pred) = pred.kind().skip_binder()

0 commit comments

Comments
 (0)