mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:24:42 +01:00
Fix check-diagnostics for pre-commit (#2683)
Unused diagnostics were incorrectly always returning "false" regardless of whether there was an issue. It was still looking for registry file changes, not kind file changes. Also, this should only be run once per pre-commit run (pass_filenames=false). Remove the one unused diagnostic.
This commit is contained in:
@@ -103,8 +103,10 @@ repos:
|
||||
(?x)^(
|
||||
toolchain/.*\.cpp|
|
||||
toolchain/.*\.h|
|
||||
toolchain/diagnostics/diagnostic_registry\.def
|
||||
toolchain/diagnostics/check_diagnostics\.py|
|
||||
toolchain/diagnostics/diagnostic_kind\.def
|
||||
)$
|
||||
pass_filenames: false
|
||||
|
||||
# Run linters last, as formatters and other checks may fix issues.
|
||||
- repo: local
|
||||
|
||||
@@ -15,8 +15,8 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
import collections
|
||||
from concurrent import futures
|
||||
import itertools
|
||||
from pathlib import Path
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
from typing import Dict, List, NamedTuple, Set
|
||||
@@ -98,9 +98,11 @@ def check_uniqueness(uses: Dict[str, List[Location]]) -> bool:
|
||||
def check_unused(decls: Set[str], uses: Dict[str, List[Location]]) -> bool:
|
||||
"""If any diagnostic is unused, prints an error and returns true."""
|
||||
unused = decls.difference(uses.keys())
|
||||
if not unused:
|
||||
return False
|
||||
for diag in sorted(unused):
|
||||
print(f"Unused diagnostic: {diag}")
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
||||
@@ -84,9 +84,6 @@ CARBON_DIAGNOSTIC_KIND(ExpectedDeclarationName)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedDeclarationSemiOrDefinition)
|
||||
CARBON_DIAGNOSTIC_KIND(MethodImplNotAllowed)
|
||||
|
||||
// Class and interface diagnostics
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedDeducedParam)
|
||||
|
||||
// ============================================================================
|
||||
// Semantics diagnostics
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user