]> git.lizzy.rs Git - rust.git/commitdiff
Ensure no one constructs `AliasTy`s themselves
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 13 Dec 2022 11:07:42 +0000 (11:07 +0000)
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Wed, 14 Dec 2022 15:36:39 +0000 (15:36 +0000)
50 files changed:
compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
compiler/rustc_borrowck/src/diagnostics/region_errors.rs
compiler/rustc_const_eval/src/transform/validate.rs
compiler/rustc_const_eval/src/util/type_name.rs
compiler/rustc_hir_analysis/src/check/check.rs
compiler/rustc_hir_analysis/src/variance/mod.rs
compiler/rustc_hir_typeck/src/_match.rs
compiler/rustc_hir_typeck/src/closure.rs
compiler/rustc_hir_typeck/src/coercion.rs
compiler/rustc_hir_typeck/src/expr.rs
compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
compiler/rustc_hir_typeck/src/generator_interior/mod.rs
compiler/rustc_hir_typeck/src/writeback.rs
compiler/rustc_infer/src/infer/combine.rs
compiler/rustc_infer/src/infer/equate.rs
compiler/rustc_infer/src/infer/error_reporting/mod.rs
compiler/rustc_infer/src/infer/error_reporting/suggest.rs
compiler/rustc_infer/src/infer/lattice.rs
compiler/rustc_infer/src/infer/nll_relate/mod.rs
compiler/rustc_infer/src/infer/opaque_types.rs
compiler/rustc_infer/src/infer/outlives/components.rs
compiler/rustc_infer/src/infer/outlives/obligations.rs
compiler/rustc_infer/src/infer/sub.rs
compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs
compiler/rustc_lint/src/unused.rs
compiler/rustc_middle/src/ty/context.rs
compiler/rustc_middle/src/ty/diagnostics.rs
compiler/rustc_middle/src/ty/error.rs
compiler/rustc_middle/src/ty/flags.rs
compiler/rustc_middle/src/ty/print/pretty.rs
compiler/rustc_middle/src/ty/relate.rs
compiler/rustc_middle/src/ty/sty.rs
compiler/rustc_middle/src/ty/util.rs
compiler/rustc_mir_transform/src/inline.rs
compiler/rustc_privacy/src/lib.rs
compiler/rustc_symbol_mangling/src/legacy.rs
compiler/rustc_symbol_mangling/src/v0.rs
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
compiler/rustc_trait_selection/src/traits/project.rs
compiler/rustc_trait_selection/src/traits/query/normalize.rs
compiler/rustc_trait_selection/src/traits/select/confirmation.rs
compiler/rustc_trait_selection/src/traits/select/mod.rs
compiler/rustc_trait_selection/src/traits/wf.rs
compiler/rustc_traits/src/chalk/db.rs
compiler/rustc_traits/src/chalk/lowering.rs
src/librustdoc/clean/mod.rs
src/tools/clippy/clippy_lints/src/future_not_send.rs
src/tools/clippy/clippy_utils/src/ty.rs

