diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index a4df277a7b084..2f80b74dbdfd2 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -400,6 +400,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { self.infcx.tcx.hir().name(var_id).to_string() } + ty::Variant(ty, index) => { + assert_eq!(index, variant_index.unwrap()); + return self.describe_field_from_ty(ty, field, variant_index); + } _ => { // Might need a revision when the fields in trait RFC is implemented // (https://github.com/rust-lang/rfcs/pull/1546) diff --git a/compiler/rustc_borrowck/src/places_conflict.rs b/compiler/rustc_borrowck/src/places_conflict.rs index 773e9e90b0c6b..feb4a3d27a4e8 100644 --- a/compiler/rustc_borrowck/src/places_conflict.rs +++ b/compiler/rustc_borrowck/src/places_conflict.rs @@ -243,10 +243,10 @@ fn place_components_conflict<'tcx>( return false; } - (ProjectionElem::Field { .. }, ty::Adt(def, _), AccessDepth::Drop) => { + (ProjectionElem::Field { .. }, _, AccessDepth::Drop) => { // Drop can read/write arbitrary projections, so places // conflict regardless of further projections. - if def.has_dtor(tcx) { + if base_ty.has_dtor(tcx) { return true; } } diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 7e69e710d6868..01a7a15bc018a 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -556,7 +556,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { let mut place_ty = PlaceTy::from_ty(self.body.local_decls[place.local].ty); for elem in place.projection.iter() { - if place_ty.variant_index.is_none() { + if place_ty.variant_index().is_none() { if place_ty.ty.references_error() { assert!(self.errors_reported); return PlaceTy::from_ty(self.tcx().ty_error()); @@ -735,7 +735,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { adt_def.variants.len() )) } else { - PlaceTy { ty: base_ty, variant_index: Some(index) } + PlaceTy { ty: self.tcx().mk_ty(ty::Variant(base_ty, index)) } } } // We do not need to handle generators here, because this runs @@ -802,9 +802,10 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { location: Location, ) -> Result, FieldAccessError> { let tcx = self.tcx(); + let ty = base_ty.ty; - let (variant, substs) = match base_ty { - PlaceTy { ty, variant_index: Some(variant_index) } => match *ty.kind() { + let (variant, substs) = if let ty::Variant(ty, variant_index) = *ty.kind() { + match *ty.kind() { ty::Adt(adt_def, substs) => (&adt_def.variants[variant_index], substs), ty::Generator(def_id, substs, _) => { let mut variants = substs.as_generator().state_tys(def_id, tcx); @@ -822,8 +823,9 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { }; } _ => bug!("can't have downcast of non-adt non-generator type"), - }, - PlaceTy { ty, variant_index: None } => match *ty.kind() { + } + } else { + match *ty.kind() { ty::Adt(adt_def, substs) if !adt_def.is_enum() => { (&adt_def.variants[VariantIdx::new(0)], substs) } @@ -863,7 +865,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { base_ty )); } - }, + } }; if let Some(field) = variant.fields.get(field.index()) { diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index accb54e464553..406bd551e5d38 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -373,6 +373,8 @@ fn push_debuginfo_type_name<'tcx>( t ); } + + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } /// MSVC names enums differently than other platforms so that the debugging visualization diff --git a/compiler/rustc_const_eval/src/const_eval/mod.rs b/compiler/rustc_const_eval/src/const_eval/mod.rs index a334165df4cb1..61e3122396823 100644 --- a/compiler/rustc_const_eval/src/const_eval/mod.rs +++ b/compiler/rustc_const_eval/src/const_eval/mod.rs @@ -129,6 +129,7 @@ fn const_to_valtree_inner<'tcx>( | ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) => None, + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index 698742fe98ceb..3b4b162c9a837 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -100,6 +100,7 @@ crate fn eval_nullary_intrinsic<'tcx>( | ty::Never | ty::Tuple(_) | ty::Error(_) => ConstValue::from_machine_usize(0u64, &tcx), + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), }, other => bug!("`{}` is not a zero arg intrinsic", other), }) diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs b/compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs index a7012cd63f313..45aa38a824017 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs @@ -65,6 +65,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { ty::Foreign(def_id) => self.print_def_path(def_id, &[]), ty::GeneratorWitness(_) => bug!("type_name: unexpected `GeneratorWitness`"), + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index fc69770bf6a30..c6b9ef285a732 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -612,6 +612,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' | ty::Opaque(..) | ty::Projection(..) | ty::GeneratorWitness(..) => bug!("Encountered invalid type {:?}", ty), + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index 934ada9932e71..3e4627259c71f 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -406,6 +406,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> { t } } + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } diff --git a/compiler/rustc_infer/src/infer/freshen.rs b/compiler/rustc_infer/src/infer/freshen.rs index c40e409891bc2..cabbd40735dcb 100644 --- a/compiler/rustc_infer/src/infer/freshen.rs +++ b/compiler/rustc_infer/src/infer/freshen.rs @@ -218,6 +218,8 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> { | ty::Opaque(..) => t.super_fold_with(self), ty::Placeholder(..) | ty::Bound(..) => bug!("unexpected type {:?}", t), + + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } diff --git a/compiler/rustc_infer/src/infer/outlives/components.rs b/compiler/rustc_infer/src/infer/outlives/components.rs index 98f926e9d76d5..d137ba8717ffc 100644 --- a/compiler/rustc_infer/src/infer/outlives/components.rs +++ b/compiler/rustc_infer/src/infer/outlives/components.rs @@ -187,6 +187,7 @@ fn compute_components( // themselves can be readily identified. compute_components_recursive(tcx, ty.into(), out, visited); } + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 708cd56e068b5..5415eff8363ca 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1130,6 +1130,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { | ty::GeneratorWitness(..) | ty::Placeholder(..) | ty::FnDef(..) => bug!("unexpected type in foreign function: {:?}", ty), + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs index c3c5ebe705eff..283d6edec31d7 100644 --- a/compiler/rustc_middle/src/mir/tcx.rs +++ b/compiler/rustc_middle/src/mir/tcx.rs @@ -12,18 +12,23 @@ use rustc_target::abi::VariantIdx; #[derive(Copy, Clone, Debug, TypeFoldable)] pub struct PlaceTy<'tcx> { pub ty: Ty<'tcx>, - /// Downcast to a particular variant of an enum, if included. - pub variant_index: Option, } // At least on 64 bit systems, `PlaceTy` should not be larger than two or three pointers. #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -static_assert_size!(PlaceTy<'_>, 16); +static_assert_size!(PlaceTy<'_>, 8); impl<'tcx> PlaceTy<'tcx> { #[inline] pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> { - PlaceTy { ty, variant_index: None } + PlaceTy { ty } + } + + pub fn variant_index(self) -> Option { + match self.ty.kind() { + ty::Variant(_, index) => Some(*index), + _ => None, + } } /// `place_ty.field_ty(tcx, f)` computes the type at a given field @@ -35,15 +40,16 @@ impl<'tcx> PlaceTy<'tcx> { /// Note that the resulting type has not been normalized. pub fn field_ty(self, tcx: TyCtxt<'tcx>, f: &Field) -> Ty<'tcx> { let answer = match self.ty.kind() { + ty::Variant(ty, variant_index) => match ty.kind() { + ty::Adt(adt_def, substs) => { + assert!(adt_def.is_enum()); + let field_def = &adt_def.variants[*variant_index].fields[f.index()]; + field_def.ty(tcx, substs) + } + _ => bug!("unexpected type: {}", ty), + }, ty::Adt(adt_def, substs) => { - let variant_def = match self.variant_index { - None => adt_def.non_enum_variant(), - Some(variant_index) => { - assert!(adt_def.is_enum()); - &adt_def.variants[variant_index] - } - }; - let field_def = &variant_def.fields[f.index()]; + let field_def = &adt_def.non_enum_variant().fields[f.index()]; field_def.ty(tcx, substs) } ty::Tuple(ref tys) => tys[f.index()].expect_ty(), @@ -103,7 +109,7 @@ impl<'tcx> PlaceTy<'tcx> { }) } ProjectionElem::Downcast(_name, index) => { - PlaceTy { ty: self.ty, variant_index: Some(index) } + PlaceTy { ty: tcx.mk_ty(ty::Variant(self.ty, index)) } } ProjectionElem::Field(ref f, ref fty) => PlaceTy::from_ty(handle_field(&self, f, fty)), }; diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 8240273acad4c..4d6d0ad3e7c18 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1932,6 +1932,7 @@ impl<'tcx> TyCtxt<'tcx> { fmt, self.0, Adt, + Variant, Array, Slice, RawPtr, diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index 2bd9415171d7d..b14f3419dd792 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -247,6 +247,7 @@ impl<'tcx> ty::TyS<'tcx> { ty::Tuple(ref tys) if tys.is_empty() => format!("`{}`", self).into(), ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.def_path_str(def.did)).into(), + ty::Variant(ty, _) => ty.sort_string(tcx), ty::Foreign(def_id) => format!("extern type `{}`", tcx.def_path_str(def_id)).into(), ty::Array(t, n) => { if t.is_simple_ty() { @@ -318,6 +319,10 @@ impl<'tcx> ty::TyS<'tcx> { | ty::Never => "type".into(), ty::Tuple(ref tys) if tys.is_empty() => "unit type".into(), ty::Adt(def, _) => def.descr().into(), + ty::Variant(ty, _) => match ty.kind() { + ty::Adt(def, _) => format!("{} variant", def.descr()).into(), + _ => bug!("unexpected type: {:?}", ty.kind()), + }, ty::Foreign(_) => "extern type".into(), ty::Array(..) => "array".into(), ty::Slice(_) => "slice".into(), diff --git a/compiler/rustc_middle/src/ty/fast_reject.rs b/compiler/rustc_middle/src/ty/fast_reject.rs index 11ee942b83e77..26db4f6a64db4 100644 --- a/compiler/rustc_middle/src/ty/fast_reject.rs +++ b/compiler/rustc_middle/src/ty/fast_reject.rs @@ -104,6 +104,7 @@ pub fn simplify_type( ty::Opaque(def_id, _) => Some(OpaqueSimplifiedType(def_id)), ty::Foreign(def_id) => Some(ForeignSimplifiedType(def_id)), ty::Placeholder(..) | ty::Bound(..) | ty::Infer(_) | ty::Error(_) => None, + ty::Variant(ty, _) => return simplify_type(tcx, ty, can_simplify_params), } } diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index a078b6fb742a7..4f848df77fd28 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -213,6 +213,8 @@ impl FlagComputation { computation.add_tys(fn_sig.inputs()); computation.add_ty(fn_sig.output()); }), + + &ty::Variant(ty, _) => self.add_kind(ty.kind()), } } diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 8ec5f4c79781f..3aa941d3ef14c 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -1403,6 +1403,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { ty::Bound(..) | ty::Param(_) | ty::Error(_) => { return Err(LayoutError::Unknown(ty)); } + + ty::Variant(ty, _) => return self.layout_of_uncached(ty), }) } } @@ -2388,6 +2390,7 @@ where | ty::Param(_) | ty::Infer(_) | ty::Error(_) => bug!("TyAndLayout::field: unexpected type `{}`", this.ty), + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index 308b4d2fefc71..5d47357ae18bb 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -315,6 +315,8 @@ fn characteristic_def_id_of_type_cached<'a>( | ty::GeneratorWitness(..) | ty::Never | ty::Float(_) => None, + + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option { diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index b11a54d5dcb11..c76cb6df4ec93 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -605,6 +605,14 @@ pub trait PrettyPrinter<'tcx>: ty::Adt(def, substs) => { p!(print_def_path(def.did, substs)); } + + ty::Variant(ty, idx) => match ty.kind() { + ty::Adt(def, substs) => { + p!(print_def_path(def.did, substs)); + p!(write("::{}", def.variants.get(idx).unwrap().ident.name)); + } + _ => bug!("unexpected type: {:?}", ty.kind()), + }, ty::Dynamic(data, r) => { let print_r = self.region_should_not_be_omitted(r); if print_r { diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index d6069395474ab..2b07c74d35fb5 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -903,6 +903,8 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { | ty::Placeholder(..) | ty::Never | ty::Foreign(..) => return self, + + ty::Variant(ty, _) => return ty.super_fold_with(folder), }; if *self.kind() == kind { self } else { folder.tcx().mk_ty(kind) } @@ -951,6 +953,8 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { | ty::Param(..) | ty::Never | ty::Foreign(..) => ControlFlow::CONTINUE, + + ty::Variant(ty, _) => return ty.super_visit_with(visitor), } } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 874de3366d792..f91dbafc568c3 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -195,6 +195,9 @@ pub enum TyKind<'tcx> { /// A type variable used during type checking. Infer(InferTy), + /// Type of a variant of an enum + Variant(Ty<'tcx>, VariantIdx), + /// A placeholder for a type which could not be computed; this is /// propagated to avoid useless error messages. Error(DelaySpanBugEmitted), @@ -1902,6 +1905,14 @@ impl<'tcx> TyS<'tcx> { !matches!(self.kind(), Param(_) | Infer(_) | Error(_)) } + pub fn has_dtor(&self, tcx: TyCtxt<'tcx>) -> bool { + match self.kind() { + Adt(adt_def, _) => adt_def.has_dtor(tcx), + Variant(ty, _) => ty.has_dtor(tcx), + _ => false, + } + } + /// Returns the type and mutability of `*ty`. /// /// The parameter `explicit` indicates if this is an *explicit* dereference. @@ -2059,6 +2070,8 @@ impl<'tcx> TyS<'tcx> { | ty::Infer(FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { bug!("`discriminant_ty` applied to unexpected type: {:?}", self) } + + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } @@ -2107,6 +2120,8 @@ impl<'tcx> TyS<'tcx> { | ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { bug!("`ptr_metadata_ty` applied to unexpected type: {:?}", tail) } + + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } @@ -2185,6 +2200,15 @@ impl<'tcx> TyS<'tcx> { | ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { bug!("`is_trivially_sized` applied to unexpected type: {:?}", self) } + + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), + } + } + + pub fn strip_variant_type(&self) -> &Self { + match self.kind() { + ty::Variant(ty, ..) => *ty, + _ => self, } } } diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 2c884813d2318..72382c94595d1 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -712,6 +712,8 @@ impl<'tcx> ty::TyS<'tcx> { | ty::Param(_) | ty::Placeholder(_) | ty::Projection(_) => false, + + ty::Variant(ty, _) => return ty.is_trivially_freeze(), } } @@ -752,6 +754,7 @@ impl<'tcx> ty::TyS<'tcx> { | ty::Param(_) | ty::Placeholder(_) | ty::Projection(_) => false, + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } @@ -874,6 +877,8 @@ impl<'tcx> ty::TyS<'tcx> { Projection(_) | Opaque(..) | Param(_) | Bound(..) | Placeholder(_) | Infer(_) => false, Foreign(_) | GeneratorWitness(..) | Error(_) => false, + + Variant(..) => unimplemented!("TODO(zhamlin)"), } } @@ -1022,6 +1027,8 @@ pub fn needs_drop_components( | ty::Infer(_) | ty::Closure(..) | ty::Generator(..) => Ok(smallvec![ty]), + + ty::Variant(ty, _) => return needs_drop_components(ty, target_layout), } } diff --git a/compiler/rustc_middle/src/ty/walk.rs b/compiler/rustc_middle/src/ty/walk.rs index 73985cf31e0f9..6785407dcee1f 100644 --- a/compiler/rustc_middle/src/ty/walk.rs +++ b/compiler/rustc_middle/src/ty/walk.rs @@ -198,6 +198,7 @@ fn push_inner<'tcx>( stack.push(sig.skip_binder().output().into()); stack.extend(sig.skip_binder().inputs().iter().copied().rev().map(|ty| ty.into())); } + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), }, GenericArgKind::Lifetime(_) => {} GenericArgKind::Const(parent_ct) => { diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index d228a34046cef..05375944e3414 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -277,6 +277,7 @@ where ty::Bound(..) | ty::Placeholder(..) | ty::Infer(..) => { bug!("unexpected type: {:?}", ty) } + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } if self.def_id_visitor.shallow() { diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index 521730dfeb01c..d78357e827bab 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -467,6 +467,8 @@ impl Printer<'tcx> for &mut SymbolMangler<'tcx> { } ty::GeneratorWitness(_) => bug!("symbol_names: unexpected `GeneratorWitness`"), + + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } // Only cache types that do not refer to an enclosing diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index 42d3194aed48a..c16420f249641 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -651,5 +651,7 @@ fn ty_is_local_constructor(ty: Ty<'_>, in_crate: InCrate) -> bool { ty::Generator(..) | ty::GeneratorWitness(..) => { bug!("ty_is_local invoked on unexpected type: {:?}", ty) } + + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 5d17693dc0820..050a95bbb18c7 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1377,6 +1377,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { ty::Foreign(..) => Some(19), ty::GeneratorWitness(..) => Some(20), ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) | ty::Error(_) => None, + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index db8a6d9620495..0e8b73150cdde 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -1402,6 +1402,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>( | ty::Placeholder(..) | ty::Infer(..) | ty::Error(_) => false, + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } super::ImplSource::Pointee(..) => { @@ -1447,6 +1448,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>( | ty::Placeholder(..) | ty::Infer(..) | ty::Error(_) => false, + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } super::ImplSource::Param(..) => { diff --git a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs index f05582f061429..c580b4980a603 100644 --- a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs +++ b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs @@ -135,5 +135,6 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { | ty::Infer(_) | ty::Bound(..) | ty::Generator(..) => false, + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index 1d0c54f86dea8..88ce1f16e9beb 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -1021,6 +1021,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } debug!("not returning"); } + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } debug!(?stack, "assemble_const_drop_candidates - in loop"); } diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 1b26e38fe0e4d..c55b7a1dbee35 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1835,6 +1835,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty); } + + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } @@ -1912,6 +1914,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty); } + + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } @@ -1993,6 +1997,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // the auto trait bounds in question. t.rebind(vec![self.tcx().type_of(def_id).subst(self.tcx(), substs)]) } + + ty::Variant(ty, _) => return self.constituent_types_for_ty(t.rebind(ty)), } } diff --git a/compiler/rustc_trait_selection/src/traits/structural_match.rs b/compiler/rustc_trait_selection/src/traits/structural_match.rs index a398e847b9354..73e765a90e2da 100644 --- a/compiler/rustc_trait_selection/src/traits/structural_match.rs +++ b/compiler/rustc_trait_selection/src/traits/structural_match.rs @@ -210,6 +210,8 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> { // as this may still emit relevant errors. return ControlFlow::CONTINUE; } + + ty::Variant(ty, _) => return self.visit_ty(ty), }; if !self.seen.insert(adt_def.did) { diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index cb47ba9c360da..a1a3701b658a4 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -687,6 +687,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { self.compute(ty.into()); } } + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } } } diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index e24f699adf6b3..c9ff3993e4808 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -330,6 +330,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty>> for Ty<'tcx> { } ty::Infer(_infer) => unimplemented!(), ty::Error(_) => chalk_ir::TyKind::Error, + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } .intern(interner) } diff --git a/compiler/rustc_traits/src/dropck_outlives.rs b/compiler/rustc_traits/src/dropck_outlives.rs index 672e149b5fc96..a2de9f6561922 100644 --- a/compiler/rustc_traits/src/dropck_outlives.rs +++ b/compiler/rustc_traits/src/dropck_outlives.rs @@ -299,6 +299,8 @@ fn dtorck_constraint_for_ty<'tcx>( // be fully resolved. return Err(NoSolution); } + + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } Ok(()) diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index af3706f886e9c..8b9d617a706fd 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -68,6 +68,8 @@ fn sized_constraint_for_ty<'tcx>( Placeholder(..) | Bound(..) | Infer(..) => { bug!("unexpected type `{:?}` in sized_constraint_for_ty", ty) } + + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), }; debug!("sized_constraint_for_ty({:?}) = {:?}", ty, result); result diff --git a/compiler/rustc_typeck/src/check/cast.rs b/compiler/rustc_typeck/src/check/cast.rs index 78849b276d6bf..c19c200aa4a87 100644 --- a/compiler/rustc_typeck/src/check/cast.rs +++ b/compiler/rustc_typeck/src/check/cast.rs @@ -144,6 +144,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .delay_span_bug(span, &format!("`{:?}` should be sized but is not?", t)); return Err(ErrorReported); } + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), }) } } diff --git a/compiler/rustc_typeck/src/variance/constraints.rs b/compiler/rustc_typeck/src/variance/constraints.rs index 33c27ce86ddb5..4ef900b06e94d 100644 --- a/compiler/rustc_typeck/src/variance/constraints.rs +++ b/compiler/rustc_typeck/src/variance/constraints.rs @@ -336,6 +336,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { ty ); } + + ty::Variant(..) => unimplemented!("TODO(zhamlin)"), } }