Align Term methods with GenericArg methods

This commit is contained in:
Michael Goulet 2024-05-29 22:23:49 -04:00
parent e94779a396
commit 9f4a2dd147
4 changed files with 8 additions and 8 deletions

View file

@ -42,7 +42,7 @@ fn is_arg_ty_unified_in_fn<'tcx>(
cx.tcx.predicates_of(fn_id).predicates.iter().any(|(clause, _)| {
clause
.as_projection_clause()
.and_then(|p| p.map_bound(|p| p.term.ty()).transpose())
.and_then(|p| p.map_bound(|p| p.term.as_type()).transpose())
.is_some_and(|ty| ty.skip_binder() == arg_ty_in_args)
}) || fn_sig
.inputs()

View file

@ -311,7 +311,7 @@ fn is_mixed_projection_predicate<'tcx>(
) -> bool {
let generics = cx.tcx.generics_of(callee_def_id);
// The predicate requires the projected type to equal a type parameter from the parent context.
if let Some(term_ty) = projection_predicate.term.ty()
if let Some(term_ty) = projection_predicate.term.as_type()
&& let ty::Param(term_param_ty) = term_ty.kind()
&& (term_param_ty.index as usize) < generics.parent_count
{
@ -370,7 +370,7 @@ fn replace_types<'tcx>(
if replaced.insert(param_ty.index) {
for projection_predicate in projection_predicates {
if projection_predicate.projection_term.self_ty() == param_ty.to_ty(cx.tcx)
&& let Some(term_ty) = projection_predicate.term.ty()
&& let Some(term_ty) = projection_predicate.term.as_type()
&& let ty::Param(term_param_ty) = term_ty.kind()
{
let projection = projection_predicate

View file

@ -100,12 +100,12 @@ fn get_args_to_check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Ve
{
if ord_preds
.iter()
.any(|ord| Some(ord.self_ty()) == return_ty_pred.term.ty())
.any(|ord| Some(ord.self_ty()) == return_ty_pred.term.as_type())
{
args_to_check.push((i, "Ord".to_string()));
} else if partial_ord_preds
.iter()
.any(|pord| pord.self_ty() == return_ty_pred.term.ty().unwrap())
.any(|pord| pord.self_ty() == return_ty_pred.term.expect_type())
{
args_to_check.push((i, "PartialOrd".to_string()));
}

View file

@ -750,7 +750,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
let output = bounds
.projection_bounds()
.find(|p| lang_items.fn_once_output().map_or(false, |id| id == p.item_def_id()))
.map(|p| p.map_bound(|p| p.term.ty().unwrap()));
.map(|p| p.map_bound(|p| p.term.expect_type()));
Some(ExprFnSig::Trait(bound.map_bound(|b| b.args.type_at(0)), output, None))
},
_ => None,
@ -798,7 +798,7 @@ fn sig_from_bounds<'tcx>(
// Multiple different fn trait impls. Is this even allowed?
return None;
}
output = Some(pred.kind().rebind(p.term.ty().unwrap()));
output = Some(pred.kind().rebind(p.term.expect_type()));
},
_ => (),
}
@ -836,7 +836,7 @@ fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: AliasTy<'tcx>) -> Option
// Multiple different fn trait impls. Is this even allowed?
return None;
}
output = pred.kind().rebind(p.term.ty()).transpose();
output = pred.kind().rebind(p.term.as_type()).transpose();
},
_ => (),
}