Merge #8777
8777: Escape characters in builtin macros correctly r=edwin0cheng a=edwin0cheng Fixes #8749 It is the same bug in #8560 but in our `quote!` macro. Because the "\" are adding exponentially in #8749 case, so the text is eat up all the memory. bors r+ Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
commit
b43921cddd
2 changed files with 4 additions and 4 deletions
|
|
@ -788,9 +788,9 @@ mod tests {
|
|||
r##"
|
||||
#[rustc_builtin_macro]
|
||||
macro_rules! concat {}
|
||||
concat!("foo", "r", 0, r#"bar"#, false);
|
||||
concat!("foo", "r", 0, r#"bar"#, "\n", false);
|
||||
"##,
|
||||
expect![[r#""foor0barfalse""#]],
|
||||
expect![[r#""foor0bar\nfalse""#]],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,8 +196,8 @@ impl_to_to_tokentrees! {
|
|||
tt::Literal => self { self };
|
||||
tt::Ident => self { self };
|
||||
tt::Punct => self { self };
|
||||
&str => self { tt::Literal{text: format!("{:?}", self.escape_default().to_string()).into(), id: tt::TokenId::unspecified()}};
|
||||
String => self { tt::Literal{text: format!("{:?}", self.escape_default().to_string()).into(), id: tt::TokenId::unspecified()}}
|
||||
&str => self { tt::Literal{text: format!("\"{}\"", self.escape_debug()).into(), id: tt::TokenId::unspecified()}};
|
||||
String => self { tt::Literal{text: format!("\"{}\"", self.escape_debug()).into(), id: tt::TokenId::unspecified()}}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue