Skip to content

Commit 9f4a2dd

Browse files
Align Term methods with GenericArg methods
1 parent e94779a commit 9f4a2dd

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

clippy_lints/src/methods/iter_on_single_or_empty_collections.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn is_arg_ty_unified_in_fn<'tcx>(
4242
cx.tcx.predicates_of(fn_id).predicates.iter().any(|(clause, _)| {
4343
clause
4444
.as_projection_clause()
45-
.and_then(|p| p.map_bound(|p| p.term.ty()).transpose())
45+
.and_then(|p| p.map_bound(|p| p.term.as_type()).transpose())
4646
.is_some_and(|ty| ty.skip_binder() == arg_ty_in_args)
4747
}) || fn_sig
4848
.inputs()

clippy_lints/src/needless_borrows_for_generic_args.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ fn is_mixed_projection_predicate<'tcx>(
311311
) -> bool {
312312
let generics = cx.tcx.generics_of(callee_def_id);
313313
// The predicate requires the projected type to equal a type parameter from the parent context.
314-
if let Some(term_ty) = projection_predicate.term.ty()
314+
if let Some(term_ty) = projection_predicate.term.as_type()
315315
&& let ty::Param(term_param_ty) = term_ty.kind()
316316
&& (term_param_ty.index as usize) < generics.parent_count
317317
{
@@ -370,7 +370,7 @@ fn replace_types<'tcx>(
370370
if replaced.insert(param_ty.index) {
371371
for projection_predicate in projection_predicates {
372372
if projection_predicate.projection_term.self_ty() == param_ty.to_ty(cx.tcx)
373-
&& let Some(term_ty) = projection_predicate.term.ty()
373+
&& let Some(term_ty) = projection_predicate.term.as_type()
374374
&& let ty::Param(term_param_ty) = term_ty.kind()
375375
{
376376
let projection = projection_predicate

clippy_lints/src/unit_return_expecting_ord.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ fn get_args_to_check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Ve
100100
{
101101
if ord_preds
102102
.iter()
103-
.any(|ord| Some(ord.self_ty()) == return_ty_pred.term.ty())
103+
.any(|ord| Some(ord.self_ty()) == return_ty_pred.term.as_type())
104104
{
105105
args_to_check.push((i, "Ord".to_string()));
106106
} else if partial_ord_preds
107107
.iter()
108-
.any(|pord| pord.self_ty() == return_ty_pred.term.ty().unwrap())
108+
.any(|pord| pord.self_ty() == return_ty_pred.term.expect_type())
109109
{
110110
args_to_check.push((i, "PartialOrd".to_string()));
111111
}

clippy_utils/src/ty.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
750750
let output = bounds
751751
.projection_bounds()
752752
.find(|p| lang_items.fn_once_output().map_or(false, |id| id == p.item_def_id()))
753-
.map(|p| p.map_bound(|p| p.term.ty().unwrap()));
753+
.map(|p| p.map_bound(|p| p.term.expect_type()));
754754
Some(ExprFnSig::Trait(bound.map_bound(|b| b.args.type_at(0)), output, None))
755755
},
756756
_ => None,
@@ -798,7 +798,7 @@ fn sig_from_bounds<'tcx>(
798798
// Multiple different fn trait impls. Is this even allowed?
799799
return None;
800800
}
801-
output = Some(pred.kind().rebind(p.term.ty().unwrap()));
801+
output = Some(pred.kind().rebind(p.term.expect_type()));
802802
},
803803
_ => (),
804804
}
@@ -836,7 +836,7 @@ fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: AliasTy<'tcx>) -> Option
836836
// Multiple different fn trait impls. Is this even allowed?
837837
return None;
838838
}
839-
output = pred.kind().rebind(p.term.ty()).transpose();
839+
output = pred.kind().rebind(p.term.as_type()).transpose();
840840
},
841841
_ => (),
842842
}

0 commit comments

Comments
 (0)