Skip to content

Commit 149392b

Browse files
committed
Auto merge of #10402 - Jarcho:rustup, r=Jarcho
Rustup Looks like `@flip1995` is busy. r? `@ghost` changelog: None
2 parents 5155119 + 69c4ff6 commit 149392b

File tree

84 files changed

+186
-155
lines changed

Some content is hidden

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

84 files changed

+186
-155
lines changed

Diff for: 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 {

Diff for: 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);

Diff for: 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 {

Diff for: 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());

Diff for: clippy_lints/src/dereference.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use rustc_middle::mir::{Rvalue, StatementKind};
2727
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
2828
use rustc_middle::ty::{
2929
self, Binder, BoundVariableKind, Clause, EarlyBinder, FnSig, GenericArgKind, List, ParamEnv, ParamTy,
30-
PredicateKind, ProjectionPredicate, Ty, TyCtxt, TypeVisitable, TypeckResults,
30+
PredicateKind, ProjectionPredicate, Ty, TyCtxt, TypeVisitableExt, TypeckResults,
3131
};
3232
use rustc_session::{declare_tool_lint, impl_lint_pass};
3333
use rustc_span::{symbol::sym, Span, Symbol};
@@ -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.tcx, cx.param_env, ty, precedence).position_for_result(cx))
740740
},
741741

@@ -781,7 +781,7 @@ fn walk_parents<'tcx>(
781781
cx.tcx,
782782
// Use the param_env of the target type.
783783
cx.tcx.param_env(adt.did()),
784-
cx.tcx.type_of(field_def.did),
784+
cx.tcx.type_of(field_def.did).subst_identity(),
785785
precedence,
786786
)
787787
.position_for_arg()

Diff for: 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);

Diff for: 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;

Diff for: clippy_lints/src/doc.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_ast::token::CommentKind;
1616
use rustc_data_structures::fx::FxHashSet;
1717
use rustc_data_structures::sync::Lrc;
1818
use rustc_errors::emitter::EmitterWriter;
19-
use rustc_errors::{Applicability, Handler, SuggestionStyle};
19+
use rustc_errors::{Applicability, Handler, SuggestionStyle, TerminalUrl};
2020
use rustc_hir as hir;
2121
use rustc_hir::intravisit::{self, Visitor};
2222
use rustc_hir::{AnonConst, Expr};
@@ -707,7 +707,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
707707

708708
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
709709
let fallback_bundle =
710-
rustc_errors::fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
710+
rustc_errors::fallback_fluent_bundle(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
711711
let emitter = EmitterWriter::new(
712712
Box::new(io::sink()),
713713
None,
@@ -719,6 +719,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
719719
None,
720720
false,
721721
false,
722+
TerminalUrl::No,
722723
);
723724
let handler = Handler::with_emitter(false, None, Box::new(emitter));
724725
let sess = ParseSess::with_span_handler(handler, sm);

Diff for: 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(

Diff for: 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())

Diff for: clippy_lints/src/eta_reduction.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::{Closure, Expr, ExprKind, Param, PatKind, Unsafety};
1111
use rustc_lint::{LateContext, LateLintPass};
1212
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
1313
use rustc_middle::ty::binding::BindingMode;
14-
use rustc_middle::ty::{self, EarlyBinder, SubstsRef, Ty, TypeVisitable};
14+
use rustc_middle::ty::{self, EarlyBinder, SubstsRef, Ty, TypeVisitableExt};
1515
use rustc_session::{declare_lint_pass, declare_tool_lint};
1616
use rustc_span::symbol::sym;
1717

@@ -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(..)

Diff for: 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
}

Diff for: clippy_lints/src/indexing_slicing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
109109
if let Some(range) = higher::Range::hir(index) {
110110
// Ranged indexes, i.e., &x[n..m], &x[n..], &x[..n] and &x[..]
111111
if let ty::Array(_, s) = ty.kind() {
112-
let size: u128 = if let Some(size) = s.try_eval_usize(cx.tcx, cx.param_env) {
112+
let size: u128 = if let Some(size) = s.try_eval_target_usize(cx.tcx, cx.param_env) {
113113
size.into()
114114
} else {
115115
return;

Diff for: 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));

Diff for: clippy_lints/src/large_const_arrays.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
5454
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
5555
if let ty::Array(element_type, cst) = ty.kind();
5656
if let ConstKind::Value(ty::ValTree::Leaf(element_count)) = cst.kind();
57-
if let Ok(element_count) = element_count.try_to_machine_usize(cx.tcx);
57+
if let Ok(element_count) = element_count.try_to_target_usize(cx.tcx);
5858
if let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes());
5959
if self.maximum_allowed_size < u128::from(element_count) * u128::from(element_size);
6060

Diff for: 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
};

