Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/expand_macro.rs')
| -rw-r--r-- | crates/ide/src/expand_macro.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crates/ide/src/expand_macro.rs b/crates/ide/src/expand_macro.rs index 4b0961cbbe..e2d629a02f 100644 --- a/crates/ide/src/expand_macro.rs +++ b/crates/ide/src/expand_macro.rs @@ -177,7 +177,9 @@ fn _format( use ide_db::base_db::{FileLoader, SourceDatabase}; // hack until we get hygiene working (same character amount to preserve formatting as much as possible) const DOLLAR_CRATE_REPLACE: &str = "__r_a_"; - let expansion = expansion.replace("$crate", DOLLAR_CRATE_REPLACE); + const BUILTIN_REPLACE: &str = "builtin__POUND"; + let expansion = + expansion.replace("$crate", DOLLAR_CRATE_REPLACE).replace("builtin #", BUILTIN_REPLACE); let (prefix, suffix) = match kind { SyntaxKind::MACRO_PAT => ("fn __(", ": u32);"), SyntaxKind::MACRO_EXPR | SyntaxKind::MACRO_STMTS => ("fn __() {", "}"), @@ -206,7 +208,9 @@ fn _format( let captured_stdout = String::from_utf8(output.stdout).ok()?; if output.status.success() && !captured_stdout.trim().is_empty() { - let output = captured_stdout.replace(DOLLAR_CRATE_REPLACE, "$crate"); + let output = captured_stdout + .replace(DOLLAR_CRATE_REPLACE, "$crate") + .replace(BUILTIN_REPLACE, "builtin #"); let output = output.trim().strip_prefix(prefix)?; let output = match kind { SyntaxKind::MACRO_PAT => { |