File tree 2 files changed +8
-11
lines changed
hir-def/src/macro_expansion_tests
2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -163,7 +163,8 @@ macro_rules! compile_error {
163
163
}
164
164
165
165
// This expands to nothing (since it's in item position), but emits an error.
166
- compile_error!("error!");
166
+ compile_error!("error, with an escaped quote: \"");
167
+ compile_error!(r"this is a raw string");
167
168
"# ,
168
169
expect ! [ [ r##"
169
170
#[rustc_builtin_macro]
@@ -172,7 +173,8 @@ macro_rules! compile_error {
172
173
($msg:expr,) => ({ /* compiler built-in */ })
173
174
}
174
175
175
- /* error: error! */
176
+ /* error: error, with an escaped quote: " */
177
+ /* error: this is a raw string */
176
178
"## ] ] ,
177
179
) ;
178
180
}
Original file line number Diff line number Diff line change @@ -379,15 +379,10 @@ fn compile_error_expand(
379
379
tt : & tt:: Subtree ,
380
380
) -> ExpandResult < ExpandedEager > {
381
381
let err = match & * tt. token_trees {
382
- [ tt:: TokenTree :: Leaf ( tt:: Leaf :: Literal ( it) ) ] => {
383
- let text = it. text . as_str ( ) ;
384
- if text. starts_with ( '"' ) && text. ends_with ( '"' ) {
385
- // FIXME: does not handle raw strings
386
- ExpandError :: Other ( text[ 1 ..text. len ( ) - 1 ] . into ( ) )
387
- } else {
388
- ExpandError :: Other ( "`compile_error!` argument must be a string" . into ( ) )
389
- }
390
- }
382
+ [ tt:: TokenTree :: Leaf ( tt:: Leaf :: Literal ( it) ) ] => match unquote_str ( it) {
383
+ Some ( unquoted) => ExpandError :: Other ( unquoted. into ( ) ) ,
384
+ None => ExpandError :: Other ( "`compile_error!` argument must be a string" . into ( ) ) ,
385
+ } ,
391
386
_ => ExpandError :: Other ( "`compile_error!` argument must be a string" . into ( ) ) ,
392
387
} ;
393
388
You can’t perform that action at this time.
0 commit comments