diff options
| author | bors <bors@rust-lang.org> | 2024-07-30 06:21:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-07-30 06:21:07 +0000 |
| commit | 5fa145eab97324623e10da7100f2c18bfc8f5326 (patch) | |
| tree | 2a6fd97d5a026b6efccd19df8b0eb5f06ab117bd | |
| parent | 722f79d374cdf97fdeaf14aaa3e8dde10db07140 (diff) | |
| parent | 90e1a58cc6ead86b3caab59e3a46761c89374e50 (diff) | |
| download | rust-5fa145eab97324623e10da7100f2c18bfc8f5326.tar.gz rust-5fa145eab97324623e10da7100f2c18bfc8f5326.zip | |
Auto merge of #17741 - Veykril:include-raw, r=Veykril
fix: Fix builtin includes rejecting raw string literals Fixes https://github.com/rust-lang/rust-analyzer/issues/17701
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs | 4 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir-expand/src/builtin/fn_macro.rs | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs index 487ab537cda..b6dbba12cd6 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs @@ -439,7 +439,7 @@ macro_rules! include_bytes { ($file:expr,) => {{ /* compiler built-in */ }}; } -fn main() { include_bytes("foo"); } +fn main() { include_bytes("foo");include_bytes(r"foo"); } "#, expect![[r##" #[rustc_builtin_macro] @@ -448,7 +448,7 @@ macro_rules! include_bytes { ($file:expr,) => {{ /* compiler built-in */ }}; } -fn main() { include_bytes("foo"); } +fn main() { include_bytes("foo");include_bytes(r"foo"); } "##]], ); } diff --git a/src/tools/rust-analyzer/crates/hir-expand/src/builtin/fn_macro.rs b/src/tools/rust-analyzer/crates/hir-expand/src/builtin/fn_macro.rs index 391b891ad6c..7903ac075be 100644 --- a/src/tools/rust-analyzer/crates/hir-expand/src/builtin/fn_macro.rs +++ b/src/tools/rust-analyzer/crates/hir-expand/src/builtin/fn_macro.rs @@ -714,6 +714,12 @@ fn parse_string(tt: &tt::Subtree) -> Result<(Symbol, Span), ExpandError> { kind: tt::LitKind::Str, suffix: _, })) => Ok((unescape_str(text), *span)), + tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal { + symbol: text, + span, + kind: tt::LitKind::StrRaw(_), + suffix: _, + })) => Ok((text.clone(), *span)), // FIXME: We wrap expression fragments in parentheses which can break this expectation // here // Remove this once we handle none delims correctly @@ -725,6 +731,12 @@ fn parse_string(tt: &tt::Subtree) -> Result<(Symbol, Span), ExpandError> { kind: tt::LitKind::Str, suffix: _, })) => Some((unescape_str(text), *span)), + tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal { + symbol: text, + span, + kind: tt::LitKind::StrRaw(_), + suffix: _, + })) => Some((text.clone(), *span)), _ => None, }) } |
