File tree 2 files changed +9
-3
lines changed
rustc_macros/src/diagnostics
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,14 @@ pub(crate) fn new_code_ident() -> syn::Ident {
30
30
}
31
31
32
32
pub ( crate ) fn convert_to_litstr ( lit : & proc_macro2:: Literal ) -> LitStr {
33
- let lit_content = format ! ( "{}" , lit) ;
34
- LitStr :: new ( & lit_content[ 1 ..lit_content. len ( ) - 1 ] , lit. span ( ) )
33
+ let s = format ! ( "{}" , lit) ;
34
+ let s = if s. starts_with ( "r#\" " ) && s. ends_with ( "\" #" ) && s. len ( ) >= 5 {
35
+ s[ 3 ..s. len ( ) - 2 ] . to_string ( )
36
+ } else {
37
+ s[ 1 ..s. len ( ) - 1 ] . to_string ( )
38
+ } ;
39
+
40
+ LitStr :: new ( & s, lit. span ( ) )
35
41
}
36
42
37
43
/// Checks whether the type name of `ty` matches `name`.
Original file line number Diff line number Diff line change @@ -498,7 +498,7 @@ pub(crate) struct ExpectedEqForLetExpr {
498
498
}
499
499
500
500
#[ derive( Diagnostic ) ]
501
- #[ diag( label = r#"expected `{"{"}`, found {$first_tok}"# ) ]
501
+ #[ diag( r#"expected `{"{"}`, found {$first_tok}"# ) ]
502
502
pub ( crate ) struct ExpectedElseBlock {
503
503
#[ primary_span]
504
504
pub first_tok_span : Span ,
You can’t perform that action at this time.
0 commit comments