Skip to content

Commit 858d6a0

Browse files
committed
Mac calls
1 parent 47f92a5 commit 858d6a0

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

compiler/rustc_builtin_macros/src/format.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1237,15 +1237,17 @@ fn may_contain_yield_point(e: &ast::Expr) -> bool {
12371237

12381238
impl Visitor<'_> for MayContainYieldPoint {
12391239
fn visit_expr(&mut self, e: &ast::Expr) {
1240-
if let ast::ExprKind::Await(_) | ast::ExprKind::Yield(_) | ast::ExprKind::MacCall(_) =
1241-
e.kind
1242-
{
1240+
if let ast::ExprKind::Await(_) | ast::ExprKind::Yield(_) = e.kind {
12431241
self.0 = true;
12441242
} else {
12451243
visit::walk_expr(self, e);
12461244
}
12471245
}
12481246

1247+
fn visit_mac_call(&mut self, _: &ast::MacCall) {
1248+
self.0 = true;
1249+
}
1250+
12491251
fn visit_attribute(&mut self, _: &ast::Attribute) {
12501252
// Conservatively assume this may be a proc macro attribute in
12511253
// expression position.

src/test/ui/fmt/format-with-yield-point.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,23 @@ async fn with_await() {
1111
println!("{} {:?}", "", async {}.await);
1212
}
1313

14-
async fn with_macro_call() {
14+
async fn with_macro_call_expr() {
1515
println!("{} {:?}", "", m!());
1616
}
1717

18+
async fn with_macro_call_stmt_semi() {
19+
println!("{} {:?}", "", { m!(); });
20+
}
21+
22+
async fn with_macro_call_stmt_braced() {
23+
println!("{} {:?}", "", { m!{} });
24+
}
25+
1826
fn assert_send(_: impl Send) {}
1927

2028
fn main() {
2129
assert_send(with_await());
22-
assert_send(with_macro_call());
30+
assert_send(with_macro_call_expr());
31+
assert_send(with_macro_call_stmt_semi());
32+
assert_send(with_macro_call_stmt_braced());
2333
}

0 commit comments

Comments
 (0)