Skip to content

Commit 957ab6a

Browse files
Combine projection and opaque into alias
1 parent 89b8840 commit 957ab6a

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

clippy_lints/src/dereference.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ fn is_mixed_projection_predicate<'tcx>(
12441244
let mut projection_ty = projection_predicate.projection_ty;
12451245
loop {
12461246
match projection_ty.self_ty().kind() {
1247-
ty::Projection(inner_projection_ty) => {
1247+
ty::Alias(ty::Projection, inner_projection_ty) => {
12481248
projection_ty = *inner_projection_ty;
12491249
}
12501250
ty::Param(param_ty) => {
@@ -1390,8 +1390,8 @@ fn ty_auto_deref_stability<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, precedenc
13901390
continue;
13911391
},
13921392
ty::Param(_) => TyPosition::new_deref_stable_for_result(precedence, ty),
1393-
ty::Projection(_) if ty.has_non_region_param() => TyPosition::new_deref_stable_for_result(precedence, ty),
1394-
ty::Infer(_) | ty::Error(_) | ty::Bound(..) | ty::Opaque(..) | ty::Placeholder(_) | ty::Dynamic(..) => {
1393+
ty::Alias(ty::Projection, _) if ty.has_non_region_param() => TyPosition::new_deref_stable_for_result(precedence, ty),
1394+
ty::Infer(_) | ty::Error(_) | ty::Bound(..) | ty::Alias(ty::Opaque, ..) | ty::Placeholder(_) | ty::Dynamic(..) => {
13951395
Position::ReborrowStable(precedence).into()
13961396
},
13971397
ty::Adt(..) if ty.has_placeholders() || ty.has_opaque_types() => {
@@ -1417,7 +1417,7 @@ fn ty_auto_deref_stability<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, precedenc
14171417
| ty::Closure(..)
14181418
| ty::Never
14191419
| ty::Tuple(_)
1420-
| ty::Projection(_) => {
1420+
| ty::Alias(ty::Projection, _) => {
14211421
Position::DerefStable(precedence, ty.is_sized(cx.tcx, cx.param_env.without_caller_bounds())).into()
14221422
},
14231423
};

clippy_lints/src/future_not_send.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_hir::intravisit::FnKind;
44
use rustc_hir::{Body, FnDecl, HirId};
55
use rustc_infer::infer::TyCtxtInferExt;
66
use rustc_lint::{LateContext, LateLintPass};
7-
use rustc_middle::ty::{AliasTy, Clause, EarlyBinder, Opaque, PredicateKind};
7+
use rustc_middle::ty::{self, AliasTy, Clause, EarlyBinder, PredicateKind};
88
use rustc_session::{declare_lint_pass, declare_tool_lint};
99
use rustc_span::{sym, Span};
1010
use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt;
@@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
6262
return;
6363
}
6464
let ret_ty = return_ty(cx, hir_id);
65-
if let Opaque(AliasTy { def_id, substs }) = *ret_ty.kind() {
65+
if let ty::Alias(ty::Opaque, AliasTy { def_id, substs }) = *ret_ty.kind() {
6666
let preds = cx.tcx.explicit_item_bounds(def_id);
6767
let mut is_future = false;
6868
for &(p, _span) in preds {

clippy_lints/src/len_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
493493
.filter_by_name_unhygienic(is_empty)
494494
.any(|item| is_is_empty(cx, item))
495495
}),
496-
ty::Projection(ref proj) => has_is_empty_impl(cx, proj.def_id),
496+
ty::Alias(ty::Projection, ref proj) => has_is_empty_impl(cx, proj.def_id),
497497
ty::Adt(id, _) => has_is_empty_impl(cx, id.did()),
498498
ty::Array(..) | ty::Slice(..) | ty::Str => true,
499499
_ => false,

clippy_utils/src/qualify_min_const_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn check_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) -> McfResult {
8282
ty::Ref(_, _, hir::Mutability::Mut) => {
8383
return Err((span, "mutable references in const fn are unstable".into()));
8484
},
85-
ty::Opaque(..) => return Err((span, "`impl Trait` in const fn is unstable".into())),
85+
ty::Alias(ty::Opaque, ..) => return Err((span, "`impl Trait` in const fn is unstable".into())),
8686
ty::FnPtr(..) => {
8787
return Err((span, "function pointers in const fn are unstable".into()));
8888
},

clippy_utils/src/ty.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
7979
return true;
8080
}
8181

82-
if let ty::Opaque(ty::AliasTy { def_id, substs: _ }) = *inner_ty.kind() {
82+
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) = *inner_ty.kind() {
8383
for &(predicate, _span) in cx.tcx.explicit_item_bounds(def_id) {
8484
match predicate.kind().skip_binder() {
8585
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through
@@ -250,7 +250,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
250250
is_must_use_ty(cx, *ty)
251251
},
252252
ty::Tuple(substs) => substs.iter().any(|ty| is_must_use_ty(cx, ty)),
253-
ty::Opaque(ty::AliasTy { def_id, substs: _ }) => {
253+
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) => {
254254
for (predicate, _) in cx.tcx.explicit_item_bounds(*def_id) {
255255
if let ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() {
256256
if cx.tcx.has_attr(trait_predicate.trait_ref.def_id, sym::must_use) {
@@ -631,7 +631,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
631631
Some(ExprFnSig::Closure(decl, subs.as_closure().sig()))
632632
},
633633
ty::FnDef(id, subs) => Some(ExprFnSig::Sig(cx.tcx.bound_fn_sig(id).subst(cx.tcx, subs), Some(id))),
634-
ty::Opaque(ty::AliasTy { def_id, substs: _ }) => sig_from_bounds(cx, ty, cx.tcx.item_bounds(def_id), cx.tcx.opt_parent(def_id)),
634+
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) => sig_from_bounds(cx, ty, cx.tcx.item_bounds(def_id), cx.tcx.opt_parent(def_id)),
635635
ty::FnPtr(sig) => Some(ExprFnSig::Sig(sig, None)),
636636
ty::Dynamic(bounds, _, _) => {
637637
let lang_items = cx.tcx.lang_items();
@@ -650,7 +650,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
650650
_ => None,
651651
}
652652
},
653-
ty::Projection(proj) => match cx.tcx.try_normalize_erasing_regions(cx.param_env, ty) {
653+
ty::Alias(ty::Projection, proj) => match cx.tcx.try_normalize_erasing_regions(cx.param_env, ty) {
654654
Ok(normalized_ty) if normalized_ty != ty => ty_sig(cx, normalized_ty),
655655
_ => sig_for_projection(cx, proj).or_else(|| sig_from_bounds(cx, ty, cx.param_env.caller_bounds(), None)),
656656
},

0 commit comments

Comments
 (0)