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 {
391
391
} ;
392
392
393
393
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 ;
394
398
unescape_literal ( inner, mode, & mut |_, ch| match ch {
395
399
Ok ( ch) => unescaped. push ( ch) ,
396
400
Err ( e) if !e. is_fatal ( ) => ( ) ,
397
- Err ( e ) => panic ! ( "{e:?}" ) ,
401
+ Err ( _ ) => unparsable = true ,
398
402
} ) ;
403
+ if unparsable {
404
+ return None ;
405
+ }
399
406
400
407
let mut parts = Vec :: new ( ) ;
401
408
let _: Option < !> = for_each_expr ( pieces, |expr| {
You can’t perform that action at this time.
0 commit comments