Skip to content

Commit

Permalink
Merge #7060
Browse files Browse the repository at this point in the history
7060: Fix mbe fail to pass expr with attr r=edwin0cheng a=edwin0cheng

bors r+

Fixes #5896

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
  • Loading branch information
bors[bot] and edwin0cheng committed Dec 28, 2020
2 parents 99ec2f6 + 877c251 commit 77ad203
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/hir_def/src/nameres/tests/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ fn macro_expansion_overflow() {
r#"
macro_rules! a {
($e:expr; $($t:tt)*) => {
b!($($t)*);
b!(static = (); $($t)*);
};
() => {};
}
Expand All @@ -689,7 +689,7 @@ macro_rules! b {
() => {};
}
b! { static = #[] (); }
b! { static = #[] ();}
"#,
expect![[r#"
crate
Expand Down
12 changes: 12 additions & 0 deletions crates/mbe/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,18 @@ fn test_last_expr() {
);
}

#[test]
fn test_expr_with_attr() {
parse_macro(
r#"
macro_rules! m {
($a:expr) => {0}
}
"#,
)
.assert_expand_items("m!(#[allow(a)]())", "0");
}

#[test]
fn test_ty() {
parse_macro(
Expand Down
2 changes: 1 addition & 1 deletion crates/parser/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub(crate) mod fragments {
};

pub(crate) fn expr(p: &mut Parser) {
let _ = expressions::expr(p);
let _ = expressions::expr_with_attrs(p);
}

pub(crate) fn stmt(p: &mut Parser) {
Expand Down

0 comments on commit 77ad203

Please sign in to comment.