Diff for: clippy_lints/src/large_stack_arrays.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackArrays {
4141
if let ExprKind::Repeat(_, _) = expr.kind
4242
&& let ty::Array(element_type, cst) = cx.typeck_results().expr_ty(expr).kind()
4343
&& let ConstKind::Value(ty::ValTree::Leaf(element_count)) = cst.kind()
44-
&& let Ok(element_count) = element_count.try_to_machine_usize(cx.tcx)
44+
&& let Ok(element_count) = element_count.try_to_target_usize(cx.tcx)
4545
&& let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes())
4646
&& !cx.tcx.hir().parent_iter(expr.hir_id)
4747
.any(|(_, node)| matches!(node, Node::Item(Item { kind: ItemKind::Static(..), .. })))

Diff for: clippy_lints/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ extern crate rustc_session;
4343
extern crate rustc_span;
4444
extern crate rustc_target;
4545
extern crate rustc_trait_selection;
46+
extern crate thin_vec;
4647

4748
#[macro_use]
4849
extern crate clippy_utils;

Diff for: clippy_lints/src/loops/explicit_iter_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn is_iterable_array<'tcx>(ty: Ty<'tcx>, cx: &LateContext<'tcx>) -> bool {
6868
// IntoIterator is currently only implemented for array sizes <= 32 in rustc
6969
match ty.kind() {
7070
ty::Array(_, n) => n
71-
.try_eval_usize(cx.tcx, cx.param_env)
71+
.try_eval_target_usize(cx.tcx, cx.param_env)
7272
.map_or(false, |val| (0..=32).contains(&val)),
7373
_ => false,
7474
}

Diff for: clippy_lints/src/loops/needless_range_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ fn is_end_eq_array_len<'tcx>(
211211
if let ExprKind::Lit(ref lit) = end.kind;
212212
if let ast::LitKind::Int(end_int, _) = lit.node;
213213
if let ty::Array(_, arr_len_const) = indexed_ty.kind();
214-
if let Some(arr_len) = arr_len_const.try_eval_usize(cx.tcx, cx.param_env);
214+
if let Some(arr_len) = arr_len_const.try_eval_target_usize(cx.tcx, cx.param_env);
215215
then {
216216
return match limits {
217217
ast::RangeLimits::Closed => end_int + 1 >= arr_len.into(),

Diff for: 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();

Diff for: 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 {

Diff for: 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();

Diff for: clippy_lints/src/methods/expect_fun_call.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub(super) fn check<'tcx>(
3333
if (method_name.ident.name == sym::as_str || method_name.ident.name == sym::as_ref) && {
3434
let arg_type = cx.typeck_results().expr_ty(receiver);
3535
let base_type = arg_type.peel_refs();
36-
*base_type.kind() == ty::Str || is_type_lang_item(cx, base_type, hir::LangItem::String)
36+
base_type.is_str() || is_type_lang_item(cx, base_type, hir::LangItem::String)
3737
} {
3838
receiver
3939
} else {
@@ -54,7 +54,7 @@ pub(super) fn check<'tcx>(
5454
return false;
5555
}
5656
if let ty::Ref(_, ty, ..) = arg_ty.kind() {
57-
if *ty.kind() == ty::Str && can_be_static_str(cx, arg) {
57+
if ty.is_str() && can_be_static_str(cx, arg) {
5858
return false;
5959
}
6060
};

Diff for: 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 {

Diff for: clippy_lints/src/methods/implicit_clone.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ 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| {
57+
cx.tcx.type_of(impl_did).subst_identity().is_slice() && cx.tcx.impl_trait_ref(impl_did).is_none()
58+
})
5759
.is_some(),
5860
_ => false,
5961
}

Diff for: 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);

Diff for: 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 {

Diff for: 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,

0 commit comments

Comments
 (0)