@@ -158,6 +158,10 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> {
158158 ty:: Adt ( adt, _) if self . tcx . is_diagnostic_item ( sym:: Arguments , adt. did ) => {
159159 return self . fmt_arguments ( arg, f) ;
160160 }
161+ ty:: Adt ( adt, _) if self . tcx . is_diagnostic_item ( sym:: String , adt. did ) => {
162+ // NOTE(nbdd0121): const `String` can only be empty.
163+ dispatch_fmt ! ( "" , Display ) ;
164+ }
161165
162166 // FIXME(nbdd0121): ty::Adt(..) => (),
163167 _ => {
@@ -241,4 +245,18 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> {
241245 self . fmt_arguments ( arguments, & mut formatter) ?;
242246 Ok ( msg)
243247 }
248+
249+ pub ( super ) fn eval_const_panic_any ( & mut self , arg : OpTy < ' tcx > ) -> InterpResult < ' tcx , String > {
250+ match arg. layout . ty . kind ( ) {
251+ ty:: Ref ( _, ty, _) if ty. is_str ( ) => {
252+ let place = self . deref_operand ( & arg) ?;
253+ Ok ( self . read_str ( & place) ?. to_string ( ) )
254+ }
255+ ty:: Adt ( adt, _) if self . tcx . is_diagnostic_item ( sym:: String , adt. did ) => {
256+ // NOTE(nbdd0121): const `String` can only be empty.
257+ Ok ( String :: new ( ) )
258+ }
259+ _ => Ok ( "Box<dyn Any>" . to_string ( ) ) ,
260+ }
261+ }
244262}
0 commit comments