Skip to content

Commit

Permalink
split out AliasTy -> AliasTerm
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed May 13, 2024
1 parent e65cefc commit 760fbdf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/unnecessary_to_owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ fn get_input_traits_and_projections<'tcx>(
}
},
ClauseKind::Projection(projection_predicate) => {
if projection_predicate.projection_ty.self_ty() == input {
if projection_predicate.projection_term.self_ty() == input {
projection_predicates.push(projection_predicate);
}
},
Expand Down
13 changes: 5 additions & 8 deletions clippy_lints/src/needless_borrows_for_generic_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,11 @@ fn is_mixed_projection_predicate<'tcx>(
&& (term_param_ty.index as usize) < generics.parent_count
{
// The inner-most self type is a type parameter from the current function.
let mut projection_ty = projection_predicate.projection_ty;
let mut projection_ty = projection_predicate.projection_term;
loop {
match projection_ty.self_ty().kind() {
match *projection_ty.self_ty().kind() {
ty::Alias(ty::Projection, inner_projection_ty) => {
projection_ty = *inner_projection_ty;
projection_ty = inner_projection_ty.into();
},
ty::Param(param_ty) => {
return (param_ty.index as usize) >= generics.parent_count;
Expand Down Expand Up @@ -404,14 +404,11 @@ fn replace_types<'tcx>(
// The `replaced.insert(...)` check provides some protection against infinite loops.
if replaced.insert(param_ty.index) {
for projection_predicate in projection_predicates {
if projection_predicate.projection_ty.self_ty() == param_ty.to_ty(cx.tcx)
if projection_predicate.projection_term.self_ty() == param_ty.to_ty(cx.tcx)
&& let Some(term_ty) = projection_predicate.term.ty()
&& let ty::Param(term_param_ty) = term_ty.kind()
{
let projection = cx.tcx.mk_ty_from_kind(ty::Alias(
ty::Projection,
projection_predicate.projection_ty.with_self_ty(cx.tcx, new_ty),
));
let projection = projection_predicate.projection_term.with_self_ty(cx.tcx, new_ty).expect_ty(cx.tcx).to_ty(cx.tcx);

if let Ok(projected_ty) = cx.tcx.try_normalize_erasing_regions(cx.param_env, projection)
&& args[term_param_ty.index as usize] != GenericArg::from(projected_ty)
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/unit_return_expecting_ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn get_projection_pred<'tcx>(
let projection_pred = cx
.tcx
.instantiate_bound_regions_with_erased(proj_pred.kind().rebind(pred));
if projection_pred.projection_ty.args == trait_pred.trait_ref.args {
if projection_pred.projection_term.args == trait_pred.trait_ref.args {
return Some(projection_pred);
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_utils/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ fn sig_from_bounds<'tcx>(
inputs = Some(i);
},
ty::ClauseKind::Projection(p)
if Some(p.projection_ty.def_id) == lang_items.fn_once_output() && p.projection_ty.self_ty() == ty =>
if Some(p.projection_term.def_id) == lang_items.fn_once_output() && p.projection_term.self_ty() == ty =>
{
if output.is_some() {
// Multiple different fn trait impls. Is this even allowed?
Expand Down Expand Up @@ -834,7 +834,7 @@ fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: AliasTy<'tcx>) -> Option
}
inputs = Some(i);
},
ty::ClauseKind::Projection(p) if Some(p.projection_ty.def_id) == lang_items.fn_once_output() => {
ty::ClauseKind::Projection(p) if Some(p.projection_term.def_id) == lang_items.fn_once_output() => {
if output.is_some() {
// Multiple different fn trait impls. Is this even allowed?
return None;
Expand Down

0 comments on commit 760fbdf

Please sign in to comment.