@@ -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
@@ -124,7 +132,6 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> {
124132 ty:: Adt ( _, _)
125133 | ty:: Foreign ( _)
126134 | ty:: Pat ( _, _)
127- | ty:: Slice ( _)
128135 | ty:: FnDef ( ..)
129136 | ty:: FnPtr ( ..)
130137 | ty:: UnsafeBinder ( ..)
@@ -254,6 +261,27 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> {
254261 interp_ok ( ( ) )
255262 }
256263
264+ pub ( crate ) fn write_slice_type_info (
265+ & mut self ,
266+ place : impl Writeable < ' tcx , CtfeProvenance > ,
267+ ty : Ty < ' tcx > ,
268+ ) -> InterpResult < ' tcx > {
269+ // Iterate over all fields of `type_info::Slice`.
270+ for ( field_idx, field) in
271+ place. layout ( ) . ty . ty_adt_def ( ) . unwrap ( ) . non_enum_variant ( ) . fields . iter_enumerated ( )
272+ {
273+ let field_place = self . project_field ( & place, field_idx) ?;
274+
275+ match field. name {
276+ // Write the `TypeId` of the slice's elements to the `element_ty` field.
277+ sym:: element_ty => self . write_type_id ( ty, & field_place) ?,
278+ other => span_bug ! ( self . tcx. def_span( field. did) , "unimplemented field {other}" ) ,
279+ }
280+ }
281+
282+ interp_ok ( ( ) )
283+ }
284+
257285 fn write_int_type_info (
258286 & mut self ,
259287 place : impl Writeable < ' tcx , CtfeProvenance > ,
0 commit comments