index a92cb6bb38d4766ac9c919e07a732e84aa65d5cd..72c0257756ef2f15d1adfdc8f47a2e143ced6ccc 100644 (file)
@@ -697,7 +697,7 @@ fn suggest_borrow_fn_like(
                     .map_bound(|p| p.predicates),
                 None,
             ),
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
                 find_fn_kind_from_did(tcx.bound_explicit_item_bounds(*def_id), Some(*substs))
             }
             ty::Closure(_, substs) => match substs.as_closure().kind() {
index e6520301818d82beb2bb99c754fa3b6f7eedf945..f8ec5e5e799149c888e001dd4ddc1b488847c8d2 100644 (file)
@@ -504,7 +504,7 @@ fn report_fnmut_error(
         let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
 
         let mut output_ty = self.regioncx.universal_regions().unnormalized_output_ty;
-        if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) = *output_ty.kind() {
+        if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *output_ty.kind() {
             output_ty = self.infcx.tcx.type_of(def_id)
         };
 
index decddf47b715d7a9f4aff4df1f52ee0a7f48c6a3..bb897b95b2c53cd1122663b41945764ccd354960 100644 (file)
@@ -241,7 +241,7 @@ fn visit_projection_elem(
                 };
 
                 let kind = match parent_ty.ty.kind() {
-                    &ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
+                    &ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
                         self.tcx.bound_type_of(def_id).subst(self.tcx, substs).kind()
                     }
                     kind => kind,
index dd65d4fd591e547a93089cff9fa0e0ac27690ece..c4122f66498143a70950219d6afb696c91d58f40 100644 (file)
@@ -58,7 +58,7 @@ fn print_type(mut self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error> {
             // Types with identity (print the module path).
             ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
             | ty::FnDef(def_id, substs)
-            | ty::Alias(_, ty::AliasTy { def_id, substs })
+            | ty::Alias(_, ty::AliasTy { def_id, substs, .. })
             | ty::Closure(def_id, substs)
             | ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
             ty::Foreign(def_id) => self.print_def_path(def_id, &[]),
index dd841707b29069e3510d38db347891b553afa1c5..26e6ed205d57e7d0f9ccd1426bc87739074a7402 100644 (file)
@@ -1440,7 +1440,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span) -> E
                 impl<'tcx> ty::visit::TypeVisitor<'tcx> for OpaqueTypeCollector {
                     fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
                         match *t.kind() {
-                            ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, substs: _ }) => {
+                            ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
                                 self.0.push(def);
                                 ControlFlow::CONTINUE
                             }
index 3c29c72841e44579ce491c1e28ba2cac9283e6ed..263d8deb9b48a03c61dab116c8c4d30a15db4dd3 100644 (file)
@@ -111,7 +111,7 @@ fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
         #[instrument(level = "trace", skip(self), ret)]
         fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
             match t.kind() {
-                ty::Alias(_, ty::AliasTy { def_id, substs })
+                ty::Alias(_, ty::AliasTy { def_id, substs, .. })
                     if matches!(
                         self.tcx.def_kind(*def_id),
                         DefKind::OpaqueTy | DefKind::ImplTraitPlaceholder
@@ -169,7 +169,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
                 }
             }
             ty::PredicateKind::Clause(ty::Clause::Projection(ty::ProjectionPredicate {
-                projection_ty: ty::AliasTy { substs, def_id: _ },
+                projection_ty: ty::AliasTy { substs, .. },
                 term,
             })) => {
                 for subst in &substs[1..] {
index 36ae5d67f57c704b1454293734e96b6496852f0a..ab12cae4e2b08a0b48fc57e8b687f841b7b59509 100644 (file)
@@ -518,7 +518,7 @@ pub(crate) fn opt_suggest_box_span(
 
                 let substs = sig.output().walk().find_map(|arg| {
                     if let ty::GenericArgKind::Type(ty) = arg.unpack()
-                        && let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) = *ty.kind()
+                        && let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) = *ty.kind()
                         && def_id == rpit_def_id
                     {
                         Some(substs)
index a96d27868a6d50d128ec8f1230c5a0825c7b91fa..72d8a936ab39db2adcc5b8f4970fcdc705b638ba 100644 (file)
@@ -167,7 +167,7 @@ fn deduce_expectations_from_expected_type(
         expected_ty: Ty<'tcx>,
     ) -> (Option<ExpectedSig<'tcx>>, Option<ty::ClosureKind>) {
         match *expected_ty.kind() {
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => self
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => self
                 .deduce_signature_from_predicates(
                     self.tcx.bound_explicit_item_bounds(def_id).subst_iter_copied(self.tcx, substs),
                 ),
@@ -678,7 +678,7 @@ fn deduce_future_output_from_obligations(
                     get_future_output(obligation.predicate, obligation.cause.span)
                 })?
             }
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => self
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => self
                 .tcx
                 .bound_explicit_item_bounds(def_id)
                 .subst_iter_copied(self.tcx, substs)
index a4ca7571142b6b1ea2c165521d834c01c3fa8377..36cf4791492dd1c8c8b36d1125289dc008cb3fed 100644 (file)
@@ -1805,7 +1805,7 @@ fn add_impl_trait_explanation<'a>(
         {
             let ty = <dyn AstConv<'_>>::ast_ty_to_ty(fcx, ty);
             // Get the `impl Trait`'s `DefId`.
-            if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) = ty.kind()
+            if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind()
                 // Get the `impl Trait`'s `Item` so that we can get its trait bounds and
                 // get the `Trait`'s `DefId`.
                 && let hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds, .. }) =
index 4e2a78562240710741f64a61f99c76a75550fb4b..866090260b2723dad6ef078f500805ab69b7d46c 100644 (file)
@@ -2391,7 +2391,7 @@ fn ban_nonexisting_field(
             ty::Param(param_ty) => {
                 self.point_at_param_definition(&mut err, param_ty);
             }
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id: _, substs: _ }) => {
+            ty::Alias(ty::Opaque, _) => {
                 self.suggest_await_on_field_access(&mut err, ident, base, base_ty.peel_refs());
             }
             _ => {}
index c8ea8ba5ab0655837ce7c16617890516e8c25e01..1a4e6bf763821b05ee33737dc392ef35d145eb8a 100644 (file)
@@ -716,7 +716,7 @@ pub(in super::super) fn expected_inputs_for_expected_output(
         if formal_ret.has_infer_types() {
             for ty in ret_ty.walk() {
                 if let ty::subst::GenericArgKind::Type(ty) = ty.unpack()
-                    && let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) = *ty.kind()
+                    && let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *ty.kind()
                     && let Some(def_id) = def_id.as_local()
                     && self.opaque_type_origin(def_id, DUMMY_SP).is_some() {
                     return None;
index 615f374b2ec0b8e3f2c34d63247424d4a4f9dd12..6f0e8eb9039a56e24f302f17ddc3e3edab2366f5 100644 (file)
@@ -2124,7 +2124,7 @@ fn label_fn_like(
                         }
                     }
                 }
-                ty::Alias(ty::Opaque, ty::AliasTy { def_id: new_def_id, substs: _ })
+                ty::Alias(ty::Opaque, ty::AliasTy { def_id: new_def_id, .. })
                 | ty::Closure(new_def_id, _)
                 | ty::FnDef(new_def_id, _) => {
                     def_id = new_def_id;
index e6e1098e33d74057a0615355aaacc1f7a497c3a8..55798f281fb983956ecee987c5f220ad4c31919a 100644 (file)
@@ -174,7 +174,7 @@ pub(in super::super) fn extract_callable_info(
                     let fn_sig = substs.as_closure().sig();
                     Some((DefIdOrName::DefId(def_id), fn_sig.output(), fn_sig.inputs().map_bound(|inputs| &inputs[1..])))
                 }
-                ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
+                ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
                     self.tcx.bound_item_bounds(def_id).subst(self.tcx, substs).iter().find_map(|pred| {
                         if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = pred.kind().skip_binder()
                         && Some(proj.projection_ty.def_id) == self.tcx.lang_items().fn_once_output()
index d83b9eb995d2b687e2502191122f00e4e91ffd8c..93f2ceed777b5be20bda25798be7d198ef998950 100644 (file)
@@ -563,7 +563,7 @@ fn check_must_not_suspend_ty<'tcx>(
         }
         ty::Adt(def, _) => check_must_not_suspend_def(fcx.tcx, def.did(), hir_id, data),
         // FIXME: support adding the attribute to TAITs
-        ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, substs: _ }) => {
+        ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
             let mut has_emitted = false;
             for &(predicate, _) in fcx.tcx.explicit_item_bounds(def) {
                 // We only look at the `DefId`, so it is safe to skip the binder here.
index d25d9672c36d05ef7e638be2860812a0cfe671a3..bb956ddc780423876eca53ec2fc209aaed365aa8 100644 (file)
@@ -546,7 +546,7 @@ struct RecursionChecker {
             impl<'tcx> ty::TypeVisitor<'tcx> for RecursionChecker {
                 type BreakTy = ();
                 fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
-                    if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) = *t.kind() {
+                    if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *t.kind() {
                         if def_id == self.def_id.to_def_id() {
                             return ControlFlow::Break(());
                         }
index 316077f69d99b65ffc8fb15c4bd43c1853b60c34..9a1c49c1aa6af24feb4625f718fc2a29acbdc2aa 100644 (file)
@@ -675,7 +675,7 @@ fn tys(&mut self, t: Ty<'tcx>, t2: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
                 // relatable.
                 Ok(t)
             }
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
                 let s = self.relate(substs, substs)?;
                 Ok(if s == substs { t } else { self.infcx.tcx.mk_opaque(def_id, s) })
             }
index 9fd4bdee096ac81dc36862ab93218da4d7019b07..46e7813d99e562cd1cff9b39b0224eaa75048fb1 100644 (file)
@@ -101,13 +101,13 @@ fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
             }
 
             (
-                &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, substs: _ }),
-                &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, substs: _ }),
+                &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }),
+                &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }),
             ) if a_def_id == b_def_id => {
                 self.fields.infcx.super_combine_tys(self, a, b)?;
             }
-            (&ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }), _)
-            | (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }))
+            (&ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _)
+            | (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }))
                 if self.fields.define_opaque_types && def_id.is_local() =>
             {
                 self.fields.obligations.extend(
index 3d2b2c6ff2dad9a56cc8ab22144158d0ffb03c93..397fa43175f732b3d87e566678388b0fbcd342d8 100644 (file)
@@ -339,7 +339,7 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
 impl<'tcx> InferCtxt<'tcx> {
     pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
         let (def_id, substs) = match *ty.kind() {
-            ty::Alias(_, ty::AliasTy { def_id, substs })
+            ty::Alias(_, ty::AliasTy { def_id, substs, .. })
                 if matches!(
                     self.tcx.def_kind(def_id),
                     DefKind::OpaqueTy | DefKind::ImplTraitPlaceholder
@@ -2767,9 +2767,7 @@ fn descr(&self) -> &'static str {
     pub fn from_ty(tcx: TyCtxt<'_>, ty: Ty<'_>) -> Option<(Self, DefId)> {
         match *ty.kind() {
             ty::Closure(def_id, _) => Some((Self::Closure, def_id)),
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) => {
-                Some((Self::Opaque, def_id))
-            }
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => Some((Self::Opaque, def_id)),
             ty::Generator(def_id, ..) => {
                 Some((Self::Generator(tcx.generator_kind(def_id).unwrap()), def_id))
             }
index 62655d11ca309fd448cd44c8c7dfc4c85e4585fd..30ca9f41d6e6f8d73830b5c2b98150ee61e5dd05 100644 (file)
@@ -487,12 +487,12 @@ pub fn could_remove_semicolon(
                 StatementAsExpression::CorrectType
             }
             (
-                ty::Alias(ty::Opaque, ty::AliasTy { def_id: last_def_id, substs: _ }),
-                ty::Alias(ty::Opaque, ty::AliasTy { def_id: exp_def_id, substs: _ }),
+                ty::Alias(ty::Opaque, ty::AliasTy { def_id: last_def_id, .. }),
+                ty::Alias(ty::Opaque, ty::AliasTy { def_id: exp_def_id, .. }),
             ) if last_def_id == exp_def_id => StatementAsExpression::CorrectType,
             (
-                ty::Alias(ty::Opaque, ty::AliasTy { def_id: last_def_id, substs: last_bounds }),
-                ty::Alias(ty::Opaque, ty::AliasTy { def_id: exp_def_id, substs: exp_bounds }),
+                ty::Alias(ty::Opaque, ty::AliasTy { def_id: last_def_id, substs: last_bounds, .. }),
+                ty::Alias(ty::Opaque, ty::AliasTy { def_id: exp_def_id, substs: exp_bounds, .. }),
             ) => {
                 debug!(
                     "both opaque, likely future {:?} {:?} {:?} {:?}",
index 47d76dc5bdf02904cebcff63dd042038284cd0d4..0ebc6d55bcba952678c86e6ff3c1dba91d8a11bd 100644 (file)
@@ -106,11 +106,11 @@ pub fn super_lattice_tys<'a, 'tcx: 'a, L>(
         }
 
         (
-            &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, substs: _ }),
-            &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, substs: _ }),
+            &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }),
+            &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }),
         ) if a_def_id == b_def_id => infcx.super_combine_tys(this, a, b),
-        (&ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }), _)
-        | (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }))
+        (&ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _)
+        | (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }))
             if this.define_opaque_types() && def_id.is_local() =>
         {
             this.add_obligations(
index 3b9683e5b59333542f09347aaeaf123bd9b7295a..1f9d86a78d6e50912f7cc3dba6e0b006391a33aa 100644 (file)
@@ -611,8 +611,8 @@ fn tys(&mut self, a: Ty<'tcx>, mut b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>>
             (&ty::Infer(ty::TyVar(vid)), _) => self.relate_ty_var((vid, b)),
 
             (
-                &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, substs: _ }),
-                &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, substs: _ }),
+                &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }),
+                &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }),
             ) if a_def_id == b_def_id => infcx.super_combine_tys(self, a, b).or_else(|err| {
                 self.tcx().sess.delay_span_bug(
                     self.delegate.span(),
@@ -620,8 +620,8 @@ fn tys(&mut self, a: Ty<'tcx>, mut b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>>
                 );
                 if a_def_id.is_local() { self.relate_opaques(a, b) } else { Err(err) }
             }),
-            (&ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }), _)
-            | (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }))
+            (&ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _)
+            | (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }))
                 if def_id.is_local() =>
             {
                 self.relate_opaques(a, b)
index 67e4554c4c7074b7ba400ecb080eddc381b58e93..a130fde47ed5c4d7c0ccdae1536387b649f7cc1b 100644 (file)
@@ -66,7 +66,7 @@ pub fn replace_opaque_types_with_inference_vars<T: TypeFoldable<'tcx>>(
             lt_op: |lt| lt,
             ct_op: |ct| ct,
             ty_op: |ty| match *ty.kind() {
-                ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ })
+                ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. })
                     if replace_opaque_type(def_id) =>
                 {
                     let def_span = self.tcx.def_span(def_id);
@@ -106,7 +106,7 @@ pub fn handle_opaque_type(
         }
         let (a, b) = if a_is_expected { (a, b) } else { (b, a) };
         let process = |a: Ty<'tcx>, b: Ty<'tcx>, a_is_expected| match *a.kind() {
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) if def_id.is_local() => {
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) if def_id.is_local() => {
                 let def_id = def_id.expect_local();
                 let origin = match self.defining_use_anchor {
                     DefiningAnchor::Bind(_) => {
@@ -149,9 +149,7 @@ pub fn handle_opaque_type(
                     DefiningAnchor::Bubble => self.opaque_ty_origin_unchecked(def_id, cause.span),
                     DefiningAnchor::Error => return None,
                 };
-                if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, substs: _ }) =
-                    *b.kind()
-                {
+                if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }) = *b.kind() {
                     // We could accept this, but there are various ways to handle this situation, and we don't
                     // want to make a decision on it right now. Likely this case is so super rare anyway, that
                     // no one encounters it in practice.
@@ -480,7 +478,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
                 substs.as_generator().resume_ty().visit_with(self);
             }
 
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, ref substs }) => {
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, ref substs, .. }) => {
                 // Skip lifetime paramters that are not captures.
                 let variances = self.tcx.variances_of(*def_id);
 
@@ -583,17 +581,16 @@ fn register_hidden_type(
                     }
                     // Replace all other mentions of the same opaque type with the hidden type,
                     // as the bounds must hold on the hidden type after all.
-                    ty::Alias(ty::Opaque, ty::AliasTy { def_id: def_id2, substs: substs2 })
+                    ty::Alias(ty::Opaque, ty::AliasTy { def_id: def_id2, substs: substs2, .. })
                         if def_id.to_def_id() == def_id2 && substs == substs2 =>
                     {
                         hidden_ty
                     }
                     // FIXME(RPITIT): This can go away when we move to associated types
-                    ty::Alias(ty::Projection, ty::AliasTy { def_id: def_id2, substs: substs2 })
-                        if def_id.to_def_id() == def_id2 && substs == substs2 =>
-                    {
-                        hidden_ty
-                    }
+                    ty::Alias(
+                        ty::Projection,
+                        ty::AliasTy { def_id: def_id2, substs: substs2, .. },
+                    ) if def_id.to_def_id() == def_id2 && substs == substs2 => hidden_ty,
                     _ => ty,
                 },
                 lt_op: |lt| lt,
