Skip to content

Commit 33f084e

Browse files
committed
Auto merge of #11544 - Alexendoo:hir-ty-to-ty, r=Jarcho
Remove most usage of `hir_ty_to_ty` Removes the usages where there's a suitable query or the type was already available elsewhere. The remaining cases would all require more involved changes changelog: none r? `@Jarcho`
2 parents 4d143d7 + 01c25a8 commit 33f084e

15 files changed

+78
-105
lines changed

clippy_lints/src/default_union_representation.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
2-
use rustc_hir::{self as hir, HirId, Item, ItemKind};
3-
use rustc_hir_analysis::hir_ty_to_ty;
2+
use rustc_hir::{HirId, Item, ItemKind};
43
use rustc_lint::{LateContext, LateLintPass};
54
use rustc_middle::ty::layout::LayoutOf;
5+
use rustc_middle::ty::{self, FieldDef, GenericArg, List};
66
use rustc_session::{declare_lint_pass, declare_tool_lint};
77
use rustc_span::sym;
88

@@ -52,7 +52,10 @@ declare_lint_pass!(DefaultUnionRepresentation => [DEFAULT_UNION_REPRESENTATION])
5252

5353
impl<'tcx> LateLintPass<'tcx> for DefaultUnionRepresentation {
5454
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
55-
if is_union_with_two_non_zst_fields(cx, item) && !has_c_repr_attr(cx, item.hir_id()) {
55+
if !item.span.from_expansion()
56+
&& is_union_with_two_non_zst_fields(cx, item)
57+
&& !has_c_repr_attr(cx, item.hir_id())
58+
{
5659
span_lint_and_help(
5760
cx,
5861
DEFAULT_UNION_REPRESENTATION,
@@ -73,18 +76,17 @@ impl<'tcx> LateLintPass<'tcx> for DefaultUnionRepresentation {
7376
/// if there is only one field left after ignoring ZST fields then the offset
7477
/// of that field does not matter either.)
7578
fn is_union_with_two_non_zst_fields(cx: &LateContext<'_>, item: &Item<'_>) -> bool {
76-
if let ItemKind::Union(data, _) = &item.kind {
77-
data.fields().iter().filter(|f| !is_zst(cx, f.ty)).count() >= 2
79+
if let ItemKind::Union(..) = &item.kind
80+
&& let ty::Adt(adt_def, args) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind()
81+
{
82+
adt_def.all_fields().filter(|f| !is_zst(cx, f, args)).count() >= 2
7883
} else {
7984
false
8085
}
8186
}
8287

83-
fn is_zst(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>) -> bool {
84-
if hir_ty.span.from_expansion() {
85-
return false;
86-
}
87-
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
88+
fn is_zst<'tcx>(cx: &LateContext<'tcx>, field: &FieldDef, args: &'tcx List<GenericArg<'tcx>>) -> bool {
89+
let ty = field.ty(cx.tcx, args);
8890
if let Ok(layout) = cx.layout_of(ty) {
8991
layout.is_zst()
9092
} else {

clippy_lints/src/error_impl_error.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use clippy_utils::path_res;
33
use clippy_utils::ty::implements_trait;
44
use rustc_hir::def_id::{DefId, LocalDefId};
55
use rustc_hir::{Item, ItemKind};
6-
use rustc_hir_analysis::hir_ty_to_ty;
76
use rustc_lint::{LateContext, LateLintPass};
87
use rustc_middle::ty::Visibility;
98
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -42,9 +41,10 @@ impl<'tcx> LateLintPass<'tcx> for ErrorImplError {
4241
};
4342

4443
match item.kind {
45-
ItemKind::TyAlias(ty, _) if implements_trait(cx, hir_ty_to_ty(cx.tcx, ty), error_def_id, &[])
46-
&& item.ident.name == sym::Error
47-
&& is_visible_outside_module(cx, item.owner_id.def_id) =>
44+
ItemKind::TyAlias(..) if item.ident.name == sym::Error
45+
&& is_visible_outside_module(cx, item.owner_id.def_id)
46+
&& let ty = cx.tcx.type_of(item.owner_id).instantiate_identity()
47+
&& implements_trait(cx, ty, error_def_id, &[]) =>
4848
{
4949
span_lint(
5050
cx,

clippy_lints/src/large_const_arrays.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use clippy_utils::diagnostics::span_lint_and_then;
22
use if_chain::if_chain;
33
use rustc_errors::Applicability;
44
use rustc_hir::{Item, ItemKind};
5-
use rustc_hir_analysis::hir_ty_to_ty;
65
use rustc_lint::{LateContext, LateLintPass};
76
use rustc_middle::ty::layout::LayoutOf;
87
use rustc_middle::ty::{self, ConstKind};
@@ -50,12 +49,12 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
5049
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
5150
if_chain! {
5251
if !item.span.from_expansion();
53-
if let ItemKind::Const(hir_ty, generics, _) = &item.kind;
52+
if let ItemKind::Const(_, generics, _) = &item.kind;
5453
// Since static items may not have generics, skip generic const items.
5554
// FIXME(generic_const_items): I don't think checking `generics.hwcp` suffices as it
5655
// doesn't account for empty where-clauses that only consist of keyword `where` IINM.
5756
if generics.params.is_empty() && !generics.has_where_clause_predicates;
58-
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
57+
let ty = cx.tcx.type_of(item.owner_id).instantiate_identity();
5958
if let ty::Array(element_type, cst) = ty.kind();
6059
if let ConstKind::Value(ty::ValTree::Leaf(element_count)) = cst.kind();
6160
if let Ok(element_count) = element_count.try_to_target_usize(cx.tcx);

clippy_lints/src/loops/utils.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use rustc_ast::ast::{LitIntType, LitKind};
55
use rustc_errors::Applicability;
66
use rustc_hir::intravisit::{walk_expr, walk_local, walk_pat, walk_stmt, Visitor};
77
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, HirId, HirIdMap, Local, Mutability, Pat, PatKind, Stmt};
8-
use rustc_hir_analysis::hir_ty_to_ty;
98
use rustc_lint::LateContext;
109
use rustc_middle::hir::nested_filter;
1110
use rustc_middle::ty::{self, Ty};
@@ -150,7 +149,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
150149
if l.pat.hir_id == self.var_id;
151150
if let PatKind::Binding(.., ident, _) = l.pat.kind;
152151
then {
153-
let ty = l.ty.map(|ty| hir_ty_to_ty(self.cx.tcx, ty));
152+
let ty = l.ty.map(|_| self.cx.typeck_results().pat_ty(l.pat));
154153

155154
self.state = l.init.map_or(InitializeVisitorState::Declared(ident.name, ty), |init| {
156155
InitializeVisitorState::Initialized {

clippy_lints/src/matches/needless_match.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use clippy_utils::{
88
};
99
use rustc_errors::Applicability;
1010
use rustc_hir::LangItem::OptionNone;
11-
use rustc_hir::{Arm, BindingAnnotation, ByRef, Expr, ExprKind, FnRetTy, Guard, Node, Pat, PatKind, Path, QPath};
12-
use rustc_hir_analysis::hir_ty_to_ty;
11+
use rustc_hir::{Arm, BindingAnnotation, ByRef, Expr, ExprKind, Guard, ItemKind, Node, Pat, PatKind, Path, QPath};
1312
use rustc_lint::LateContext;
1413
use rustc_span::sym;
1514

@@ -141,11 +140,15 @@ fn expr_ty_matches_p_ty(cx: &LateContext<'_>, expr: &Expr<'_>, p_expr: &Expr<'_>
141140
return same_type_and_consts(results.node_type(local.hir_id), results.expr_ty(expr));
142141
},
143142
// compare match_expr ty with RetTy in `fn foo() -> RetTy`
144-
Node::Item(..) => {
145-
if let Some(fn_decl) = p_node.fn_decl() {
146-
if let FnRetTy::Return(ret_ty) = fn_decl.output {
147-
return same_type_and_consts(hir_ty_to_ty(cx.tcx, ret_ty), cx.typeck_results().expr_ty(expr));
148-
}
143+
Node::Item(item) => {
144+
if let ItemKind::Fn(..) = item.kind {
145+
let output = cx
146+
.tcx
147+
.fn_sig(item.owner_id)
148+
.instantiate_identity()
149+
.output()
150+
.skip_binder();
151+
return same_type_and_consts(output, cx.typeck_results().expr_ty(expr));
149152
}
150153
},
151154
// check the parent expr for this whole block `{ match match_expr {..} }`

clippy_lints/src/methods/mod.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ pub use path_ends_with_ext::DEFAULT_ALLOWED_DOTFILES;
126126
use rustc_data_structures::fx::FxHashSet;
127127
use rustc_hir as hir;
128128
use rustc_hir::{Expr, ExprKind, Node, Stmt, StmtKind, TraitItem, TraitItemKind};
129-
use rustc_hir_analysis::hir_ty_to_ty;
130129
use rustc_lint::{LateContext, LateLintPass, LintContext};
131130
use rustc_middle::lint::in_external_macro;
132131
use rustc_middle::ty::{self, TraitRef, Ty};
@@ -3926,18 +3925,20 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
39263925
if_chain! {
39273926
if let TraitItemKind::Fn(ref sig, _) = item.kind;
39283927
if sig.decl.implicit_self.has_implicit_self();
3929-
if let Some(first_arg_ty) = sig.decl.inputs.iter().next();
3930-
3928+
if let Some(first_arg_hir_ty) = sig.decl.inputs.first();
3929+
if let Some(&first_arg_ty) = cx.tcx.fn_sig(item.owner_id)
3930+
.instantiate_identity()
3931+
.inputs()
3932+
.skip_binder()
3933+
.first();
39313934
then {
3932-
let first_arg_span = first_arg_ty.span;
3933-
let first_arg_ty = hir_ty_to_ty(cx.tcx, first_arg_ty);
39343935
let self_ty = TraitRef::identity(cx.tcx, item.owner_id.to_def_id()).self_ty();
39353936
wrong_self_convention::check(
39363937
cx,
39373938
item.ident.name.as_str(),
39383939
self_ty,
39393940
first_arg_ty,
3940-
first_arg_span,
3941+
first_arg_hir_ty.span,
39413942
false,
39423943
true,
39433944
);

clippy_lints/src/missing_const_for_fn.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_hir as hir;
77
use rustc_hir::def_id::CRATE_DEF_ID;
88
use rustc_hir::intravisit::FnKind;
99
use rustc_hir::{Body, Constness, FnDecl, GenericParamKind};
10-
use rustc_hir_analysis::hir_ty_to_ty;
1110
use rustc_lint::{LateContext, LateLintPass};
1211
use rustc_middle::lint::in_external_macro;
1312
use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -124,7 +123,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
124123
FnKind::Method(_, sig, ..) => {
125124
if trait_ref_of_method(cx, def_id).is_some()
126125
|| already_const(sig.header)
127-
|| method_accepts_droppable(cx, sig.decl.inputs)
126+
|| method_accepts_droppable(cx, def_id)
128127
{
129128
return;
130129
}
@@ -165,12 +164,11 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
165164

166165
/// Returns true if any of the method parameters is a type that implements `Drop`. The method
167166
/// can't be made const then, because `drop` can't be const-evaluated.
168-
fn method_accepts_droppable(cx: &LateContext<'_>, param_tys: &[hir::Ty<'_>]) -> bool {
167+
fn method_accepts_droppable(cx: &LateContext<'_>, def_id: LocalDefId) -> bool {
168+
let sig = cx.tcx.fn_sig(def_id).instantiate_identity().skip_binder();
169+
169170
// If any of the params are droppable, return true
170-
param_tys.iter().any(|hir_ty| {
171-
let ty_ty = hir_ty_to_ty(cx.tcx, hir_ty);
172-
has_drop(cx, ty_ty)
173-
})
171+
sig.inputs().iter().any(|&ty| has_drop(cx, ty))
174172
}
175173

176174
// We don't have to lint on something that's already `const`

clippy_lints/src/no_effect.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ use clippy_utils::{get_parent_node, is_lint_allowed, peel_blocks};
55
use rustc_errors::Applicability;
66
use rustc_hir::def::{DefKind, Res};
77
use rustc_hir::{
8-
is_range_literal, BinOpKind, BlockCheckMode, Expr, ExprKind, FnRetTy, ItemKind, Node, PatKind, Stmt, StmtKind,
9-
UnsafeSource,
8+
is_range_literal, BinOpKind, BlockCheckMode, Expr, ExprKind, ItemKind, Node, PatKind, Stmt, StmtKind, UnsafeSource,
109
};
11-
use rustc_hir_analysis::hir_ty_to_ty;
1210
use rustc_infer::infer::TyCtxtInferExt as _;
1311
use rustc_lint::{LateContext, LateLintPass, LintContext};
1412
use rustc_middle::lint::in_external_macro;
@@ -99,14 +97,13 @@ fn check_no_effect(cx: &LateContext<'_>, stmt: &Stmt<'_>) -> bool {
9997
|diag| {
10098
for parent in cx.tcx.hir().parent_iter(stmt.hir_id) {
10199
if let Node::Item(item) = parent.1
102-
&& let ItemKind::Fn(sig, ..) = item.kind
103-
&& let FnRetTy::Return(ret_ty) = sig.decl.output
100+
&& let ItemKind::Fn(..) = item.kind
104101
&& let Some(Node::Block(block)) = get_parent_node(cx.tcx, stmt.hir_id)
105102
&& let [.., final_stmt] = block.stmts
106103
&& final_stmt.hir_id == stmt.hir_id
107104
{
108105
let expr_ty = cx.typeck_results().expr_ty(expr);
109-
let mut ret_ty = hir_ty_to_ty(cx.tcx, ret_ty);
106+
let mut ret_ty = cx.tcx.fn_sig(item.owner_id).instantiate_identity().output().skip_binder();
110107

111108
// Remove `impl Future<Output = T>` to get `T`
112109
if cx.tcx.ty_is_opaque_future(ret_ty) &&
@@ -115,7 +112,7 @@ fn check_no_effect(cx: &LateContext<'_>, stmt: &Stmt<'_>) -> bool {
115112
ret_ty = true_ret_ty;
116113
}
117114

118-
if ret_ty == expr_ty {
115+
if !ret_ty.is_unit() && ret_ty == expr_ty {
119116
diag.span_suggestion(
120117
stmt.span.shrink_to_lo(),
121118
"did you mean to return it?",

clippy_lints/src/non_canonical_impls.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use clippy_utils::ty::implements_trait;
44
use clippy_utils::{get_parent_node, is_res_lang_ctor, last_path_segment, match_def_path, path_res, std_or_core};
55
use rustc_errors::Applicability;
66
use rustc_hir::def_id::LocalDefId;
7-
use rustc_hir::{Expr, ExprKind, ImplItem, ImplItemKind, ItemKind, LangItem, Node, UnOp};
8-
use rustc_hir_analysis::hir_ty_to_ty;
7+
use rustc_hir::{Expr, ExprKind, ImplItem, ImplItemKind, LangItem, Node, UnOp};
98
use rustc_lint::{LateContext, LateLintPass};
109
use rustc_middle::ty::EarlyBinder;
1110
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -123,9 +122,6 @@ impl LateLintPass<'_> for NonCanonicalImpls {
123122
if cx.tcx.is_automatically_derived(item.owner_id.to_def_id()) {
124123
return;
125124
}
126-
let ItemKind::Impl(imp) = item.kind else {
127-
return;
128-
};
129125
let ImplItemKind::Fn(_, impl_item_id) = cx.tcx.hir().impl_item(impl_item.impl_item_id()).kind else {
130126
return;
131127
};
@@ -181,12 +177,8 @@ impl LateLintPass<'_> for NonCanonicalImpls {
181177

182178
if cx.tcx.is_diagnostic_item(sym::PartialOrd, trait_impl.def_id)
183179
&& impl_item.ident.name == sym::partial_cmp
184-
&& let Some(ord_def_id) = cx
185-
.tcx
186-
.diagnostic_items(trait_impl.def_id.krate)
187-
.name_to_id
188-
.get(&sym::Ord)
189-
&& implements_trait(cx, hir_ty_to_ty(cx.tcx, imp.self_ty), *ord_def_id, &[])
180+
&& let Some(ord_def_id) = cx.tcx.get_diagnostic_item(sym::Ord)
181+
&& implements_trait(cx, trait_impl.self_ty(), ord_def_id, &[])
190182
{
191183
// If the `cmp` call likely needs to be fully qualified in the suggestion
192184
// (like `std::cmp::Ord::cmp`). It's unfortunate we must put this here but we can't

clippy_lints/src/non_copy_const.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use rustc_hir::def_id::DefId;
1313
use rustc_hir::{
1414
BodyId, Expr, ExprKind, HirId, Impl, ImplItem, ImplItemKind, Item, ItemKind, Node, TraitItem, TraitItemKind, UnOp,
1515
};
16-
use rustc_hir_analysis::hir_ty_to_ty;
1716
use rustc_lint::{LateContext, LateLintPass, Lint};
1817
use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult, GlobalId};
1918
use rustc_middle::ty::adjustment::Adjust;
@@ -297,17 +296,17 @@ declare_lint_pass!(NonCopyConst => [DECLARE_INTERIOR_MUTABLE_CONST, BORROW_INTER
297296

298297
impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
299298
fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx Item<'_>) {
300-
if let ItemKind::Const(hir_ty, _generics, body_id) = it.kind {
301-
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
299+
if let ItemKind::Const(.., body_id) = it.kind {
300+
let ty = cx.tcx.type_of(it.owner_id).instantiate_identity();
302301
if !ignored_macro(cx, it) && is_unfrozen(cx, ty) && is_value_unfrozen_poly(cx, body_id, ty) {
303302
lint(cx, Source::Item { item: it.span });
304303
}
305304
}
306305
}
307306

308307
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, trait_item: &'tcx TraitItem<'_>) {
309-
if let TraitItemKind::Const(hir_ty, body_id_opt) = &trait_item.kind {
310-
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
308+
if let TraitItemKind::Const(_, body_id_opt) = &trait_item.kind {
309+
let ty = cx.tcx.type_of(trait_item.owner_id).instantiate_identity();
311310

312311
// Normalize assoc types because ones originated from generic params
313312
// bounded other traits could have their bound.
@@ -333,7 +332,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
333332
}
334333

335334
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'_>) {
336-
if let ImplItemKind::Const(hir_ty, body_id) = &impl_item.kind {
335+
if let ImplItemKind::Const(_, body_id) = &impl_item.kind {
337336
let item_def_id = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id;
338337
let item = cx.tcx.hir().expect_item(item_def_id);
339338

@@ -366,7 +365,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
366365
// we should use here as a frozen variant is a potential to be frozen
367366
// similar to unknown layouts.
368367
// e.g. `layout_of(...).is_err() || has_frozen_variant(...);`
369-
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
368+
let ty = cx.tcx.type_of(impl_item.owner_id).instantiate_identity();
370369
let normalized = cx.tcx.normalize_erasing_regions(cx.param_env, ty);
371370
if is_unfrozen(cx, normalized);
372371
if is_value_unfrozen_poly(cx, *body_id, normalized);
@@ -381,7 +380,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
381380
}
382381
},
383382
ItemKind::Impl(Impl { of_trait: None, .. }) => {
384-
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
383+
let ty = cx.tcx.type_of(impl_item.owner_id).instantiate_identity();
385384
// Normalize assoc types originated from generic params.
386385
let normalized = cx.tcx.normalize_erasing_regions(cx.param_env, ty);
387386

clippy_lints/src/ptr.rs

+7-14
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use rustc_hir::{
1616
ImplItemKind, ItemKind, Lifetime, Mutability, Node, Param, PatKind, QPath, TraitFn, TraitItem, TraitItemKind,
1717
TyKind, Unsafety,
1818
};
19-
use rustc_hir_analysis::hir_ty_to_ty;
2019
use rustc_infer::infer::TyCtxtInferExt;
2120
use rustc_infer::traits::{Obligation, ObligationCause};
2221
use rustc_lint::{LateContext, LateLintPass};
@@ -172,13 +171,8 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
172171

173172
for arg in check_fn_args(
174173
cx,
175-
cx.tcx
176-
.fn_sig(item.owner_id)
177-
.instantiate_identity()
178-
.skip_binder()
179-
.inputs(),
174+
cx.tcx.fn_sig(item.owner_id).instantiate_identity().skip_binder(),
180175
sig.decl.inputs,
181-
&sig.decl.output,
182176
&[],
183177
)
184178
.filter(|arg| arg.mutability() == Mutability::Not)
@@ -237,7 +231,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
237231

238232
let decl = sig.decl;
239233
let sig = cx.tcx.fn_sig(item_id).instantiate_identity().skip_binder();
240-
let lint_args: Vec<_> = check_fn_args(cx, sig.inputs(), decl.inputs, &decl.output, body.params)
234+
let lint_args: Vec<_> = check_fn_args(cx, sig, decl.inputs, body.params)
241235
.filter(|arg| !is_trait_item || arg.mutability() == Mutability::Not)
242236
.collect();
243237
let results = check_ptr_arg_usage(cx, body, &lint_args);
@@ -443,12 +437,13 @@ impl<'tcx> DerefTy<'tcx> {
443437
#[expect(clippy::too_many_lines)]
444438
fn check_fn_args<'cx, 'tcx: 'cx>(
445439
cx: &'cx LateContext<'tcx>,
446-
tys: &'tcx [Ty<'tcx>],
440+
fn_sig: ty::FnSig<'tcx>,
447441
hir_tys: &'tcx [hir::Ty<'tcx>],
448-
ret_ty: &'tcx FnRetTy<'tcx>,
449442
params: &'tcx [Param<'tcx>],
450443
) -> impl Iterator<Item = PtrArg<'tcx>> + 'cx {
451-
tys.iter()
444+
fn_sig
445+
.inputs()
446+
.iter()
452447
.zip(hir_tys.iter())
453448
.enumerate()
454449
.filter_map(move |(i, (ty, hir_ty))| {
@@ -494,9 +489,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
494489
})
495490
{
496491
if !lifetime.is_anonymous()
497-
&& let FnRetTy::Return(ret_ty) = ret_ty
498-
&& let ret_ty = hir_ty_to_ty(cx.tcx, ret_ty)
499-
&& ret_ty
492+
&& fn_sig.output()
500493
.walk()
501494
.filter_map(|arg| {
502495
arg.as_region().and_then(|lifetime| {

0 commit comments

Comments
 (0)