lint rule: avoid_void_async: report on local main functions

Fixes https://github.com/dart-lang/linter/issues/4941

Change-Id: Icd417fdb591e832cbf4698156f622ea13f8fcaad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389800
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
diff --git a/pkg/linter/lib/src/rules/avoid_void_async.dart b/pkg/linter/lib/src/rules/avoid_void_async.dart
index fd56110..543fc69 100644
--- a/pkg/linter/lib/src/rules/avoid_void_async.dart
+++ b/pkg/linter/lib/src/rules/avoid_void_async.dart
@@ -38,7 +38,7 @@
 
   @override
   void visitFunctionDeclaration(FunctionDeclaration node) {
-    if (node.name.lexeme == 'main') return;
+    if (node.name.lexeme == 'main' && node.parent is CompilationUnit) return;
     _check(
       declaredElement: node.declaredElement,
       returnType: node.returnType,
diff --git a/pkg/linter/test/rules/avoid_void_async_test.dart b/pkg/linter/test/rules/avoid_void_async_test.dart
index 94da5e4..5d66b29 100644
--- a/pkg/linter/test/rules/avoid_void_async_test.dart
+++ b/pkg/linter/test/rules/avoid_void_async_test.dart
@@ -112,7 +112,6 @@
     ]);
   }
 
-  @FailingTest(issue: 'https://github.com/dart-lang/linter/issues/4941')
   test_functionLocal_main_async_arrow() async {
     await assertDiagnostics(r'''
 void f() {