Skip to content

Commit e7e87fc

Browse files
committed
Don't bail on parse errors in macro input for builtin expansion
1 parent b02027d commit e7e87fc

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

crates/hir_expand/src/builtin_macro.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,23 @@ mod tests {
792792
);
793793
}
794794

795+
#[test]
796+
fn test_format_args_expand_with_broken_member_access() {
797+
check_expansion(
798+
r#"
799+
#[rustc_builtin_macro]
800+
macro_rules! format_args {
801+
($fmt:expr) => ({ /* compiler built-in */ });
802+
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })
803+
}
804+
format_args!("{} {:?}", a.);
805+
"#,
806+
expect![[
807+
r#"unsafe{std::fmt::Arguments::new_v1(&[], &[std::fmt::ArgumentV1::new(&(a.),std::fmt::Display::fmt),])}"#
808+
]],
809+
);
810+
}
811+
795812
#[test]
796813
fn test_include_bytes_expand() {
797814
check_expansion(

crates/mbe/src/syntax_bridge.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn parse_to_token_tree(text: &str) -> Option<(tt::Subtree, TokenMap)> {
9090
Some((subtree, conv.id_alloc.map))
9191
}
9292

93-
/// Split token tree with seperate expr: $($e:expr)SEP*
93+
/// Split token tree with separate expr: $($e:expr)SEP*
9494
pub fn parse_exprs_with_sep(tt: &tt::Subtree, sep: char) -> Vec<tt::Subtree> {
9595
if tt.token_trees.is_empty() {
9696
return Vec::new();
@@ -101,9 +101,6 @@ pub fn parse_exprs_with_sep(tt: &tt::Subtree, sep: char) -> Vec<tt::Subtree> {
101101

102102
while iter.peek_n(0).is_some() {
103103
let expanded = iter.expect_fragment(ParserEntryPoint::Expr);
104-
if expanded.err.is_some() {
105-
break;
106-
}
107104

108105
res.push(match expanded.value {
109106
None => break,

0 commit comments

Comments
 (0)