mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Merge #7422
7422: Disallow non-boolean literals in concat! r=lnicola a=lnicola Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
commit
a6a5b02f4c
1 changed files with 4 additions and 2 deletions
|
@ -331,7 +331,9 @@ fn concat_expand(
|
||||||
text.push_str(&component);
|
text.push_str(&component);
|
||||||
}
|
}
|
||||||
// handle boolean literals
|
// handle boolean literals
|
||||||
tt::TokenTree::Leaf(tt::Leaf::Ident(id)) if i % 2 == 0 => {
|
tt::TokenTree::Leaf(tt::Leaf::Ident(id))
|
||||||
|
if i % 2 == 0 && (id.text == "true" || id.text == "false") =>
|
||||||
|
{
|
||||||
text.push_str(id.text.as_str());
|
text.push_str(id.text.as_str());
|
||||||
}
|
}
|
||||||
tt::TokenTree::Leaf(tt::Leaf::Punct(punct)) if i % 2 == 1 && punct.char == ',' => (),
|
tt::TokenTree::Leaf(tt::Leaf::Punct(punct)) if i % 2 == 1 && punct.char == ',' => (),
|
||||||
|
@ -739,7 +741,7 @@ mod tests {
|
||||||
r##"
|
r##"
|
||||||
#[rustc_builtin_macro]
|
#[rustc_builtin_macro]
|
||||||
macro_rules! concat {}
|
macro_rules! concat {}
|
||||||
concat!("foo", r, 0, r#"bar"#, false);
|
concat!("foo", "r", 0, r#"bar"#, false);
|
||||||
"##,
|
"##,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue