Skip to content

Commit

Permalink
Use non_exhaustive for AliasTy.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Mar 2, 2024
1 parent 178a505 commit 70bf864
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ where
/// * For an opaque type, there is no explicit syntax.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
#[non_exhaustive]
pub struct AliasTy<'tcx> {
/// The parameters of the associated or opaque item.
///
Expand All @@ -1136,10 +1137,6 @@ 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 `AliasTy` without using
/// [AliasTy::new].
_use_alias_ty_new_instead: (),
}

impl<'tcx> AliasTy<'tcx> {
Expand All @@ -1149,7 +1146,7 @@ impl<'tcx> AliasTy<'tcx> {
args: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
) -> ty::AliasTy<'tcx> {
let args = tcx.check_and_mk_args(def_id, args);
ty::AliasTy { def_id, args, _use_alias_ty_new_instead: () }
ty::AliasTy { def_id, args }
}

pub fn kind(self, tcx: TyCtxt<'tcx>) -> ty::AliasKind {
Expand Down

0 comments on commit 70bf864

Please sign in to comment.