{"record":{"id":"0fe3357b28fa72fd","repo":"rust-lang/rust","slug":"invalid-number-of-arguments","errorCode":null,"errorMessage":"Invalid number of {} arguments","messagePattern":"Invalid number of (.+?) arguments","errorType":"validation","errorClass":"InvalidCheck","httpStatus":null,"severity":"error","filePath":"src/etc/htmldocck.py","lineNumber":547,"sourceCode":"                    cache.get_file(c.args[0])\n                    ret = True\n                except FailedCheck as err:\n                    cerr = str(err)\n                    ret = False\n            # hasraw/matchesraw <path> <pat> = string test\n            elif len(c.args) == 2 and \"raw\" in c.cmd:\n                cerr = \"`PATTERN` did not match\"\n                if c.negated:\n                    cerr = \"`PATTERN` unexpectedly matched\"\n                ret = check_string(cache.get_file(c.args[0]), c.args[1], regexp)\n            # has/matches <path> <pat> <match> = XML tree test\n            elif len(c.args) == 3 and \"raw\" not in c.cmd:\n                cerr = \"`XPATH PATTERN` did not match\"\n                if c.negated:\n                    cerr = \"`XPATH PATTERN` unexpectedly matched\"\n                ret = get_nb_matching_elements(cache, c, regexp, True) != 0\n            else:\n                raise InvalidCheck(\"Invalid number of {} arguments\".format(c.cmd))\n\n        elif c.cmd == \"files\":  # check files in given folder\n            if len(c.args) != 2:  # files <folder path> <file list>\n                raise InvalidCheck(\"Invalid number of {} arguments\".format(c.cmd))\n            elif c.negated:\n                raise InvalidCheck(\"{} doesn't support negative check\".format(c.cmd))\n            ret = check_files_in_folder(c, cache, c.args[0], c.args[1])\n\n        elif c.cmd == \"count\":  # count test\n            if len(c.args) == 3:  # count <path> <pat> <count> = count test\n                expected = int(c.args[2])\n                found = get_tree_count(cache.get_tree(c.args[0]), c.args[1])\n                cerr = \"Expected {} occurrences but found {}\".format(expected, found)\n                ret = expected == found\n            elif len(c.args) == 4:  # count <path> <pat> <text> <count> = count test\n                expected = int(c.args[3])\n                found = get_nb_matching_elements(cache, c, False, False)\n                cerr = \"Expected {} occurrences but found {}\".format(expected, found)","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/etc/htmldocck.py#L529-L565","documentation":"Raised by htmldocck (the rustdoc HTML test harness) when a 'has', 'matches', 'hasraw', or 'matchesraw' directive is written with an unsupported argument count. 'hasraw'/'matchesraw' require exactly 2 args (path + pattern); 'has'/'matches' require exactly 3 (path + xpath + pattern). Any other count falls through to this InvalidCheck, which is a hard error in the test definition, not a check failure.","triggerScenarios":"Writing `//@ has foo.html` (1 arg), `//@ matches a.html xpath pattern extra` (4 args), or `//@ hasraw a.html pat extra` (3 args) in a `.rs` rustdoc test. The directive is parsed by CustomCheck and this branch rejects every arity other than 2-for-raw and 3-for-tree.","commonSituations":"Test authors confuse has (needs an XPATH) with hasraw (plain string). Copy-pasting a compiletest directive into a rustdoc test, or forgetting the XPATH argument after renaming a tree check to a raw check.","solutions":["Count the directive's arguments: hasraw/matchesraw = path + pattern (2); has/matches = path + xpath + pattern (3).","If you meant a plain substring test, switch to hasraw/matchesraw and drop the xpath.","If you meant an HTML tree test, add the xpath as the middle argument."],"exampleFix":"// before\n//@ has foo.html \"some text\"\n// after\n//@ hasraw foo.html \"some text\"\n","handlingStrategy":"validation","validationCode":"# Validate a has/matches/hasraw/matchesraw directive before committing it to a test\nraw_cmds = {\"hasraw\", \"matchesraw\"}\nif cmd in raw_cmds and len(args) != 2:\n    raise ValueError(f\"{cmd} requires exactly 2 args (path, pattern), got {len(args)}\")\nif cmd in {\"has\", \"matches\"} and len(args) != 3:\n    raise ValueError(f\"{cmd} requires exactly 3 args (path, xpath, pattern), got {len(args)}\")\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a cheat-sheet of htmldocck arities next to your test: hasraw/matchesraw=2, has/matches=3.","Run the rustdoc test locally before pushing; htmldocck reports the exact directive and line."],"tags":["rustdoc","htmldocck","testing","directive"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}