Skip to content

Commit 9fb0bff

Browse files
committed
Use Term in ProjectionPredicate
ProjectionPredicate should be able to handle both associated types and consts so this adds the first step of that. It mainly just pipes types all the way down, not entirely sure how to handle consts, but hopefully that'll come with time.
1 parent 05b8c72 commit 9fb0bff

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

clippy_lints/src/manual_async_fn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use if_chain::if_chain;
66
use rustc_errors::Applicability;
77
use rustc_hir::intravisit::FnKind;
88
use rustc_hir::{
9-
AsyncGeneratorKind, Block, Body, Expr, ExprKind, FnDecl, FnRetTy, GeneratorKind, GenericArg, GenericBound, HirId,
9+
Term, AsyncGeneratorKind, Block, Body, Expr, ExprKind, FnDecl, FnRetTy, GeneratorKind, GenericArg, GenericBound, HirId,
1010
IsAsync, ItemKind, LifetimeName, TraitRef, Ty, TyKind, TypeBindingKind,
1111
};
1212
use rustc_lint::{LateContext, LateLintPass};
@@ -140,7 +140,7 @@ fn future_output_ty<'tcx>(trait_ref: &'tcx TraitRef<'tcx>) -> Option<&'tcx Ty<'t
140140
if args.bindings.len() == 1;
141141
let binding = &args.bindings[0];
142142
if binding.ident.name == sym::Output;
143-
if let TypeBindingKind::Equality{ty: output} = binding.kind;
143+
if let TypeBindingKind::Equality{term: Term::Ty(output)} = binding.kind;
144144
then {
145145
return Some(output)
146146
}

clippy_lints/src/methods/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,10 +2143,10 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
21432143
if let ty::PredicateKind::Projection(projection_predicate) = predicate.kind().skip_binder() {
21442144
// walk the associated type and check for Self
21452145
if let Some(self_adt) = self_ty.ty_adt_def() {
2146-
if contains_adt_constructor(projection_predicate.ty, self_adt) {
2146+
if contains_adt_constructor(projection_predicate.term.ty(), self_adt) {
21472147
return;
21482148
}
2149-
} else if contains_ty(projection_predicate.ty, self_ty) {
2149+
} else if contains_ty(projection_predicate.term.ty(), self_ty) {
21502150
return;
21512151
}
21522152
}

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ fn check_other_call_arg<'tcx>(
243243
if if trait_predicate.def_id() == deref_trait_id {
244244
if let [projection_predicate] = projection_predicates[..] {
245245
let normalized_ty =
246-
cx.tcx.subst_and_normalize_erasing_regions(call_substs, cx.param_env, projection_predicate.ty);
246+
cx.tcx.subst_and_normalize_erasing_regions(call_substs, cx.param_env, projection_predicate.term.ty());
247247
implements_trait(cx, receiver_ty, deref_trait_id, &[])
248248
&& get_associated_type(cx, receiver_ty, deref_trait_id, "Target") == Some(normalized_ty)
249249
} else {

clippy_lints/src/unit_return_expecting_ord.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ fn get_args_to_check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Ve
9898
if trait_pred.self_ty() == inp;
9999
if let Some(return_ty_pred) = get_projection_pred(cx, generics, *trait_pred);
100100
then {
101-
if ord_preds.iter().any(|ord| ord.self_ty() == return_ty_pred.ty) {
101+
if ord_preds.iter().any(|ord| ord.self_ty() == return_ty_pred.term.ty()) {
102102
args_to_check.push((i, "Ord".to_string()));
103-
} else if partial_ord_preds.iter().any(|pord| pord.self_ty() == return_ty_pred.ty) {
103+
} else if partial_ord_preds.iter().any(|pord| pord.self_ty() == return_ty_pred.term.ty()) {
104104
args_to_check.push((i, "PartialOrd".to_string()));
105105
}
106106
}

0 commit comments

Comments
 (0)