[3.10] bpo-43897: Reject "_" captures and top-level MatchStar in the AST validator (GH-27432) (GH-27435)



(cherry picked from commit 8d0647485db5af2a0f0929d6509479ca45f1281b)


Co-authored-by: Brandt Bucher <brandt@python.org>

Automerge-Triggered-By: GH:brandtbucher
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index ac0669a..326f3ab 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -1596,7 +1596,11 @@ def test_stdlib_validates(self):
         ),
         ast.MatchOr(
             [pattern_1, pattern_x, ast.MatchSingleton('xxx')]
-        )
+        ),
+        ast.MatchAs(name="_"),
+        ast.MatchStar(name="x"),
+        ast.MatchSequence([ast.MatchStar("_")]),
+        ast.MatchMapping([], [], rest="_"),
     ]
 
     def test_match_validation_pattern(self):