Clean up Label validation, and introduce a factory method for constructing a Label without validation.
RELNOTES: None
PiperOrigin-RevId: 164479651
diff --git a/src/main/java/com/google/devtools/build/lib/query2/BlazeQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/BlazeQueryEnvironment.java
index 5939573..2781b0f 100644
--- a/src/main/java/com/google/devtools/build/lib/query2/BlazeQueryEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/query2/BlazeQueryEnvironment.java
@@ -19,7 +19,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.cmdline.ResolvedTargets;
import com.google.devtools.build.lib.cmdline.TargetParsingException;
@@ -403,15 +402,11 @@
// Also add the BUILD file of the subinclude.
if (buildFiles) {
- try {
- addIfUniqueLabel(
- getSubincludeTarget(subinclude.getLocalTargetLabel("BUILD"), pkg),
- seenLabels,
- dependentFiles);
-
- } catch (LabelSyntaxException e) {
- throw new AssertionError("BUILD should always parse as a target name", e);
- }
+ addIfUniqueLabel(
+ getSubincludeTarget(
+ Label.createUnvalidated(subinclude.getPackageIdentifier(), "BUILD"), pkg),
+ seenLabels,
+ dependentFiles);
}
}
}