Skip to content

Commit 9554045

Browse files
committed
Auto merge of rust-lang#107753 - kylematsuda:type-of, r=BoxyUwU
Switch to `EarlyBinder` for `type_of` query Part of the work to finish rust-lang#105779 and implement rust-lang/types-team#78. Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `type_of` query and removes `bound_type_of`. r? `@lcnr`
2 parents cc60e21 + 98c4a49 commit 9554045

Some content is hidden

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

42 files changed

+58
-54
lines changed

clippy_lints/src/casts/cast_ptr_alignment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn is_used_as_unaligned(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
6666
if matches!(name.ident.as_str(), "read_unaligned" | "write_unaligned")
6767
&& let Some(def_id) = cx.typeck_results().type_dependent_def_id(parent.hir_id)
6868
&& let Some(def_id) = cx.tcx.impl_of_method(def_id)
69-
&& cx.tcx.type_of(def_id).is_unsafe_ptr()
69+
&& cx.tcx.type_of(def_id).subst_identity().is_unsafe_ptr()
7070
{
7171
true
7272
} else {

clippy_lints/src/copy_iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'tcx> LateLintPass<'tcx> for CopyIterator {
4343
of_trait: Some(ref trait_ref),
4444
..
4545
}) = item.kind;
46-
let ty = cx.tcx.type_of(item.owner_id);
46+
let ty = cx.tcx.type_of(item.owner_id).subst_identity();
4747
if is_copy(cx, ty);
4848
if let Some(trait_id) = trait_ref.trait_def_id();
4949
if cx.tcx.is_diagnostic_item(sym::Iterator, trait_id);

clippy_lints/src/default.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl<'tcx> LateLintPass<'tcx> for Default {
150150
.fields
151151
.iter()
152152
.all(|field| {
153-
is_copy(cx, cx.tcx.type_of(field.did))
153+
is_copy(cx, cx.tcx.type_of(field.did).subst_identity())
154154
});
155155
if !has_drop(cx, binding_type) || all_fields_are_copy;
156156
then {

clippy_lints/src/default_numeric_fallback.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
167167
.iter()
168168
.find_map(|f_def| {
169169
if f_def.ident(self.cx.tcx) == field.ident
170-
{ Some(self.cx.tcx.type_of(f_def.did)) }
170+
{ Some(self.cx.tcx.type_of(f_def.did).subst_identity()) }
171171
else { None }
172172
});
173173
self.ty_bounds.push(bound.into());

clippy_lints/src/dereference.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ fn walk_parents<'tcx>(
735735
span,
736736
..
737737
}) if span.ctxt() == ctxt => {
738-
let ty = cx.tcx.type_of(owner_id.def_id);
738+
let ty = cx.tcx.type_of(owner_id.def_id).subst_identity();
739739
Some(ty_auto_deref_stability(cx, ty, precedence).position_for_result(cx))
740740
},
741741

@@ -771,7 +771,7 @@ fn walk_parents<'tcx>(
771771
}) => variant_of_res(cx, cx.qpath_res(path, *hir_id))
772772
.and_then(|variant| variant.fields.iter().find(|f| f.name == field.ident.name))
773773
.map(|field_def| {
774-
ty_auto_deref_stability(cx, cx.tcx.type_of(field_def.did), precedence).position_for_arg()
774+
ty_auto_deref_stability(cx, cx.tcx.type_of(field_def.did).subst_identity(), precedence).position_for_arg()
775775
}),
776776
_ => None,
777777
},

clippy_lints/src/derivable_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
184184
if let Some(Node::ImplItem(impl_item)) = cx.tcx.hir().find(impl_item_hir);
185185
if let ImplItemKind::Fn(_, b) = &impl_item.kind;
186186
if let Body { value: func_expr, .. } = cx.tcx.hir().body(*b);
187-
if let Some(adt_def) = cx.tcx.type_of(item.owner_id).ty_adt_def();
187+
if let Some(adt_def) = cx.tcx.type_of(item.owner_id).subst_identity().ty_adt_def();
188188
if let attrs = cx.tcx.hir().attrs(item.hir_id());
189189
if !attrs.iter().any(|attr| attr.doc_str().is_some());
190190
if let child_attrs = cx.tcx.hir().attrs(impl_item_hir);

