Mac calls

This commit is contained in:
David Tolnay 2022-01-29 22:16:35 -08:00
parent 47f92a58a4
commit 858d6a0711
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
2 changed files with 17 additions and 5 deletions

View file

@ -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.

View file

@ -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());
}