Skip to content

Commit 65069d5

Browse files
committed
Ensure no one constructs AliasTys themselves
1 parent 957ab6a commit 65069d5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

clippy_lints/src/future_not_send.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 ty::Alias(ty::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_utils/src/ty.rs

Lines changed: 6 additions & 6 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::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) = *inner_ty.kind() {
82+
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *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::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) => {
253+
ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => {
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::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)),
634+
ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => 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();
@@ -1039,10 +1039,10 @@ pub fn make_projection<'tcx>(
10391039
}
10401040
}
10411041

1042-
Some(AliasTy {
1042+
Some(tcx.mk_alias_ty(
1043+
assoc_item.def_id,
10431044
substs,
1044-
def_id: assoc_item.def_id,
1045-
})
1045+
))
10461046
}
10471047
helper(
10481048
tcx,

0 commit comments

Comments
 (0)