Skip to content

Commit 5b934bd

Browse files
committed
Auto merge of #17741 - Veykril:include-raw, r=Veykril
fix: Fix builtin includes rejecting raw string literals Fixes #17701
2 parents a021b85 + ad71abb commit 5b934bd

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ macro_rules! include_bytes {
439439
($file:expr,) => {{ /* compiler built-in */ }};
440440
}
441441
442-
fn main() { include_bytes("foo"); }
442+
fn main() { include_bytes("foo");include_bytes(r"foo"); }
443443
"#,
444444
expect![[r##"
445445
#[rustc_builtin_macro]
@@ -448,7 +448,7 @@ macro_rules! include_bytes {
448448
($file:expr,) => {{ /* compiler built-in */ }};
449449
}
450450
451-
fn main() { include_bytes("foo"); }
451+
fn main() { include_bytes("foo");include_bytes(r"foo"); }
452452
"##]],
453453
);
454454
}

crates/hir-expand/src/builtin/fn_macro.rs

+12
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,12 @@ fn parse_string(tt: &tt::Subtree) -> Result<(Symbol, Span), ExpandError> {
714714
kind: tt::LitKind::Str,
715715
suffix: _,
716716
})) => Ok((unescape_str(text), *span)),
717+
tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal {
718+
symbol: text,
719+
span,
720+
kind: tt::LitKind::StrRaw(_),
721+
suffix: _,
722+
})) => Ok((text.clone(), *span)),
717723
// FIXME: We wrap expression fragments in parentheses which can break this expectation
718724
// here
719725
// Remove this once we handle none delims correctly
@@ -725,6 +731,12 @@ fn parse_string(tt: &tt::Subtree) -> Result<(Symbol, Span), ExpandError> {
725731
kind: tt::LitKind::Str,
726732
suffix: _,
727733
})) => Some((unescape_str(text), *span)),
734+
tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal {
735+
symbol: text,
736+
span,
737+
kind: tt::LitKind::StrRaw(_),
738+
suffix: _,
739+
})) => Some((text.clone(), *span)),
728740
_ => None,
729741
})
730742
}

0 commit comments

Comments
 (0)