index 984bbe169e6cf7ae110549236f2c6145de2dc3d4..aa2b5d067d266d8742c322ea147ffe5bc4905442 100644 (file)
@@ -130,7 +130,7 @@ fn compute_components<'tcx>(
             // outlives any other lifetime, which is unsound.
             // See https://github.com/rust-lang/rust/issues/84305 for
             // more details.
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
                 out.push(Component::Opaque(def_id, substs));
             },
 
index da85de60199324b2d236e386699b3f235324b657..ccae7165d80d2fac9d859c26b64031742bcbd244 100644 (file)
@@ -338,7 +338,7 @@ fn opaque_must_outlive(
             substs,
             true,
             |ty| match *ty.kind() {
-                ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => (def_id, substs),
+                ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => (def_id, substs),
                 _ => bug!("expected only projection types from env, not {:?}", ty),
             },
         );
index 58e27f8b21d6366337fe89ecb46c8b5eb255f467..bd38b52ba34a7eab0fbcbae019d94d58dd0d2c40 100644 (file)
@@ -131,14 +131,14 @@ fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
             }
 
             (
-                &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, substs: _ }),
-                &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, substs: _ }),
+                &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }),
+                &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }),
             ) if a_def_id == b_def_id => {
                 self.fields.infcx.super_combine_tys(self, a, b)?;
                 Ok(a)
             }
