File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -391,11 +391,18 @@ impl FormatString {
391391 } ;
392392
393393 let mut unescaped = String :: with_capacity ( inner. len ( ) ) ;
394+ // Sometimes the original string comes from a macro which accepts a malformed string, such as in a
395+ // #[display(""somestring)] attribute (accepted by the `displaythis` crate). Reconstructing the
396+ // string from the span will not be possible, so we will just return None here.
397+ let mut unparsable = false ;
394398 unescape_literal ( inner, mode, & mut |_, ch| match ch {
395399 Ok ( ch) => unescaped. push ( ch) ,
396400 Err ( e) if !e. is_fatal ( ) => ( ) ,
397- Err ( e ) => panic ! ( "{e:?}" ) ,
401+ Err ( _ ) => unparsable = true ,
398402 } ) ;
403+ if unparsable {
404+ return None ;
405+ }
399406
400407 let mut parts = Vec :: new ( ) ;
401408 let _: Option < !> = for_each_expr ( pieces, |expr| {
You can’t perform that action at this time.
0 commit comments