@@ -66,6 +66,14 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> {
6666
6767 variant
6868 }
69+ ty:: Slice ( ty) => {
70+ let ( variant, variant_place) = downcast ( sym:: Slice ) ?;
71+ let slice_place = self . project_field ( & variant_place, FieldIdx :: ZERO ) ?;
72+
73+ self . write_slice_type_info ( slice_place, * ty) ?;
74+
75+ variant
76+ }
6977 ty:: Bool => {
7078 let ( variant, _variant_place) = downcast ( sym:: Bool ) ?;
7179 variant
@@ -115,7 +123,6 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> {
115123 ty:: Adt ( _, _)
116124 | ty:: Foreign ( _)
117125 | ty:: Pat ( _, _)
118- | ty:: Slice ( _)
119126 | ty:: RawPtr ( ..)
120127 | ty:: FnDef ( ..)
121128 | ty:: FnPtr ( ..)
@@ -246,6 +253,27 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> {
246253 interp_ok ( ( ) )
247254 }
248255
256+ pub ( crate ) fn write_slice_type_info (
257+ & mut self ,
258+ place : impl Writeable < ' tcx , CtfeProvenance > ,
259+ ty : Ty < ' tcx > ,
260+ ) -> InterpResult < ' tcx > {
261+ // Iterate over all fields of `type_info::Slice`.
262+ for ( field_idx, field) in
263+ place. layout ( ) . ty . ty_adt_def ( ) . unwrap ( ) . non_enum_variant ( ) . fields . iter_enumerated ( )
264+ {
265+ let field_place = self . project_field ( & place, field_idx) ?;
266+
267+ match field. name {
268+ // Write the `TypeId` of the slice's elements to the `element_ty` field.
269+ sym:: element_ty => self . write_type_id ( ty, & field_place) ?,
270+ other => span_bug ! ( self . tcx. def_span( field. did) , "unimplemented field {other}" ) ,
271+ }
272+ }
273+
274+ interp_ok ( ( ) )
275+ }
276+
249277 fn write_int_type_info (
250278 & mut self ,
251279 place : impl Writeable < ' tcx , CtfeProvenance > ,
0 commit comments