mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Correctly escape strings in our quote macro
This is a small change, but it was the cause of 90% of the errors in `rust-analyzer diagnostics .` 🫢 With this change and #18085 together, all remaining errors are type errors. This may mean we can enable more errors, but this is out of scope for this PR.
This commit is contained in:
parent
f13c776361
commit
7c44d453c8
3 changed files with 25 additions and 6 deletions
|
@ -483,7 +483,7 @@ fn concat_expand(
|
|||
match it.kind {
|
||||
tt::LitKind::Char => {
|
||||
if let Ok(c) = unescape_char(it.symbol.as_str()) {
|
||||
text.extend(c.escape_default());
|
||||
text.push(c);
|
||||
}
|
||||
record_span(it.span);
|
||||
}
|
||||
|
@ -491,11 +491,11 @@ fn concat_expand(
|
|||
format_to!(text, "{}", it.symbol.as_str())
|
||||
}
|
||||
tt::LitKind::Str => {
|
||||
text.push_str(it.symbol.as_str());
|
||||
text.push_str(unescape_str(&it.symbol).as_str());
|
||||
record_span(it.span);
|
||||
}
|
||||
tt::LitKind::StrRaw(_) => {
|
||||
format_to!(text, "{}", it.symbol.as_str().escape_debug());
|
||||
format_to!(text, "{}", it.symbol.as_str());
|
||||
record_span(it.span);
|
||||
}
|
||||
tt::LitKind::Byte
|
||||
|
@ -813,7 +813,7 @@ fn include_str_expand(
|
|||
|
||||
fn get_env_inner(db: &dyn ExpandDatabase, arg_id: MacroCallId, key: &Symbol) -> Option<String> {
|
||||
let krate = db.lookup_intern_macro_call(arg_id).krate;
|
||||
db.crate_graph()[krate].env.get(key.as_str()).map(|it| it.escape_debug().to_string())
|
||||
db.crate_graph()[krate].env.get(key.as_str())
|
||||
}
|
||||
|
||||
fn env_expand(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue