Skip to content

Commit 760fbdf

Browse files
split out AliasTy -> AliasTerm
1 parent e65cefc commit 760fbdf

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

clippy_lints/src/methods/unnecessary_to_owned.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ fn get_input_traits_and_projections<'tcx>(
417417
}
418418
},
419419
ClauseKind::Projection(projection_predicate) => {
420-
if projection_predicate.projection_ty.self_ty() == input {
420+
if projection_predicate.projection_term.self_ty() == input {
421421
projection_predicates.push(projection_predicate);
422422
}
423423
},

clippy_lints/src/needless_borrows_for_generic_args.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,11 @@ fn is_mixed_projection_predicate<'tcx>(
320320
&& (term_param_ty.index as usize) < generics.parent_count
321321
{
322322
// The inner-most self type is a type parameter from the current function.
323-
let mut projection_ty = projection_predicate.projection_ty;
323+
let mut projection_ty = projection_predicate.projection_term;
324324
loop {
325-
match projection_ty.self_ty().kind() {
325+
match *projection_ty.self_ty().kind() {
326326
ty::Alias(ty::Projection, inner_projection_ty) => {
327-
projection_ty = *inner_projection_ty;
327+
projection_ty = inner_projection_ty.into();
328328
},
329329
ty::Param(param_ty) => {
330330
return (param_ty.index as usize) >= generics.parent_count;
@@ -404,14 +404,11 @@ fn replace_types<'tcx>(
404404
// The `replaced.insert(...)` check provides some protection against infinite loops.
405405
if replaced.insert(param_ty.index) {
406406
for projection_predicate in projection_predicates {
407-
if projection_predicate.projection_ty.self_ty() == param_ty.to_ty(cx.tcx)
407+
if projection_predicate.projection_term.self_ty() == param_ty.to_ty(cx.tcx)
408408
&& let Some(term_ty) = projection_predicate.term.ty()
409409
&& let ty::Param(term_param_ty) = term_ty.kind()
410410
{
411-
let projection = cx.tcx.mk_ty_from_kind(ty::Alias(
412-
ty::Projection,
413-
projection_predicate.projection_ty.with_self_ty(cx.tcx, new_ty),
414-
));
411+
let projection = projection_predicate.projection_term.with_self_ty(cx.tcx, new_ty).expect_ty(cx.tcx).to_ty(cx.tcx);
415412

416413
if let Ok(projected_ty) = cx.tcx.try_normalize_erasing_regions(cx.param_env, projection)
417414
&& args[term_param_ty.index as usize] != GenericArg::from(projected_ty)

clippy_lints/src/unit_return_expecting_ord.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn get_projection_pred<'tcx>(
6666
let projection_pred = cx
6767
.tcx
6868
.instantiate_bound_regions_with_erased(proj_pred.kind().rebind(pred));
69-
if projection_pred.projection_ty.args == trait_pred.trait_ref.args {
69+
if projection_pred.projection_term.args == trait_pred.trait_ref.args {
7070
return Some(projection_pred);
7171
}
7272
}

clippy_utils/src/ty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ fn sig_from_bounds<'tcx>(
795795
inputs = Some(i);
796796
},
797797
ty::ClauseKind::Projection(p)
798-
if Some(p.projection_ty.def_id) == lang_items.fn_once_output() && p.projection_ty.self_ty() == ty =>
798+
if Some(p.projection_term.def_id) == lang_items.fn_once_output() && p.projection_term.self_ty() == ty =>
799799
{
800800
if output.is_some() {
801801
// Multiple different fn trait impls. Is this even allowed?
@@ -834,7 +834,7 @@ fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: AliasTy<'tcx>) -> Option
834834
}
835835
inputs = Some(i);
836836
},
837-
ty::ClauseKind::Projection(p) if Some(p.projection_ty.def_id) == lang_items.fn_once_output() => {
837+
ty::ClauseKind::Projection(p) if Some(p.projection_term.def_id) == lang_items.fn_once_output() => {
838838
if output.is_some() {
839839
// Multiple different fn trait impls. Is this even allowed?
840840
return None;

0 commit comments

Comments
 (0)