Skip to content

Commit a5cd3bd

Browse files
committed
Ensure no one constructs AliasTys themselves
1 parent 4ffe3bd commit a5cd3bd

File tree

50 files changed

+104
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+104
-106
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
697697
.map_bound(|p| p.predicates),
698698
None,
699699
),
700-
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
700+
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
701701
find_fn_kind_from_did(tcx.bound_explicit_item_bounds(*def_id), Some(*substs))
702702
}
703703
ty::Closure(_, substs) => match substs.as_closure().kind() {

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
504504
let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
505505

506506
let mut output_ty = self.regioncx.universal_regions().unnormalized_output_ty;
507-
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) = *output_ty.kind() {
507+
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *output_ty.kind() {
508508
output_ty = self.infcx.tcx.type_of(def_id)
509509
};
510510

compiler/rustc_const_eval/src/transform/validate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
241241
};
242242

243243
let kind = match parent_ty.ty.kind() {
244-
&ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
244+
&ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
245245
self.tcx.bound_type_of(def_id).subst(self.tcx, substs).kind()
246246
}
247247
kind => kind,

compiler/rustc_const_eval/src/util/type_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
5858
// Types with identity (print the module path).
5959
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
6060
| ty::FnDef(def_id, substs)
61-
| ty::Alias(_, ty::AliasTy { def_id, substs })
61+
| ty::Alias(_, ty::AliasTy { def_id, substs, .. })
6262
| ty::Closure(def_id, substs)
6363
| ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
6464
ty::Foreign(def_id) => self.print_def_path(def_id, &[]),

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span) -> E
14401440
impl<'tcx> ty::visit::TypeVisitor<'tcx> for OpaqueTypeCollector {
14411441
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
14421442
match *t.kind() {
1443-
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, substs: _ }) => {
1443+
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
14441444
self.0.push(def);
14451445
ControlFlow::CONTINUE
14461446
}

compiler/rustc_hir_analysis/src/variance/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
111111
#[instrument(level = "trace", skip(self), ret)]
112112
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
113113
match t.kind() {
114-
ty::Alias(_, ty::AliasTy { def_id, substs })
114+
ty::Alias(_, ty::AliasTy { def_id, substs, .. })
115115
if matches!(
116116
self.tcx.def_kind(*def_id),
117117
DefKind::OpaqueTy | DefKind::ImplTraitPlaceholder
@@ -169,7 +169,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
169169
}
170170
}
171171
ty::PredicateKind::Clause(ty::Clause::Projection(ty::ProjectionPredicate {
172-
projection_ty: ty::AliasTy { substs, def_id: _ },
172+
projection_ty: ty::AliasTy { substs, .. },
173173
term,
174174
})) => {
175175
for subst in &substs[1..] {

compiler/rustc_hir_typeck/src/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
518518

519519
let substs = sig.output().walk().find_map(|arg| {
520520
if let ty::GenericArgKind::Type(ty) = arg.unpack()
521-
&& let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) = *ty.kind()
521+
&& let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) = *ty.kind()
522522
&& def_id == rpit_def_id
523523
{
524524
Some(substs)

compiler/rustc_hir_typeck/src/closure.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
167167
expected_ty: Ty<'tcx>,
168168
) -> (Option<ExpectedSig<'tcx>>, Option<ty::ClosureKind>) {
169169
match *expected_ty.kind() {
170-
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => self
170+
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => self
171171
.deduce_signature_from_predicates(
172172
self.tcx.bound_explicit_item_bounds(def_id).subst_iter_copied(self.tcx, substs),
173173
),
@@ -678,7 +678,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
678678
get_future_output(obligation.predicate, obligation.cause.span)
679679
})?
680680
}
681-
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => self
681+
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => self
682682
.tcx
683683
.bound_explicit_item_bounds(def_id)
684684
.subst_iter_copied(self.tcx, substs)

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1805,7 +1805,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
18051805
{
18061806
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(fcx, ty);
18071807
// Get the `impl Trait`'s `DefId`.
1808-
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) = ty.kind()
1808+
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind()
18091809
// Get the `impl Trait`'s `Item` so that we can get its trait bounds and
18101810
// get the `Trait`'s `DefId`.
18111811
&& let hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds, .. }) =

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2391,7 +2391,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23912391
ty::Param(param_ty) => {
23922392
self.point_at_param_definition(&mut err, param_ty);
23932393
}
2394-
ty::Alias(ty::Opaque, ty::AliasTy { def_id: _, substs: _ }) => {
2394+
ty::Alias(ty::Opaque, _) => {
23952395
self.suggest_await_on_field_access(&mut err, ident, base, base_ty.peel_refs());
23962396
}
23972397
_ => {}

0 commit comments

Comments
 (0)