]> git.lizzy.rs Git - rust.git/blobdiff - src/etc/check_missing_items.py
Rollup merge of #100379 - davidtwco:triagebot-diag, r=Mark-Simulacrum
[rust.git] / src / etc / check_missing_items.py
index 343dd0387f47987c011c2334c80f0c8d0f914ea4..ce06a79a21c3f58a770606027708e84b6552afa0 100644 (file)
@@ -57,7 +57,7 @@ def check_generic_bound(bound):
     if "trait_bound" in bound:
         for param in bound["trait_bound"]["generic_params"]:
             check_generic_param(param)
-        check_type(bound["trait_bound"]["trait"])
+        check_path(bound["trait_bound"]["trait"])
 
 
 def check_decl(decl):
@@ -66,35 +66,35 @@ def check_decl(decl):
     if decl["output"]:
         check_type(decl["output"])
 
+def check_path(path):
+    args = path["args"]
+    if args:
+        if "angle_bracketed" in args:
+            for arg in args["angle_bracketed"]["args"]:
+                if "type" in arg:
+                    check_type(arg["type"])
+                elif "const" in arg:
+                    check_type(arg["const"]["type"])
+            for binding in args["angle_bracketed"]["bindings"]:
+                if "equality" in binding["binding"]:
+                    term = binding["binding"]["equality"]
+                    if "type" in term: check_type(term["type"])
+                    elif "const" in term: check_type(term["const"])
+                elif "constraint" in binding["binding"]:
+                    for bound in binding["binding"]["constraint"]:
+                        check_generic_bound(bound)
+        elif "parenthesized" in args:
+            for input_ty in args["parenthesized"]["inputs"]:
+                check_type(input_ty)
+            if args["parenthesized"]["output"]:
+                check_type(args["parenthesized"]["output"])
+    if not valid_id(path["id"]):
+        print("Type contained an invalid ID:", path["id"])
+        sys.exit(1)
 
 def check_type(ty):
     if ty["kind"] == "resolved_path":
-        for bound in ty["inner"]["param_names"]:
-            check_generic_bound(bound)
-        args = ty["inner"]["args"]
-        if args:
-            if "angle_bracketed" in args:
-                for arg in args["angle_bracketed"]["args"]:
-                    if "type" in arg:
-                        check_type(arg["type"])
-                    elif "const" in arg:
-                        check_type(arg["const"]["type"])
-                for binding in args["angle_bracketed"]["bindings"]:
-                    if "equality" in binding["binding"]:
-                        term = binding["binding"]["equality"]
-                        if "type" in term: check_type(term["type"])
-                        elif "const" in term: check_type(term["const"])
-                    elif "constraint" in binding["binding"]:
-                        for bound in binding["binding"]["constraint"]:
-                            check_generic_bound(bound)
-            elif "parenthesized" in args:
-                for ty in args["parenthesized"]["inputs"]:
-                    check_type(ty)
-                if args["parenthesized"]["output"]:
-                    check_type(args["parenthesized"]["output"])
-        if not valid_id(ty["inner"]["id"]):
-            print("Type contained an invalid ID:", ty["inner"]["id"])
-            sys.exit(1)
+        check_path(ty["inner"])
     elif ty["kind"] == "tuple":
         for ty in ty["inner"]:
             check_type(ty)
@@ -111,7 +111,7 @@ def check_type(ty):
         check_decl(ty["inner"]["decl"])
     elif ty["kind"] == "qualified_path":
         check_type(ty["inner"]["self_type"])
-        check_type(ty["inner"]["trait"])
+        check_path(ty["inner"]["trait"])
 
 
 work_list = set([crate["root"]])
@@ -174,7 +174,7 @@ while work_list:
     elif item["kind"] == "impl":
         check_generics(item["inner"]["generics"])
         if item["inner"]["trait"]:
-            check_type(item["inner"]["trait"])
+            check_path(item["inner"]["trait"])
         if item["inner"]["blanket_impl"]:
             check_type(item["inner"]["blanket_impl"])
         check_type(item["inner"]["for"])