diff options
| author | David Tolnay <dtolnay@gmail.com> | 2022-01-29 22:16:35 -0800 |
|---|---|---|
| committer | David Tolnay <dtolnay@gmail.com> | 2022-01-30 11:53:12 -0800 |
| commit | 858d6a071199b30ea95c744895f61f93ad188ffb (patch) | |
| tree | e2bcacf96d5cff9b61a708fc14c8a1c16953db72 | |
| parent | 47f92a58a412fed5555eb120f963bcf6a35a9da8 (diff) | |
| download | rust-858d6a071199b30ea95c744895f61f93ad188ffb.tar.gz rust-858d6a071199b30ea95c744895f61f93ad188ffb.zip | |
Mac calls
| -rw-r--r-- | compiler/rustc_builtin_macros/src/format.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/fmt/format-with-yield-point.rs | 14 |
2 files changed, 17 insertions, 5 deletions
diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs index d1696816666..f08aa8f95ff 100644 --- a/compiler/rustc_builtin_macros/src/format.rs +++ b/compiler/rustc_builtin_macros/src/format.rs @@ -1237,15 +1237,17 @@ fn may_contain_yield_point(e: &ast::Expr) -> bool { impl Visitor<'_> for MayContainYieldPoint { fn visit_expr(&mut self, e: &ast::Expr) { - if let ast::ExprKind::Await(_) | ast::ExprKind::Yield(_) | ast::ExprKind::MacCall(_) = - e.kind - { + if let ast::ExprKind::Await(_) | ast::ExprKind::Yield(_) = e.kind { self.0 = true; } else { visit::walk_expr(self, e); } } + fn visit_mac_call(&mut self, _: &ast::MacCall) { + self.0 = true; + } + fn visit_attribute(&mut self, _: &ast::Attribute) { // Conservatively assume this may be a proc macro attribute in // expression position. diff --git a/src/test/ui/fmt/format-with-yield-point.rs b/src/test/ui/fmt/format-with-yield-point.rs index 0bd9062f95e..e484074cc9a 100644 --- a/src/test/ui/fmt/format-with-yield-point.rs +++ b/src/test/ui/fmt/format-with-yield-point.rs @@ -11,13 +11,23 @@ async fn with_await() { println!("{} {:?}", "", async {}.await); } -async fn with_macro_call() { +async fn with_macro_call_expr() { println!("{} {:?}", "", m!()); } +async fn with_macro_call_stmt_semi() { + println!("{} {:?}", "", { m!(); }); +} + +async fn with_macro_call_stmt_braced() { + println!("{} {:?}", "", { m!{} }); +} + fn assert_send(_: impl Send) {} fn main() { assert_send(with_await()); - assert_send(with_macro_call()); + assert_send(with_macro_call_expr()); + assert_send(with_macro_call_stmt_semi()); + assert_send(with_macro_call_stmt_braced()); } |