clippy_lints/src/derive.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl<'tcx> LateLintPass<'tcx> for Derive {
211211
..
212212
}) = item.kind
213213
{
214-
let ty = cx.tcx.type_of(item.owner_id);
214+
let ty = cx.tcx.type_of(item.owner_id).subst_identity();
215215
let is_automatically_derived = cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
216216

217217
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
@@ -347,7 +347,7 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
347347
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).map_or(false, |impls| {
348348
impls
349349
.iter()
350-
.any(|&id| matches!(cx.tcx.type_of(id).kind(), ty::Adt(adt, _) if ty_adt.did() == adt.did()))
350+
.any(|&id| matches!(cx.tcx.type_of(id).subst_identity().kind(), ty::Adt(adt, _) if ty_adt.did() == adt.did()))
351351
});
352352
if !has_copy_impl {
353353
return;

clippy_lints/src/empty_enum.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for EmptyEnum {
4949
}
5050

5151
if let ItemKind::Enum(..) = item.kind {
52-
let ty = cx.tcx.type_of(item.owner_id);
52+
let ty = cx.tcx.type_of(item.owner_id).subst_identity();
5353
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
5454
if adt.variants().is_empty() {
5555
span_lint_and_help(

clippy_lints/src/enum_clike.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'tcx> LateLintPass<'tcx> for UnportableVariant {
4545
for var in def.variants {
4646
if let Some(anon_const) = &var.disr_expr {
4747
let def_id = cx.tcx.hir().body_owner_def_id(anon_const.body);
48-
let mut ty = cx.tcx.type_of(def_id.to_def_id());
48+
let mut ty = cx.tcx.type_of(def_id.to_def_id()).subst_identity();
4949
let constant = cx
5050
.tcx
5151
.const_eval_poly(def_id.to_def_id())

clippy_lints/src/eta_reduction.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
108108
if check_inputs(cx, body.params, None, args);
109109
let callee_ty = cx.typeck_results().expr_ty_adjusted(callee);
110110
let call_ty = cx.typeck_results().type_dependent_def_id(body.value.hir_id)
111-
.map_or(callee_ty, |id| cx.tcx.type_of(id));
111+
.map_or(callee_ty, |id| cx.tcx.type_of(id).subst_identity());
112112
if check_sig(cx, closure_ty, call_ty);
113113
let substs = cx.typeck_results().node_substs(callee.hir_id);
114114
// This fixes some false positives that I don't entirely understand
@@ -153,7 +153,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
153153
if check_inputs(cx, body.params, Some(receiver), args);
154154
let method_def_id = cx.typeck_results().type_dependent_def_id(body.value.hir_id).unwrap();
155155
let substs = cx.typeck_results().node_substs(body.value.hir_id);
156-
let call_ty = cx.tcx.bound_type_of(method_def_id).subst(cx.tcx, substs);
156+
let call_ty = cx.tcx.type_of(method_def_id).subst(cx.tcx, substs);
157157
if check_sig(cx, closure_ty, call_ty);
158158
then {
159159
span_lint_and_then(cx, REDUNDANT_CLOSURE_FOR_METHOD_CALLS, expr.span, "redundant closure", |diag| {
@@ -233,7 +233,7 @@ fn get_ufcs_type_name<'tcx>(cx: &LateContext<'tcx>, method_def_id: DefId, substs
233233
match assoc_item.container {
234234
ty::TraitContainer => cx.tcx.def_path_str(def_id),
235235
ty::ImplContainer => {
236-
let ty = cx.tcx.type_of(def_id);
236+
let ty = cx.tcx.type_of(def_id).skip_binder();
237237
match ty.kind() {
238238
ty::Adt(adt, _) => cx.tcx.def_path_str(adt.did()),
239239
ty::Array(..)

clippy_lints/src/implicit_saturating_sub.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub {
102102
if let Some(const_id) = cx.typeck_results().type_dependent_def_id(cond_num_val.hir_id);
103103
if let Some(impl_id) = cx.tcx.impl_of_method(const_id);
104104
if let None = cx.tcx.impl_trait_ref(impl_id); // An inherent impl
105-
if cx.tcx.type_of(impl_id).is_integral();
105+
if cx.tcx.type_of(impl_id).subst_identity().is_integral();
106106
then {
107107
print_lint_and_sugg(cx, var_name, expr)
108108
}
@@ -115,7 +115,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub {
115115
if let Some(func_id) = cx.typeck_results().type_dependent_def_id(func.hir_id);
116116
if let Some(impl_id) = cx.tcx.impl_of_method(func_id);
117117
if let None = cx.tcx.impl_trait_ref(impl_id); // An inherent impl
118-
if cx.tcx.type_of(impl_id).is_integral();
118+
if cx.tcx.type_of(impl_id).subst_identity().is_integral();
119119
then {
120120
print_lint_and_sugg(cx, var_name, expr)
121121
}

clippy_lints/src/inherent_impl.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
6666
)
6767
}) {
6868
for impl_id in impl_ids.iter().map(|id| id.expect_local()) {
69-
match type_map.entry(cx.tcx.type_of(impl_id)) {
69+
let impl_ty = cx.tcx.type_of(impl_id).subst_identity();
70+
match type_map.entry(impl_ty) {
7071
Entry::Vacant(e) => {
7172
// Store the id for the first impl block of this type. The span is retrieved lazily.
7273
e.insert(IdOrSpan::Id(impl_id));

clippy_lints/src/large_enum_variant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeEnumVariant {
8383
return;
8484
}
8585
if let ItemKind::Enum(ref def, _) = item.kind {
86-
let ty = cx.tcx.type_of(item.owner_id);
86+
let ty = cx.tcx.type_of(item.owner_id).subst_identity();
8787
let Adt(adt, subst) = ty.kind() else {
8888
panic!("already checked whether this is an enum")
8989
};

clippy_lints/src/matches/rest_pat_in_fully_bound_struct.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub(crate) fn check(cx: &LateContext<'_>, pat: &Pat<'_>) {
1010
if !pat.span.from_expansion();
1111
if let PatKind::Struct(QPath::Resolved(_, path), fields, true) = pat.kind;
1212
if let Some(def_id) = path.res.opt_def_id();
13-
let ty = cx.tcx.type_of(def_id);
13+
let ty = cx.tcx.type_of(def_id).subst_identity();
1414
if let ty::Adt(def, _) = ty.kind();
1515
if def.is_struct() || def.is_union();
1616
if fields.len() == def.non_enum_variant().fields.len();

clippy_lints/src/methods/bytes_count_to_len.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(super) fn check<'tcx>(
1717
if_chain! {
1818
if let Some(bytes_id) = cx.typeck_results().type_dependent_def_id(count_recv.hir_id);
1919
if let Some(impl_id) = cx.tcx.impl_of_method(bytes_id);
20-
if cx.tcx.type_of(impl_id).is_str();
20+
if cx.tcx.type_of(impl_id).subst_identity().is_str();
2121
let ty = cx.typeck_results().expr_ty(bytes_recv).peel_refs();
2222
if ty.is_str() || is_type_lang_item(cx, ty, hir::LangItem::String);
2323
then {

clippy_lints/src/methods/case_sensitive_file_extension_comparisons.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(super) fn check<'tcx>(
3030
if_chain! {
3131
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
3232
if let Some(impl_id) = cx.tcx.impl_of_method(method_id);
33-
if cx.tcx.type_of(impl_id).is_str();
33+
if cx.tcx.type_of(impl_id).subst_identity().is_str();
3434
if let ExprKind::Lit(Spanned { node: LitKind::Str(ext_literal, ..), ..}) = arg.kind;
3535
if (2..=6).contains(&ext_literal.as_str().len());
3636
let ext_str = ext_literal.as_str();

clippy_lints/src/methods/get_first.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(super) fn check<'tcx>(
1919
if_chain! {
2020
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
2121
if let Some(impl_id) = cx.tcx.impl_of_method(method_id);
22-
if cx.tcx.type_of(impl_id).is_slice();
22+
if cx.tcx.type_of(impl_id).subst_identity().is_slice();
2323
if let Some(_) = is_slice_of_primitives(cx, recv);
2424
if let hir::ExprKind::Lit(Spanned { node: LitKind::Int(0, _), .. }) = arg.kind;
2525
then {

clippy_lints/src/methods/implicit_clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn is_clone_like(cx: &LateContext<'_>, method_name: &str, method_def_id: hir
5353
"to_vec" => cx
5454
.tcx
5555
.impl_of_method(method_def_id)
56-
.filter(|&impl_did| cx.tcx.type_of(impl_did).is_slice() && cx.tcx.impl_trait_ref(impl_did).is_none())
56+
.filter(|&impl_did| cx.tcx.type_of(impl_did).subst_identity().is_slice() && cx.tcx.impl_trait_ref(impl_did).is_none())
5757
.is_some(),
5858
_ => false,
5959
}

clippy_lints/src/methods/manual_ok_or.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(super) fn check<'tcx>(
2121
if_chain! {
2222
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
2323
if let Some(impl_id) = cx.tcx.impl_of_method(method_id);
24-
if is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id), sym::Option);
24+
if is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id).subst_identity(), sym::Option);
2525
if let ExprKind::Call(err_path, [err_arg]) = or_expr.kind;
2626
if is_res_lang_ctor(cx, path_res(cx, err_path), ResultErr);
2727
if is_ok_wrapping(cx, map_expr);

clippy_lints/src/methods/map_clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(super) fn check(cx: &LateContext<'_>, e: &hir::Expr<'_>, recv: &hir::Expr<'_
1919
if_chain! {
2020
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(e.hir_id);
2121
if cx.tcx.impl_of_method(method_id)
22-
.map_or(false, |id| is_type_diagnostic_item(cx, cx.tcx.type_of(id), sym::Option))
22+
.map_or(false, |id| is_type_diagnostic_item(cx, cx.tcx.type_of(id).subst_identity(), sym::Option))
2323
|| is_diag_trait_item(cx, method_id, sym::Iterator);
2424
if let hir::ExprKind::Closure(&hir::Closure{ body, .. }) = arg.kind;
2525
then {

clippy_lints/src/methods/map_err_ignore.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use super::MAP_ERR_IGNORE;
99
pub(super) fn check(cx: &LateContext<'_>, e: &Expr<'_>, arg: &Expr<'_>) {
1010
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(e.hir_id)
1111
&& let Some(impl_id) = cx.tcx.impl_of_method(method_id)
12-
&& is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id), sym::Result)
12+
&& is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id).subst_identity(), sym::Result)
1313
&& let ExprKind::Closure(&Closure {
1414
capture_clause: CaptureBy::Ref,
1515
body,

clippy_lints/src/methods/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3349,7 +3349,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
33493349
let name = impl_item.ident.name.as_str();
33503350
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id;
33513351
let item = cx.tcx.hir().expect_item(parent);
3352-
let self_ty = cx.tcx.type_of(item.owner_id);
3352+
let self_ty = cx.tcx.type_of(item.owner_id).subst_identity();
33533353

33543354
let implements_trait = matches!(item.kind, hir::ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }));
33553355
if let hir::ImplItemKind::Fn(ref sig, id) = impl_item.kind {

clippy_lints/src/methods/mut_mutex_lock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, ex: &'tcx Expr<'tcx>, recv: &'
1515
if let ty::Ref(_, _, Mutability::Mut) = cx.typeck_results().expr_ty(recv).kind();
1616
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(ex.hir_id);
1717
if let Some(impl_id) = cx.tcx.impl_of_method(method_id);
18-
if is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id), sym::Mutex);
18+
if is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id).subst_identity(), sym::Mutex);
1919
then {
2020
span_lint_and_sugg(
2121
cx,

clippy_lints/src/methods/open_options.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use super::NONSENSICAL_OPEN_OPTIONS;
1111
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, recv: &'tcx Expr<'_>) {
1212
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(e.hir_id)
1313
&& let Some(impl_id) = cx.tcx.impl_of_method(method_id)
14-
&& match_type(cx, cx.tcx.type_of(impl_id), &paths::OPEN_OPTIONS)
14+
&& match_type(cx, cx.tcx.type_of(impl_id).subst_identity(), &paths::OPEN_OPTIONS)
1515
{
1616
let mut options = Vec::new();
1717
get_open_options(cx, recv, &mut options);

clippy_lints/src/methods/path_buf_push_overwrite.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, arg: &'t
1414
if_chain! {
1515
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
1616
if let Some(impl_id) = cx.tcx.impl_of_method(method_id);
17-
if is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id), sym::PathBuf);
17+
if is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id).subst_identity(), sym::PathBuf);
1818
if let ExprKind::Lit(ref lit) = arg.kind;
1919
if let LitKind::Str(ref path_lit, _) = lit.node;
2020
if let pushed_path = Path::new(path_lit.as_str());

clippy_lints/src/methods/stable_sort_primitive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use super::STABLE_SORT_PRIMITIVE;
1010
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, recv: &'tcx Expr<'_>) {
1111
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(e.hir_id)
1212
&& let Some(impl_id) = cx.tcx.impl_of_method(method_id)
13-
&& cx.tcx.type_of(impl_id).is_slice()
13+
&& cx.tcx.type_of(impl_id).subst_identity().is_slice()
1414
&& let Some(slice_type) = is_slice_of_primitives(cx, recv)
1515
{
1616
span_lint_and_then(

clippy_lints/src/methods/suspicious_splitn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(super) fn check(cx: &LateContext<'_>, method_name: &str, expr: &Expr<'_>, se
1313
if let Some(call_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
1414
if let Some(impl_id) = cx.tcx.impl_of_method(call_id);
1515
if cx.tcx.impl_trait_ref(impl_id).is_none();
16-
let self_ty = cx.tcx.type_of(impl_id);
16+
let self_ty = cx.tcx.type_of(impl_id).subst_identity();
1717
if self_ty.is_slice() || self_ty.is_str();
1818
then {
1919
// Ignore empty slice and string literals when used with a literal count.

clippy_lints/src/methods/unnecessary_sort_by.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn detect_lint(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, arg: &Exp
122122
if_chain! {
123123
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
124124
if let Some(impl_id) = cx.tcx.impl_of_method(method_id);
125-
if cx.tcx.type_of(impl_id).is_slice();
125+
if cx.tcx.type_of(impl_id).subst_identity().is_slice();
126126
if let ExprKind::Closure(&Closure { body, .. }) = arg.kind;
127127
if let closure_body = cx.tcx.hir().body(body);
128128
if let &[

clippy_lints/src/methods/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for CloneOrCopyVisitor<'cx, 'tcx> {
143143
if_chain! {
144144
if args.iter().all(|arg| !self.is_binding(arg));
145145
if let Some(method_def_id) = self.cx.typeck_results().type_dependent_def_id(parent.hir_id);
146-
let method_ty = self.cx.tcx.type_of(method_def_id);
146+
let method_ty = self.cx.tcx.type_of(method_def_id).subst_identity();
147147
let self_ty = method_ty.fn_sig(self.cx.tcx).input(0).skip_binder();
148148
if matches!(self_ty.kind(), ty::Ref(_, _, Mutability::Not));
149149
then {

clippy_lints/src/methods/vec_resize_to_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub(super) fn check<'tcx>(
2020
if_chain! {
2121
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
2222
if let Some(impl_id) = cx.tcx.impl_of_method(method_id);
23-
if is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id), sym::Vec);
23+
if is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id).subst_identity(), sym::Vec);
2424
if let ExprKind::Lit(Spanned { node: LitKind::Int(0, _), .. }) = count_arg.kind;
2525
if let ExprKind::Lit(Spanned { node: LitKind::Int(..), .. }) = default_arg.kind;
2626
then {

clippy_lints/src/mut_reference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMutPassed {
5252
ExprKind::MethodCall(path, receiver, arguments, _) => {
5353
let def_id = cx.typeck_results().type_dependent_def_id(e.hir_id).unwrap();
5454
let substs = cx.typeck_results().node_substs(e.hir_id);
55-
let method_type = cx.tcx.bound_type_of(def_id).subst(cx.tcx, substs);
55+
let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs);
5656
check_arguments(
5757
cx,
5858
std::iter::once(receiver).chain(arguments.iter()).collect(),

0 commit comments

Comments
 (0)