-            (&ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }), _)
-            | (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }))
+            (&ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _)
+            | (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }))
                 if self.fields.define_opaque_types && def_id.is_local() =>
             {
                 self.fields.obligations.extend(
index 3808d308186c0ee104b8f6a41d4fbd17f621bb17..42442cfb1904d4ddfdd621d53b156e62ec1186f2 100644 (file)
@@ -117,7 +117,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
                     // then we can emit a suggestion to add the bound.
                     let add_bound = match (proj_term.kind(), assoc_pred.kind().skip_binder()) {
                         (
-                            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }),
+                            ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }),
                             ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)),
                         ) => Some(AddBound {
                             suggest_span: cx.tcx.def_span(*def_id).shrink_to_hi(),
index fb2c8b1ef647c85d3e9a4679b393703be441bd9f..d628a18dd01c5875c36e5ad8bebb8940b8f89cc6 100644 (file)
@@ -96,7 +96,7 @@ fn check_stmt(&mut self, cx: &LateContext<'_>, s: &hir::Stmt<'_>) {
 
         if let hir::ExprKind::Match(await_expr, _arms, hir::MatchSource::AwaitDesugar) = expr.kind
             && let ty = cx.typeck_results().expr_ty(&await_expr)
-            && let ty::Alias(ty::Opaque, ty::AliasTy { def_id: future_def_id, substs: _ }) = ty.kind()
+            && let ty::Alias(ty::Opaque, ty::AliasTy { def_id: future_def_id, .. }) = ty.kind()
             && cx.tcx.ty_is_opaque_future(ty)
             // FIXME: This also includes non-async fns that return `impl Future`.
             && let async_fn_def_id = cx.tcx.parent(*future_def_id)
@@ -251,7 +251,7 @@ fn is_ty_must_use<'tcx>(
                         .map(|inner| MustUsePath::Boxed(Box::new(inner)))
                 }
                 ty::Adt(def, _) => is_def_must_use(cx, def.did(), span),
-                ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, substs: _ }) => {
+                ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
                     elaborate_predicates_with_span(
                         cx.tcx,
                         cx.tcx.explicit_item_bounds(def).iter().cloned(),
index 5ca5ec283210119ea89e9f6f2dcc1d1b8d90cf00..c220814d4fdf60c404212658b423401f67612333 100644 (file)
@@ -2321,7 +2321,7 @@ pub fn trait_may_define_assoc_type(self, trait_def_id: DefId, assoc_name: Ident)
 
     /// Given a `ty`, return whether it's an `impl Future<...>`.
     pub fn ty_is_opaque_future(self, ty: Ty<'_>) -> bool {
-        let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) = ty.kind() else { return false };
+        let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind() else { return false };
         let future_trait = self.require_lang_item(LangItem::Future, None);
 
         self.explicit_item_bounds(def_id).iter().any(|(predicate, _)| {
@@ -2673,7 +2673,7 @@ pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> GenericArg<'tcx>
 
     #[inline]
     pub fn mk_opaque(self, def_id: DefId, substs: SubstsRef<'tcx>) -> Ty<'tcx> {
-        self.mk_ty(Alias(ty::Opaque, ty::AliasTy { def_id, substs }))
+        self.mk_ty(Alias(ty::Opaque, self.mk_alias_ty(def_id, substs)))
     }
 
     pub fn mk_place_field(self, place: Place<'tcx>, f: Field, ty: Ty<'tcx>) -> Place<'tcx> {
@@ -2888,7 +2888,7 @@ pub fn mk_alias_ty(
             substs.collect::<Vec<_>>(),
         );
         let substs = self.mk_substs(substs);
-        ty::AliasTy { def_id, substs }
+        ty::AliasTy { def_id, substs, _use_mk_alias_ty_instead: () }
     }
 
     pub fn mk_bound_variable_kinds<
index d7880a32ea9cd8f141b70ecadad0c5fca95836bd..d8d476d3fefe24e190095c86eaa88c0da0ad6e62 100644 (file)
@@ -457,10 +457,10 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
                 return ControlFlow::Break(());
             }
 
-            Alias(Opaque, AliasTy { def_id, substs: _ }) => {
+            Alias(Opaque, AliasTy { def_id, .. }) => {
                 let parent = self.tcx.parent(*def_id);
                 if let hir::def::DefKind::TyAlias | hir::def::DefKind::AssocTy = self.tcx.def_kind(parent)
-                    && let Alias(Opaque, AliasTy { def_id: parent_opaque_def_id, substs: _ }) = self.tcx.type_of(parent).kind()
+                    && let Alias(Opaque, AliasTy { def_id: parent_opaque_def_id, .. }) = self.tcx.type_of(parent).kind()
                     && parent_opaque_def_id == def_id
                 {
                     // Okay
index 22dc921aba1ca13fd53a7604c6eafeb9b6eb6f08..14d07608a780e6c5b33b6dbae204401251b39088 100644 (file)
@@ -779,8 +779,7 @@ fn suggest_constraining_opaque_associated_type(
         ty: Ty<'tcx>,
     ) -> bool {
         let assoc = self.associated_item(proj_ty.def_id);
-        if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) = *proj_ty.self_ty().kind()
-        {
+        if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *proj_ty.self_ty().kind() {
             let opaque_local_def_id = def_id.as_local();
             let opaque_hir_ty = if let Some(opaque_local_def_id) = opaque_local_def_id {
                 match &self.hir().expect_item(opaque_local_def_id).kind {
index 174ac74fc9e61f6e5b3cdaec8fc1b54491605092..d283ccc3ad8a29435035c2c6bc4fc1fe9b0b3454 100644 (file)
@@ -160,7 +160,7 @@ fn add_kind(&mut self, kind: &ty::TyKind<'_>) {
                 self.add_projection_ty(data);
             }
 
-            &ty::Alias(ty::Opaque, ty::AliasTy { def_id: _, substs }) => {
+            &ty::Alias(ty::Opaque, ty::AliasTy { substs, .. }) => {
                 self.add_flags(TypeFlags::HAS_TY_OPAQUE);
                 self.add_substs(substs);
             }
index 6acc2dc65d36942c7f7e53b5f8d28e12952af228..b1bc6eb8b81c5351029382a88dec5fe2b4292728 100644 (file)
@@ -728,7 +728,7 @@ fn pretty_print_type(mut self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error>
                 }
             }
             ty::Placeholder(placeholder) => p!(write("Placeholder({:?})", placeholder)),
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
                 // FIXME(eddyb) print this with `print_def_path`.
                 // We use verbose printing in 'NO_QUERIES' mode, to
                 // avoid needing to call `predicates_of`. This should
@@ -743,7 +743,7 @@ fn pretty_print_type(mut self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error>
                 let parent = self.tcx().parent(def_id);
                 match self.tcx().def_kind(parent) {
                     DefKind::TyAlias | DefKind::AssocTy => {
-                        if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: d, substs: _ }) =
+                        if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: d, .. }) =
                             *self.tcx().type_of(parent).kind()
                         {
                             if d == def_id {
index c463980bed50d5e78824810bf6c1bf7b14974d38..b39a7a323455a86e17cf2bf5730cbd8f52d48ee9 100644 (file)
@@ -557,8 +557,8 @@ pub fn super_relate_tys<'tcx, R: TypeRelation<'tcx>>(
         }
 
         (
-            &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, substs: a_substs }),
-            &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, substs: b_substs }),
+            &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, substs: a_substs, .. }),
+            &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, substs: b_substs, .. }),
         ) if a_def_id == b_def_id => {
             if relation.intercrate() {
                 // During coherence, opaque types should be treated as equal to each other, even if their generic params
index a60aea26216963bc5b5ce07de5c2c3acc8471b1c..0e4e792a982f33ac5a0e031f539e1ae9f974df4c 100644 (file)
@@ -1166,6 +1166,10 @@ pub struct AliasTy<'tcx> {
     /// `TraitRef` containing this associated type, which is in `tcx.associated_item(def_id).container`,
     /// aka. `tcx.parent(def_id)`.
     pub def_id: DefId,
+
+    /// This field exists to prevent the creation of `ProjectionTy` without using
+    /// [TyCtxt::mk_projection_ty].
+    pub(super) _use_mk_alias_ty_instead: (),
 }
 
 impl<'tcx> AliasTy<'tcx> {
index b8a19e582c9dcf3fa9aec79f1fed5e16005b96fd..857f52c8a245612ddc9d164207681e8c15a7f4aa 100644 (file)
@@ -825,7 +825,7 @@ fn tcx(&self) -> TyCtxt<'tcx> {
     }
 
     fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
-        if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) = *t.kind() {
+        if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) = *t.kind() {
             self.expand_opaque_ty(def_id, substs).unwrap_or(t)
         } else if t.has_opaque_types() {
             t.super_fold_with(self)
index ef7589d3ef2315f9bbf21e9c880c5f03e4e39122..9d560f5c837e2d75e75f6899d65199bdef8fe710 100644 (file)
@@ -849,7 +849,7 @@ fn visit_projection_elem(
             };
 
             let kind = match parent_ty.ty.kind() {
-                &ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
+                &ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
                     self.tcx.bound_type_of(def_id).subst(self.tcx, substs).kind()
                 }
                 kind => kind,
index d80c05d6b38268d734924a5b7d5a95732eb3be40..cbe11ee6ac2ddf787cdc58187de0ed95df35db91 100644 (file)
@@ -235,7 +235,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<V::BreakTy> {
                     self.def_id_visitor.visit_def_id(def_id, "trait", &trait_ref)?;
                 }
             }
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) => {
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => {
                 // Skip repeated `Opaque`s to avoid infinite recursion.
                 if self.visited_opaque_tys.insert(def_id) {
                     // The intent is to treat `impl Trait1 + Trait2` identically to
index 281b2d88f483bd66bd16e2994fad7df908f79619..a59c9011ab21a4116e4452b206392781e0ab0e25 100644 (file)
@@ -216,7 +216,7 @@ fn print_type(mut self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error> {
         match *ty.kind() {
             // Print all nominal types as paths (unlike `pretty_print_type`).
             ty::FnDef(def_id, substs)
-            | ty::Alias(_, ty::AliasTy { def_id, substs })
+            | ty::Alias(_, ty::AliasTy { def_id, substs, .. })
             | ty::Closure(def_id, substs)
             | ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
 
index b7f055d9146a05c30dc41af17d8c5ebe0e34c938..4285aa62cb96307991169be15b067839e36c2686 100644 (file)
@@ -439,7 +439,7 @@ fn print_type(mut self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error> {
             // Mangle all nominal types as paths.
             ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
             | ty::FnDef(def_id, substs)
-            | ty::Alias(_, ty::AliasTy { def_id, substs })
+            | ty::Alias(_, ty::AliasTy { def_id, substs, .. })
             | ty::Closure(def_id, substs)
             | ty::Generator(def_id, substs, _) => {
                 self = self.print_def_path(def_id, substs)?;
index 414aee0c4342b8854b01e7c0f1b0298cc4bc088b..dd5085bf4f300d029f779b55f909eb5ae4e500bf 100644 (file)
@@ -878,7 +878,7 @@ fn suggest_fn_call(
                     fn_sig.inputs().map_bound(|inputs| &inputs[1..]),
                 ))
             }
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
                 self.tcx.bound_item_bounds(def_id).subst(self.tcx, substs).iter().find_map(|pred| {
                     if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = pred.kind().skip_binder()
                     && Some(proj.projection_ty.def_id) == self.tcx.lang_items().fn_once_output()
@@ -2662,7 +2662,7 @@ fn note_obligation_cause_code<T>(
                                 Some(ident) => err.span_note(ident.span, &msg),
                                 None => err.note(&msg),
                             },
-                            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) => {
+                            ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => {
                                 // Avoid printing the future from `core::future::identity_future`, it's not helpful
                                 if tcx.parent(*def_id) == identity_future {
                                     break 'print;
index 445d783aabcf575d6e726b28cabf5fdab2b95a91..160bf5e76e3766788bd92029382e6a42dd8b375d 100644 (file)
@@ -496,7 +496,7 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
             // This is really important. While we *can* handle this, this has
             // severe performance implications for large opaque types with
             // late-bound regions. See `issue-88862` benchmark.
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs })
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. })
                 if !substs.has_escaping_bound_vars() =>
             {
                 // Only normalize `impl Trait` outside of type inference, usually in codegen.
index 777de195895b89de6c9f1e50c422de074b842bed..c6ef13e185b2d7526e6870397a3932e451e6a49c 100644 (file)
@@ -205,7 +205,7 @@ fn try_fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
             // This is really important. While we *can* handle this, this has
             // severe performance implications for large opaque types with
             // late-bound regions. See `issue-88862` benchmark.
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs })
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. })
                 if !substs.has_escaping_bound_vars() =>
             {
                 // Only normalize `impl Trait` outside of type inference, usually in codegen.
index 85456853ce08c66cffd744c7112974852a37b043..f6fe71fbd4f889ce18c08f0c08b890b4939363c1 100644 (file)
@@ -155,7 +155,7 @@ fn confirm_projection_candidate(
         let placeholder_self_ty = placeholder_trait_predicate.self_ty();
         let placeholder_trait_predicate = ty::Binder::dummy(placeholder_trait_predicate);
         let (def_id, substs) = match *placeholder_self_ty.kind() {
-            ty::Alias(_, ty::AliasTy { def_id, substs }) => (def_id, substs),
+            ty::Alias(_, ty::AliasTy { def_id, substs, .. }) => (def_id, substs),
             _ => bug!("projection candidate for unexpected type: {:?}", placeholder_self_ty),
         };
 
index 115897851d67317e8ad4670714e864e4ae28131c..792933096b15c61a731b3a2e1cee0d87c1347926 100644 (file)
@@ -1595,7 +1595,7 @@ fn match_projection_obligation_against_definition_bounds(
 
         let tcx = self.infcx.tcx;
         let (def_id, substs) = match *placeholder_trait_predicate.trait_ref.self_ty().kind() {
-            ty::Alias(_, ty::AliasTy { def_id, substs }) => (def_id, substs),
+            ty::Alias(_, ty::AliasTy { def_id, substs, .. }) => (def_id, substs),
             _ => {
                 span_bug!(
                     obligation.cause.span,
@@ -2259,7 +2259,7 @@ fn constituent_types_for_ty(
                 t.rebind(def.all_fields().map(|f| f.ty(self.tcx(), substs)).collect())
             }
 
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
                 // We can resolve the `impl Trait` to its concrete type,
                 // which enforces a DAG between the functions requiring
                 // the auto trait bounds in question.
index 74c4ae8854c34e4d9fb628808f5523a4f4707c65..a995eeb9a7afb8841b5539440c9df059dfd49484 100644 (file)
@@ -648,7 +648,7 @@ fn compute(&mut self, arg: GenericArg<'tcx>) {
                     // types appearing in the fn signature
                 }
 
-                ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
+                ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
                     // All of the requirements on type parameters
                     // have already been checked for `impl Trait` in
                     // return position. We do need to check type-alias-impl-trait though.
index 53bafde0ea20e9fdcc52f63b587bb4d223185ea2..bc4a52c5040d1fa5f2647d6acd6c7105a814009c 100644 (file)
@@ -433,7 +433,7 @@ fn impl_provided_for(
                     }
                 }
                 (
-                    &ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }),
+                    &ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }),
                     OpaqueType(opaque_ty_id, ..),
                 ) => def_id == opaque_ty_id.0,
                 (&ty::FnDef(def_id, ..), FnDef(fn_def_id, ..)) => def_id == fn_def_id.0,
@@ -789,7 +789,7 @@ fn fold_binder<T: TypeFoldable<'tcx>>(
     }
 
     fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
-        if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) = *ty.kind() {
+        if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) = *ty.kind() {
             if def_id == self.opaque_ty_id.0 && substs == self.identity_substs {
                 return self.tcx.mk_ty(ty::Bound(
                     self.binder_index,
index f3fd315c71ee5fa43aaf47771f94849e399ac3a4..9712abb708f2762c61c6c2b0b922e642c681fb83 100644 (file)
@@ -347,13 +347,13 @@ fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::Ty<RustInterner<'
             ty::Tuple(types) => {
                 chalk_ir::TyKind::Tuple(types.len(), types.as_substs().lower_into(interner))
             }
-            ty::Alias(ty::Projection, ty::AliasTy { def_id, substs }) => {
+            ty::Alias(ty::Projection, ty::AliasTy { def_id, substs, .. }) => {
                 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTy {
                     associated_ty_id: chalk_ir::AssocTypeId(def_id),
                     substitution: substs.lower_into(interner),
                 }))
             }
-            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
+            ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
                 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy {
                     opaque_ty_id: chalk_ir::OpaqueTyId(def_id),
                     substitution: substs.lower_into(interner),
@@ -443,11 +443,11 @@ fn lower_into(self, interner: RustInterner<'tcx>) -> Ty<'tcx> {
             TyKind::Str => ty::Str,
             TyKind::OpaqueType(opaque_ty, substitution) => ty::Alias(
                 ty::Opaque,
-                ty::AliasTy { def_id: opaque_ty.0, substs: substitution.lower_into(interner) },
+                interner.tcx.mk_alias_ty(opaque_ty.0, substitution.lower_into(interner)),
             ),
             TyKind::AssociatedType(assoc_ty, substitution) => ty::Alias(
                 ty::Projection,
-                ty::AliasTy { substs: substitution.lower_into(interner), def_id: assoc_ty.0 },
+                interner.tcx.mk_alias_ty(assoc_ty.0, substitution.lower_into(interner)),
             ),
             TyKind::Foreign(def_id) => ty::Foreign(def_id.0),
             TyKind::Error => return interner.tcx.ty_error(),
@@ -458,17 +458,17 @@ fn lower_into(self, interner: RustInterner<'tcx>) -> Ty<'tcx> {
             TyKind::Alias(alias_ty) => match alias_ty {
                 chalk_ir::AliasTy::Projection(projection) => ty::Alias(
                     ty::Projection,
-                    ty::AliasTy {
-                        def_id: projection.associated_ty_id.0,
-                        substs: projection.substitution.lower_into(interner),
-                    },
+                    interner.tcx.mk_alias_ty(
+                        projection.associated_ty_id.0,
+                        projection.substitution.lower_into(interner),
+                    ),
                 ),
                 chalk_ir::AliasTy::Opaque(opaque) => ty::Alias(
                     ty::Opaque,
-                    ty::AliasTy {
-                        def_id: opaque.opaque_ty_id.0,
-                        substs: opaque.substitution.lower_into(interner),
-                    },
+                    interner.tcx.mk_alias_ty(
+                        opaque.opaque_ty_id.0,
+                        opaque.substitution.lower_into(interner),
+                    ),
                 ),
             },
             TyKind::Function(_quantified_ty) => unimplemented!(),
index 4a4dc899ba9a379279fa6e0e1d7ea50002dee894..92886bbfe26b4e5d03953f9eb3362bfe03bd3ae9 100644 (file)
@@ -1835,7 +1835,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
             }
         }
 
-        ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
+        ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
             // Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
             // by looking up the bounds associated with the def_id.
             let bounds = cx
index fcdac90fc237ae1a1a18bd7ffcf3e722e53bb545..989f83cf80d5972301fc06eef9604796f674a7b8 100644 (file)
@@ -62,7 +62,7 @@ fn check_fn(
             return;
         }
         let ret_ty = return_ty(cx, hir_id);
-        if let ty::Alias(ty::Opaque, AliasTy { def_id, substs }) = *ret_ty.kind() {
+        if let ty::Alias(ty::Opaque, AliasTy { def_id, substs, .. }) = *ret_ty.kind() {
             let preds = cx.tcx.explicit_item_bounds(def_id);
             let mut is_future = false;
             for &(p, _span) in preds {
index 33f3b3af3dc02d125223da58b3c9fc694805def0..a6bcb134d408096099ddd5d13263a68e28688fa1 100644 (file)
@@ -79,7 +79,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
                 return true;
             }
 
-            if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) = *inner_ty.kind() {
+            if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *inner_ty.kind() {
                 for &(predicate, _span) in cx.tcx.explicit_item_bounds(def_id) {
                     match predicate.kind().skip_binder() {
                         // 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 {
             is_must_use_ty(cx, *ty)
         },
         ty::Tuple(substs) => substs.iter().any(|ty| is_must_use_ty(cx, ty)),
-        ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) => {
+        ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => {
             for (predicate, _) in cx.tcx.explicit_item_bounds(*def_id) {
                 if let ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() {
                     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
             Some(ExprFnSig::Closure(decl, subs.as_closure().sig()))
         },
         ty::FnDef(id, subs) => Some(ExprFnSig::Sig(cx.tcx.bound_fn_sig(id).subst(cx.tcx, subs), Some(id))),
-        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)),
+        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)),
         ty::FnPtr(sig) => Some(ExprFnSig::Sig(sig, None)),
         ty::Dynamic(bounds, _, _) => {
             let lang_items = cx.tcx.lang_items();
@@ -1039,10 +1039,10 @@ fn helper<'tcx>(
             }
         }
 
-        Some(AliasTy {
+        Some(tcx.mk_alias_ty(
+            assoc_item.def_id,
             substs,
-            def_id: assoc_item.def_id,
-        })
+        ))
     }
     helper(
         tcx,