bazel syntax: remove Location from calling convention

This change removes the Location parameter from StarlarkCallable.call
(built-in functions) and the SkylarkCallable.useLocation feature from
annotated built-in functions.

Lately, the thread's call stack records the position of the program
counter of each active frame, so clients may access it through
StarlarkThread.getCallerLocation.

Numerous parameters that pass Locations merely to construct an
EvalException have been deleted. (This is the bulk of the change.)
Many places that directly constructed an EvalException now call
Starlark.errorf instead. (A few places in Bazel formerly specified a
location other than thread.getCallerLocation, or equivalently, null.)
The evaluator ensures that any exception thrown by Starlark.call
is augmented with the location of the call.

PiperOrigin-RevId: 291009378
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/CommandLineArgsApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/CommandLineArgsApi.java
index 016e969..2e74568 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/CommandLineArgsApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/CommandLineArgsApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkinterface.Param;
 import com.google.devtools.build.lib.skylarkinterface.ParamType;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
@@ -24,6 +23,7 @@
 import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.Sequence;
+import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.syntax.StarlarkValue;
 
 /** Command line args module. */
@@ -193,7 +193,7 @@
                     + "list's length must equal the number of items. Use <code>map_each</code> "
                     + "of <code>add_all</code> or <code>add_joined</code> instead.")
       },
-      useLocation = true)
+      useStarlarkThread = true)
   CommandLineArgsApi addArgument(
       Object argNameOrValue,
       Object value,
@@ -201,7 +201,7 @@
       Object beforeEach,
       Object joinWith,
       Object mapFn,
-      Location loc)
+      StarlarkThread thread)
       throws EvalException;
 
   @SkylarkCallable(
@@ -349,7 +349,7 @@
                     + "items are appended (as happens if <code>values</code> is empty or all of "
                     + "its items are filtered)."),
       },
-      useLocation = true)
+      useStarlarkThread = true)
   CommandLineArgsApi addAll(
       Object argNameOrValue,
       Object values,
@@ -360,7 +360,7 @@
       Boolean uniquify,
       Boolean expandDirectories,
       Object terminateWith,
-      Location loc)
+      StarlarkThread thread)
       throws EvalException;
 
   @SkylarkCallable(
@@ -465,7 +465,7 @@
             defaultValue = "True",
             doc = "Same as for <a href='#add_all.expand_directories'><code>add_all</code></a>.")
       },
-      useLocation = true)
+      useStarlarkThread = true)
   CommandLineArgsApi addJoined(
       Object argNameOrValue,
       Object values,
@@ -476,7 +476,7 @@
       Boolean omitIfEmpty,
       Boolean uniquify,
       Boolean expandDirectories,
-      Location loc)
+      StarlarkThread thread)
       throws EvalException;
 
   @SkylarkCallable(
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/DefaultInfoApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/DefaultInfoApi.java
index 2450bfa..393ffc1 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/DefaultInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/DefaultInfoApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.StructApi;
 import com.google.devtools.build.lib.skylarkinterface.Param;
@@ -24,6 +23,7 @@
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
 import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.EvalException;
+import com.google.devtools.build.lib.syntax.StarlarkThread;
 
 /** A provider that gives general information about a target's direct and transitive files. */
 @SkylarkModule(
@@ -149,8 +149,8 @@
                       + " should be executed to run the target. By default it is the predeclared"
                       + " output <code>ctx.outputs.executable</code>.")
         },
-        useLocation = true,
-        selfCall = true)
+        selfCall = true,
+        useStarlarkThread = true)
     @SkylarkConstructor(objectType = DefaultInfoApi.class, receiverNameForDoc = "DefaultInfo")
     DefaultInfoApi constructor(
         // TODO(cparsons): Use stricter types when Runfiles.NONE is passed as null.
@@ -159,7 +159,7 @@
         Object dataRunfiles,
         Object defaultRunfiles,
         Object executable,
-        Location loc)
+        StarlarkThread thread)
         throws EvalException;
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/OutputGroupInfoApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/OutputGroupInfoApi.java
index 43e4952..26b6f60 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/OutputGroupInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/OutputGroupInfoApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.StructApi;
 import com.google.devtools.build.lib.skylarkinterface.Param;
@@ -55,11 +54,10 @@
                 type = Dict.class,
                 defaultValue = "{}",
                 doc = "Dictionary of arguments."),
-        useLocation = true,
         selfCall = true)
     @SkylarkConstructor(
         objectType = OutputGroupInfoApi.class,
         receiverNameForDoc = "OutputGroupInfo")
-    OutputGroupInfoApi constructor(Dict<?, ?> kwargs, Location loc) throws EvalException;
+    OutputGroupInfoApi constructor(Dict<?, ?> kwargs) throws EvalException;
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkActionFactoryApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkActionFactoryApi.java
index acea0a9..ec0bf1f 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkActionFactoryApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkActionFactoryApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkinterface.Param;
 import com.google.devtools.build.lib.skylarkinterface.ParamType;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
@@ -72,9 +71,8 @@
             positional = false,
             named = true,
             defaultValue = "None")
-      },
-      useLocation = true)
-  FileApi declareFile(String filename, Object sibling, Location loc) throws EvalException;
+      })
+  FileApi declareFile(String filename, Object sibling) throws EvalException;
 
   @SkylarkCallable(
       name = "declare_directory",
@@ -129,9 +127,8 @@
             positional = false,
             named = true,
             defaultValue = "None")
-      },
-      useLocation = true)
-  FileApi declareSymlink(String filename, Object sibling, Location location) throws EvalException;
+      })
+  FileApi declareSymlink(String filename, Object sibling) throws EvalException;
 
   @SkylarkCallable(
       name = "do_nothing",
@@ -156,9 +153,8 @@
             positional = false,
             defaultValue = "[]",
             doc = "List of the input files of the action."),
-      },
-      useLocation = true)
-  void doNothing(String mnemonic, Object inputs, Location location) throws EvalException;
+      })
+  void doNothing(String mnemonic, Object inputs) throws EvalException;
 
   @SkylarkCallable(
       name = "symlink",
@@ -172,9 +168,8 @@
       parameters = {
         @Param(name = "output", type = FileApi.class, doc = "The output path.", named = true),
         @Param(name = "target", type = String.class, doc = "The target.", named = true),
-      },
-      useLocation = true)
-  void symlink(FileApi output, String targetPath, Location location) throws EvalException;
+      })
+  void symlink(FileApi output, String targetPath) throws EvalException;
 
   @SkylarkCallable(
       name = "write",
@@ -203,10 +198,8 @@
             defaultValue = "False",
             doc = "Whether the output file should be executable.",
             named = true)
-      },
-      useLocation = true)
-  void write(FileApi output, Object content, Boolean isExecutable, Location location)
-      throws EvalException;
+      })
+  void write(FileApi output, Object content, Boolean isExecutable) throws EvalException;
 
   @SkylarkCallable(
       name = "run",
@@ -344,8 +337,7 @@
             doc =
                 "(Experimental) sets the input runfiles metadata; "
                     + "they are typically generated by resolve_command.")
-      },
-      useLocation = true)
+      })
   void run(
       Sequence<?> outputs,
       Object inputs,
@@ -358,8 +350,7 @@
       Boolean useDefaultShellEnv,
       Object envUnchecked,
       Object executionRequirementsUnchecked,
-      Object inputManifestsUnchecked,
-      Location location)
+      Object inputManifestsUnchecked)
       throws EvalException;
 
   @SkylarkCallable(
@@ -515,8 +506,7 @@
                 "(Experimental) sets the input runfiles metadata; "
                     + "they are typically generated by resolve_command.")
       },
-      useStarlarkThread = true,
-      useLocation = true)
+      useStarlarkThread = true)
   void runShell(
       Sequence<?> outputs,
       Object inputs,
@@ -529,7 +519,6 @@
       Object envUnchecked,
       Object executionRequirementsUnchecked,
       Object inputManifestsUnchecked,
-      Location location,
       StarlarkThread thread)
       throws EvalException;
 
@@ -572,14 +561,9 @@
             named = true,
             positional = false,
             doc = "Whether the output file should be executable.")
-      },
-      useLocation = true)
+      })
   void expandTemplate(
-      FileApi template,
-      FileApi output,
-      Dict<?, ?> substitutionsUnchecked,
-      Boolean executable,
-      Location location)
+      FileApi template, FileApi output, Dict<?, ?> substitutionsUnchecked, Boolean executable)
       throws EvalException;
 
   @SkylarkCallable(
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkAttrApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkAttrApi.java
index 9719968..24f39a6 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkAttrApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkAttrApi.java
@@ -15,7 +15,6 @@
 package com.google.devtools.build.lib.skylarkbuildapi;
 
 import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkinterface.Param;
 import com.google.devtools.build.lib.skylarkinterface.ParamType;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
@@ -177,14 +176,12 @@
             named = true,
             positional = false)
       },
-      useLocation = true,
       useStarlarkThread = true)
   Descriptor intAttribute(
       Integer defaultValue,
       String doc,
       Boolean mandatory,
       Sequence<?> values,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -222,14 +219,12 @@
             named = true,
             positional = false)
       },
-      useLocation = true,
       useStarlarkThread = true)
   Descriptor stringAttribute(
       String defaultValue,
       String doc,
       Boolean mandatory,
       Sequence<?> values,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -359,7 +354,6 @@
             positional = false,
             doc = ASPECTS_ARG_DOC),
       },
-      useLocation = true,
       useStarlarkThread = true)
   Descriptor labelAttribute(
       Object defaultValue,
@@ -373,7 +367,6 @@
       Boolean singleFile,
       Object cfg,
       Sequence<?> aspects,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -415,7 +408,6 @@
             named = true,
             positional = false)
       },
-      useLocation = true,
       useStarlarkThread = true)
   Descriptor stringListAttribute(
       Boolean mandatory,
@@ -423,7 +415,6 @@
       Boolean allowEmpty,
       Sequence<?> defaultValue,
       String doc,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -465,7 +456,6 @@
             named = true,
             positional = false)
       },
-      useLocation = true,
       useStarlarkThread = true)
   Descriptor intListAttribute(
       Boolean mandatory,
@@ -473,7 +463,6 @@
       Boolean allowEmpty,
       Sequence<?> defaultValue,
       String doc,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -573,7 +562,6 @@
             positional = false,
             doc = ASPECTS_ARG_DOC),
       },
-      useLocation = true,
       useStarlarkThread = true)
   Descriptor labelListAttribute(
       Boolean allowEmpty,
@@ -587,7 +575,6 @@
       Boolean nonEmpty,
       Object cfg,
       Sequence<?> aspects,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -689,7 +676,6 @@
             positional = false,
             doc = ASPECTS_ARG_DOC)
       },
-      useLocation = true,
       useStarlarkThread = true)
   Descriptor labelKeyedStringDictAttribute(
       Boolean allowEmpty,
@@ -703,7 +689,6 @@
       Boolean nonEmpty,
       Object cfg,
       Sequence<?> aspects,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -733,10 +718,9 @@
             positional = false,
             doc = MANDATORY_DOC)
       },
-      useLocation = true,
       useStarlarkThread = true)
   Descriptor boolAttribute(
-      Boolean defaultValue, String doc, Boolean mandatory, Location loc, StarlarkThread thread)
+      Boolean defaultValue, String doc, Boolean mandatory, StarlarkThread thread)
       throws EvalException;
 
   @SkylarkCallable(
@@ -771,10 +755,9 @@
             positional = false,
             doc = MANDATORY_DOC)
       },
-      useLocation = true,
       useStarlarkThread = true)
   Descriptor outputAttribute(
-      Object defaultValue, String doc, Boolean mandatory, Location loc, StarlarkThread thread)
+      Object defaultValue, String doc, Boolean mandatory, StarlarkThread thread)
       throws EvalException;
 
   @SkylarkCallable(
@@ -822,7 +805,6 @@
             positional = false,
             doc = NON_EMPTY_DOC)
       },
-      useLocation = true,
       useStarlarkThread = true)
   Descriptor outputListAttribute(
       Boolean allowEmpty,
@@ -830,7 +812,6 @@
       String doc,
       Boolean mandatory,
       Boolean nonEmpty,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -875,7 +856,6 @@
             positional = false,
             doc = NON_EMPTY_DOC)
       },
-      useLocation = true,
       useStarlarkThread = true)
   Descriptor stringDictAttribute(
       Boolean allowEmpty,
@@ -883,7 +863,6 @@
       String doc,
       Boolean mandatory,
       Boolean nonEmpty,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -928,7 +907,6 @@
             positional = false,
             doc = NON_EMPTY_DOC)
       },
-      useLocation = true,
       useStarlarkThread = true)
   Descriptor stringListDictAttribute(
       Boolean allowEmpty,
@@ -936,7 +914,6 @@
       String doc,
       Boolean mandatory,
       Boolean nonEmpty,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -969,10 +946,9 @@
             doc = MANDATORY_DOC)
       },
       disableWithFlag = FlagIdentifier.INCOMPATIBLE_NO_ATTR_LICENSE,
-      useLocation = true,
       useStarlarkThread = true)
   Descriptor licenseAttribute(
-      Object defaultValue, String doc, Boolean mandatory, Location loc, StarlarkThread thread)
+      Object defaultValue, String doc, Boolean mandatory, StarlarkThread thread)
       throws EvalException;
 
   /** An attribute descriptor. */
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkBuildApiGlobals.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkBuildApiGlobals.java
index 1eccbd2..100211e 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkBuildApiGlobals.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkBuildApiGlobals.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkinterface.Param;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkGlobalLibrary;
@@ -55,8 +54,7 @@
             named = true,
             doc = "The name of the value to obtain from the configuration fragment."),
       },
-      useLocation = true,
       useStarlarkThread = true)
-  LateBoundDefaultApi configurationField(
-      String fragment, String name, Location loc, StarlarkThread thread) throws EvalException;
+  LateBoundDefaultApi configurationField(String fragment, String name, StarlarkThread thread)
+      throws EvalException;
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkNativeModuleApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkNativeModuleApi.java
index 960ae79..d68e0b3 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkNativeModuleApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkNativeModuleApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkinterface.Param;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
@@ -83,14 +82,12 @@
                     + " result must be non-empty (after the matches of the `exclude` patterns are"
                     + " excluded).")
       },
-      useLocation = true,
       useStarlarkThread = true)
   Sequence<?> glob(
       Sequence<?> include,
       Sequence<?> exclude,
       Integer excludeDirectories,
       Object allowEmpty,
-      Location loc,
       StarlarkThread thread)
       throws EvalException, InterruptedException;
 
@@ -127,9 +124,8 @@
             legacyNamed = true,
             doc = "The name of the target.")
       },
-      useLocation = true,
       useStarlarkThread = true)
-  Object existingRule(String name, Location loc, StarlarkThread thread)
+  Object existingRule(String name, StarlarkThread thread)
       throws EvalException, InterruptedException;
 
   @SkylarkCallable(
@@ -140,9 +136,8 @@
               + " would be returned by <code>existing_rule(name)</code>.<p><i>Note: If possible,"
               + " avoid using this function. It makes BUILD files brittle and order-dependent, and"
               + " it may be expensive especially if called within a loop.</i>",
-      useLocation = true,
       useStarlarkThread = true)
-  Dict<String, Dict<String, Object>> existingRules(Location loc, StarlarkThread thread)
+  Dict<String, Dict<String, Object>> existingRules(StarlarkThread thread)
       throws EvalException, InterruptedException;
 
   @SkylarkCallable(
@@ -174,10 +169,9 @@
             positional = false,
             doc = "Other package groups that are included in this one.")
       },
-      useLocation = true,
       useStarlarkThread = true)
   NoneType packageGroup(
-      String name, Sequence<?> packages, Sequence<?> includes, Location loc, StarlarkThread thread)
+      String name, Sequence<?> packages, Sequence<?> includes, StarlarkThread thread)
       throws EvalException;
 
   @SkylarkCallable(
@@ -212,10 +206,8 @@
             defaultValue = "None",
             doc = "Licenses to be specified.")
       },
-      useLocation = true,
       useStarlarkThread = true)
-  NoneType exportsFiles(
-      Sequence<?> srcs, Object visibility, Object licenses, Location loc, StarlarkThread thread)
+  NoneType exportsFiles(Sequence<?> srcs, Object visibility, Object licenses, StarlarkThread thread)
       throws EvalException;
 
   @SkylarkCallable(
@@ -227,10 +219,8 @@
               + "If the BUILD file calls a function defined in a .bzl file, "
               + "<code>package_name()</code> will match the caller BUILD file package. "
               + "This function is equivalent to the deprecated variable <code>PACKAGE_NAME</code>.",
-      parameters = {},
-      useLocation = true,
       useStarlarkThread = true)
-  String packageName(Location loc, StarlarkThread thread) throws EvalException;
+  String packageName(StarlarkThread thread) throws EvalException;
 
   @SkylarkCallable(
       name = "repository_name",
@@ -241,8 +231,6 @@
               + "<code>@local</code>. In packages in the main repository, it will be set to "
               + "<code>@</code>. This function is equivalent to the deprecated variable "
               + "<code>REPOSITORY_NAME</code>.",
-      parameters = {},
-      useLocation = true,
       useStarlarkThread = true)
-  String repositoryName(Location location, StarlarkThread thread) throws EvalException;
+  String repositoryName(StarlarkThread thread) throws EvalException;
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkRuleContextApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkRuleContextApi.java
index 8a134cc..eb292c5 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkRuleContextApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkRuleContextApi.java
@@ -16,7 +16,6 @@
 
 import com.google.common.collect.ImmutableList;
 import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.StructApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.TransitiveInfoCollectionApi;
@@ -422,9 +421,8 @@
             },
             defaultValue = "unbound",
             doc = "")
-      },
-      useLocation = true)
-  FileApi newFile(Object var1, Object var2, Object var3, Location loc) throws EvalException;
+      })
+  FileApi newFile(Object var1, Object var2, Object var3) throws EvalException;
 
   @SkylarkCallable(
       name = "experimental_new_directory",
@@ -669,7 +667,6 @@
                     + "they are typically generated by resolve_command.")
       },
       allowReturnNones = true,
-      useLocation = true,
       useStarlarkThread = true)
   NoneType action(
       Sequence<?> outputs,
@@ -684,7 +681,6 @@
       Object envUnchecked,
       Object executionRequirementsUnchecked,
       Object inputManifestsUnchecked,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -717,9 +713,8 @@
             doc = "List of targets for additional lookup information."),
       },
       allowReturnNones = true,
-      useLocation = true,
       useStarlarkThread = true)
-  String expandLocation(String input, Sequence<?> targets, Location loc, StarlarkThread thread)
+  String expandLocation(String input, Sequence<?> targets, StarlarkThread thread)
       throws EvalException;
 
   @SkylarkCallable(
@@ -742,10 +737,8 @@
             doc = "Whether the output file should be executable (default is False).")
       },
       allowReturnNones = true,
-      useLocation = true,
       useStarlarkThread = true)
-  NoneType fileAction(
-      FileApi output, String content, Boolean executable, Location loc, StarlarkThread thread)
+  NoneType fileAction(FileApi output, String content, Boolean executable, StarlarkThread thread)
       throws EvalException;
 
   @SkylarkCallable(
@@ -775,10 +768,8 @@
             doc = "List of the input files of the action."),
       },
       allowReturnNones = true,
-      useLocation = true,
       useStarlarkThread = true)
-  NoneType emptyAction(String mnemonic, Object inputs, Location loc, StarlarkThread thread)
-      throws EvalException;
+  NoneType emptyAction(String mnemonic, Object inputs, StarlarkThread thread) throws EvalException;
 
   @SkylarkCallable(
       name = "template_action",
@@ -814,14 +805,12 @@
             doc = "Whether the output file should be executable (default is False).")
       },
       allowReturnNones = true,
-      useLocation = true,
       useStarlarkThread = true)
   NoneType templateAction(
       FileApi template,
       FileApi output,
       Dict<?, ?> substitutionsUnchecked,
       Boolean executable,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -882,16 +871,14 @@
             defaultValue = "{}",
             named = true,
             doc = "The map of symlinks to be added to the runfiles.")
-      },
-      useLocation = true)
+      })
   RunfilesApi runfiles(
       Sequence<?> files,
       Object transitiveFiles,
       Boolean collectData,
       Boolean collectDefault,
       Dict<?, ?> symlinks,
-      Dict<?, ?> rootSymlinks,
-      Location loc)
+      Dict<?, ?> rootSymlinks)
       throws EvalException;
 
   @SkylarkCallable(
@@ -966,7 +953,6 @@
                     + "<a href=\"$BE_ROOT/common-definitions.html#common.tags\">tags</a> "
                     + "for useful keys."),
       },
-      useLocation = true,
       useStarlarkThread = true)
   Tuple<Object> resolveCommand(
       String command,
@@ -976,7 +962,6 @@
       Sequence<?> tools,
       Dict<?, ?> labelDictUnchecked,
       Dict<?, ?> executionRequirementsUnchecked,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -998,8 +983,6 @@
             named = true,
             positional = false,
             doc = "List of tools (list of targets)."),
-      },
-      useLocation = false,
-      useStarlarkThread = false)
+      })
   Tuple<Object> resolveTools(Sequence<?> tools) throws EvalException;
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkRuleFunctionsApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkRuleFunctionsApi.java
index c21396f..3d2d8a8 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkRuleFunctionsApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkRuleFunctionsApi.java
@@ -15,7 +15,6 @@
 package com.google.devtools.build.lib.skylarkbuildapi;
 
 import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.StarlarkConfigApi.BuildSettingApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
 import com.google.devtools.build.lib.skylarkinterface.Param;
@@ -85,8 +84,8 @@
             positional = false,
             defaultValue = "None")
       },
-      useLocation = true)
-  ProviderApi provider(String doc, Object fields, Location location) throws EvalException;
+      useStarlarkThread = true)
+  ProviderApi provider(String doc, Object fields, StarlarkThread thread) throws EvalException;
 
   @SkylarkCallable(
       name = "rule",
@@ -330,7 +329,6 @@
                 "If set, points to the configuration transition the rule will "
                     + "apply to its own configuration before analysis.")
       },
-      useLocation = true,
       useStarlarkThread = true)
   BaseFunction rule(
       StarlarkFunction implementation,
@@ -349,7 +347,6 @@
       Object analysisTest,
       Object buildSetting,
       Object cfg,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -488,8 +485,7 @@
                     + "will propagate through `alpha`, `beta`, and `charlie`. If False, then the "
                     + "aspect will propagate only to `alpha`. </p><p>False by default.</p>")
       },
-      useStarlarkThread = true,
-      useLocation = true)
+      useStarlarkThread = true)
   SkylarkAspectApi aspect(
       StarlarkFunction implementation,
       Sequence<?> attributeAspects,
@@ -501,7 +497,6 @@
       Sequence<?> toolchains,
       String doc,
       Boolean applyToGeneratingRules,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -533,10 +528,8 @@
                     + "False, a repo-relative label is resolved relative to the file in which the "
                     + "Label() call appears.")
       },
-      useLocation = true,
       useStarlarkThread = true)
   @SkylarkConstructor(objectType = Label.class)
-  Label label(
-      String labelString, Boolean relativeToCallerRepository, Location loc, StarlarkThread thread)
+  Label label(String labelString, Boolean relativeToCallerRepository, StarlarkThread thread)
       throws EvalException;
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/TemplateVariableInfoApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/TemplateVariableInfoApi.java
index 2845b19..83057f7 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/TemplateVariableInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/TemplateVariableInfoApi.java
@@ -15,7 +15,6 @@
 package com.google.devtools.build.lib.skylarkbuildapi;
 
 import com.google.common.collect.ImmutableMap;
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.StructApi;
 import com.google.devtools.build.lib.skylarkinterface.Param;
@@ -24,6 +23,7 @@
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
 import com.google.devtools.build.lib.syntax.Dict;
 import com.google.devtools.build.lib.syntax.EvalException;
+import com.google.devtools.build.lib.syntax.StarlarkThread;
 
 /** Provides access to make variables from the current fragments. */
 @SkylarkModule(
@@ -62,8 +62,8 @@
           @Param(name = "vars", positional = true, named = true, type = Dict.class),
         },
         selfCall = true,
-        useLocation = true)
-    TemplateVariableInfoApi templateVariableInfo(Dict<?, ?> vars, Location loc)
+        useStarlarkThread = true)
+    TemplateVariableInfoApi templateVariableInfo(Dict<?, ?> vars, StarlarkThread thread)
         throws EvalException;
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/WorkspaceGlobalsApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/WorkspaceGlobalsApi.java
index a620a47..736507b 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/WorkspaceGlobalsApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/WorkspaceGlobalsApi.java
@@ -15,7 +15,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkinterface.Param;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkGlobalLibrary;
@@ -78,12 +77,10 @@
                     + "\nManaged directories must be excluded from the source tree by listing"
                     + " them (or their parent directories) in the .bazelignore file."),
       },
-      useLocation = true,
       useStarlarkThread = true)
   NoneType workspace(
       String name,
       Dict<?, ?> managedDirectories, // <String, Sequence<String>>
-      Location loc,
       StarlarkThread thread)
       throws EvalException, InterruptedException;
 
@@ -112,10 +109,9 @@
             named = true,
             positional = false)
       },
-      useLocation = true,
       useStarlarkThread = true,
       enableOnlyWithFlag = FlagIdentifier.EXPERIMENTAL_NINJA_ACTIONS)
-  NoneType dontSymlinkDirectoriesInExecroot(Sequence<?> paths, Location loc, StarlarkThread thread)
+  NoneType dontSymlinkDirectoriesInExecroot(Sequence<?> paths, StarlarkThread thread)
       throws EvalException, InterruptedException;
 
   @SkylarkCallable(
@@ -128,10 +124,8 @@
               type = Sequence.class,
               generic1 = String.class,
               doc = "The labels of the platforms to register."),
-      useLocation = true,
       useStarlarkThread = true)
-  NoneType registerExecutionPlatforms(
-      Sequence<?> platformLabels, Location location, StarlarkThread thread)
+  NoneType registerExecutionPlatforms(Sequence<?> platformLabels, StarlarkThread thread)
       throws EvalException, InterruptedException;
 
   @SkylarkCallable(
@@ -146,9 +140,8 @@
               type = Sequence.class,
               generic1 = String.class,
               doc = "The labels of the toolchains to register."),
-      useLocation = true,
       useStarlarkThread = true)
-  NoneType registerToolchains(Sequence<?> toolchainLabels, Location location, StarlarkThread thread)
+  NoneType registerToolchains(Sequence<?> toolchainLabels, StarlarkThread thread)
       throws EvalException, InterruptedException;
 
   @SkylarkCallable(
@@ -175,8 +168,7 @@
             defaultValue = "None",
             doc = "The real label to be aliased")
       },
-      useLocation = true,
       useStarlarkThread = true)
-  NoneType bind(String name, Object actual, Location loc, StarlarkThread thread)
+  NoneType bind(String name, Object actual, StarlarkThread thread)
       throws EvalException, InterruptedException;
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/AndroidDataProcessingApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/AndroidDataProcessingApi.java
index 19eba87..be67ec0 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/AndroidDataProcessingApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/AndroidDataProcessingApi.java
@@ -13,7 +13,6 @@
 // limitations under the License.
 package com.google.devtools.build.lib.skylarkbuildapi.android;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.FileApi;
 import com.google.devtools.build.lib.skylarkbuildapi.FileProviderApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
@@ -126,8 +125,6 @@
             named = true,
             doc = "The Android application package to stamp the manifest with."),
       },
-      useLocation = true,
-      useStarlarkThread = true,
       doc =
           "Creates an AndroidResourcesInfoApi from this target's resource dependencies, ignoring"
               + " local resources. Only processing of deps will be done. This method is deprecated"
@@ -140,9 +137,7 @@
       Sequence<?> deps, // <AndroidResourcesInfoT>
       Sequence<?> assets, // <AndroidAssetsInfoT>
       boolean neverlink,
-      String customPackage,
-      Location location,
-      StarlarkThread thread)
+      String customPackage)
       throws InterruptedException, EvalException;
 
   @SkylarkCallable(
@@ -185,17 +180,10 @@
                     + " eventually merged into targets that depend on it. Otherwise, it won't be"
                     + " inherited."),
       },
-      useLocation = true,
-      useStarlarkThread = true,
       doc = "Stamps a manifest with package information.",
       documented = false)
   AndroidManifestInfoT stampAndroidManifest(
-      AndroidDataContextT ctx,
-      Object manifest,
-      Object customPackage,
-      boolean exported,
-      Location location,
-      StarlarkThread thread)
+      AndroidDataContextT ctx, Object manifest, Object customPackage, boolean exported)
       throws InterruptedException, EvalException;
 
   @SkylarkCallable(
@@ -248,8 +236,6 @@
                 "Defaults to False. If passed as True, these assets will not be inherited by"
                     + " targets that depend on this one.")
       },
-      useLocation = true,
-      useStarlarkThread = true,
       doc =
           "Merges this target's assets together with assets inherited from dependencies. Note that,"
               + " by default, actions for validating the merge are created but may not be called."
@@ -261,9 +247,7 @@
       Object assets,
       Object assetsDir,
       Sequence<?> deps, // <AndroidAssetsInfoT>
-      boolean neverlink,
-      Location location,
-      StarlarkThread thread)
+      boolean neverlink)
       throws EvalException, InterruptedException;
 
   @SkylarkCallable(
@@ -320,8 +304,6 @@
                 "Defaults to False. If True, processes data binding expressions in layout"
                     + " resources."),
       },
-      useLocation = true,
-      useStarlarkThread = true,
       doc =
           "Merges this target's resources together with resources inherited from dependencies."
               + " Returns a dict of provider type to actual info, with elements for"
@@ -339,9 +321,7 @@
       Sequence<?> resources, // <TransitiveInfoCollectionT>
       Sequence<?> deps, // <AndroidResourcesInfoT>
       boolean neverlink,
-      boolean enableDataBinding,
-      Location location,
-      StarlarkThread thread)
+      boolean enableDataBinding)
       throws EvalException, InterruptedException;
 
   @SkylarkCallable(
@@ -398,8 +378,6 @@
                 "Defaults to False. If True, processes data binding expressions in layout"
                     + " resources."),
       },
-      useLocation = true,
-      useStarlarkThread = true,
       doc =
           "Merges this target's resources together with resources inherited from dependencies."
               + " Returns a dict of provider type to actual info, with elements for"
@@ -416,9 +394,7 @@
       Sequence<?> resources, // <TransitiveInfoCollectionT>
       Sequence<?> deps, // <AndroidResourcesInfoT>
       boolean neverlink,
-      boolean enableDataBinding,
-      Location location,
-      StarlarkThread thread)
+      boolean enableDataBinding)
       throws EvalException, InterruptedException;
 
   @SkylarkCallable(
@@ -639,8 +615,6 @@
             named = true,
             doc = "A list of file extensions to leave uncompressed in the resource apk.")
       },
-      useLocation = true,
-      useStarlarkThread = true,
       doc =
           "Processes resources, assets, and manifests for android_local_test and returns a dict"
               + " from provider type to the appropriate provider.",
@@ -655,9 +629,7 @@
       String aaptVersionString,
       Dict<?, ?> manifestValues, // <String, String>
       Sequence<?> deps, // <TransitiveInfoCollectionT>
-      Sequence<?> noCompressExtensions, // <String>
-      Location location,
-      StarlarkThread thread)
+      Sequence<?> noCompressExtensions) // <String>
       throws InterruptedException, EvalException;
 
   @SkylarkCallable(
@@ -711,8 +683,6 @@
                 "A list of file extension to leave uncompressed in apk. Templates must be"
                     + " expanded before passing this value in."),
       },
-      useLocation = true,
-      useStarlarkThread = true,
       doc =
           "Returns a wrapper object containing various settings shared across multiple methods for"
               + " processing binary data.",
@@ -722,9 +692,7 @@
       Object shrinkResources,
       Sequence<?> resourceConfigurationFilters, // <String>
       Sequence<?> densities, // <String>
-      Sequence<?> noCompressExtensions, // <String>
-      Location location,
-      StarlarkThread thread)
+      Sequence<?> noCompressExtensions) // <String>
       throws EvalException;
 
   @SkylarkCallable(
@@ -843,8 +811,6 @@
                 "Defaults to False. If True, processes data binding expressions in layout"
                     + " resources."),
       },
-      useLocation = true,
-      useStarlarkThread = true,
       doc =
           "Processes resources, assets, and manifests for android_binary and returns the"
               + " appropriate providers.",
@@ -861,9 +827,7 @@
       String manifestMerger,
       Object maybeSettings,
       boolean crunchPng,
-      boolean dataBindingEnabled,
-      Location location,
-      StarlarkThread thread)
+      boolean dataBindingEnabled)
       throws InterruptedException, EvalException;
 
   @SkylarkCallable(
@@ -934,8 +898,6 @@
                 "Additional proguard specs that should be added for top-level targets. This  value"
                     + " is controlled by Java configuration.")
       },
-      useLocation = true,
-      useStarlarkThread = true,
       doc =
           "Possibly shrinks the data APK by removing resources that were marked as unused during"
               + " proguarding.",
@@ -948,9 +910,7 @@
       Object maybeSettings,
       Sequence<?> deps, // <TransitiveInfoCollectionT>
       Sequence<?> localProguardSpecs, // <TransitiveInfoCollectionT>
-      Sequence<?> extraProguardSpecs, // <TransitiveInfoCollectionT>
-      Location location,
-      StarlarkThread thread)
+      Sequence<?> extraProguardSpecs) // <TransitiveInfoCollectionT>
       throws EvalException, InterruptedException;
 
   @SkylarkCallable(
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/ApkInfoApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/ApkInfoApi.java
index 152dcfa..1eef012 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/ApkInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/ApkInfoApi.java
@@ -13,7 +13,6 @@
 // limitations under the License.
 package com.google.devtools.build.lib.skylarkbuildapi.android;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.FileApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.StructApi;
@@ -85,8 +84,7 @@
         // This is left undocumented as it throws a "not-implemented in Skylark" error when invoked.
         documented = false,
         extraKeywords = @Param(name = "kwargs"),
-        useLocation = true,
         selfCall = true)
-    ApkInfoApi<?> createInfo(Dict<String, Object> kwargs, Location loc) throws EvalException;
+    ApkInfoApi<?> createInfo(Dict<String, Object> kwargs) throws EvalException;
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/config/ConfigGlobalLibraryApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/config/ConfigGlobalLibraryApi.java
index 111d662..5fc9b28 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/config/ConfigGlobalLibraryApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/config/ConfigGlobalLibraryApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi.config;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkinterface.Param;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkConstructor;
@@ -97,14 +96,12 @@
                 "List of build settings that can be written by this transition. This must be "
                     + "a superset of the key set of the dictionary returned by this transition."),
       },
-      useLocation = true,
       useStarlarkThread = true)
   @SkylarkConstructor(objectType = ConfigurationTransitionApi.class)
   ConfigurationTransitionApi transition(
       BaseFunction implementation,
       Sequence<?> inputs, // <String> expected
       Sequence<?> outputs, // <String> expected
-      Location location,
       StarlarkThread thread)
       throws EvalException;
 
@@ -131,9 +128,9 @@
                     + "are unchanged. Use this to declare specific configuration settings that "
                     + "an analysis test requires to be set in order to pass."),
       },
-      useLocation = true)
+      useStarlarkThread = true)
   ConfigurationTransitionApi analysisTestTransition(
       Dict<?, ?> changedSettings, // <String, String> expected
-      Location location)
+      StarlarkThread thread)
       throws EvalException;
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/core/StructApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/core/StructApi.java
index 1bc6aac..d0e6ae8 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/core/StructApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/core/StructApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi.core;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkinterface.Param;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkConstructor;
@@ -22,6 +21,7 @@
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
 import com.google.devtools.build.lib.syntax.Dict;
 import com.google.devtools.build.lib.syntax.EvalException;
+import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.syntax.StarlarkValue;
 
 /** Interface for the "struct" object in the build API. */
@@ -62,9 +62,8 @@
               + "#   key: 2\n"
               + "#   value: 1\n"
               + "# }\n"
-              + "</pre>",
-      useLocation = true)
-  String toProto(Location loc) throws EvalException;
+              + "</pre>")
+  String toProto() throws EvalException;
 
   @SkylarkCallable(
       name = "to_json",
@@ -83,9 +82,8 @@
               + "struct(key=[struct(inner_key=1), struct(inner_key=2)]).to_json()\n"
               + "# {\"key\":[{\"inner_key\":1},{\"inner_key\":2}]}\n\n"
               + "struct(key=struct(inner_key=struct(inner_inner_key='text'))).to_json()\n"
-              + "# {\"key\":{\"inner_key\":{\"inner_inner_key\":\"text\"}}}\n</pre>",
-      useLocation = true)
-  String toJson(Location loc) throws EvalException;
+              + "# {\"key\":{\"inner_key\":{\"inner_inner_key\":\"text\"}}}\n</pre>")
+  String toJson() throws EvalException;
 
   /** Callable Provider for new struct objects. */
   @SkylarkModule(name = "Provider", documented = false, doc = "")
@@ -104,9 +102,9 @@
                 type = Dict.class,
                 defaultValue = "{}",
                 doc = "Dictionary of arguments."),
-        useLocation = true,
+        useStarlarkThread = true,
         selfCall = true)
     @SkylarkConstructor(objectType = StructApi.class, receiverNameForDoc = "struct")
-    StructApi createStruct(Dict<?, ?> kwargs, Location loc) throws EvalException;
+    StructApi createStruct(Dict<String, Object> kwargs, StarlarkThread thread) throws EvalException;
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/BazelCcModuleApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/BazelCcModuleApi.java
index b213f58..30f697e 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/BazelCcModuleApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/BazelCcModuleApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi.cpp;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.FileApi;
 import com.google.devtools.build.lib.skylarkbuildapi.SkylarkActionFactoryApi;
 import com.google.devtools.build.lib.skylarkbuildapi.SkylarkRuleContextApi;
@@ -70,7 +69,6 @@
           "Should be used for C++ compilation. Returns tuple of "
               + "(<code>CompilationContext</code>, <code>CcCompilationOutputs</code>).",
       useStarlarkThread = true,
-      useLocation = true,
       parameters = {
         @Param(
             name = "actions",
@@ -237,7 +235,6 @@
       boolean disallowPicOutputs,
       boolean disallowNopicOutputs,
       Sequence<?> additionalInputs, // <FileT> expected
-      Location location,
       StarlarkThread thread)
       throws EvalException, InterruptedException;
 
@@ -245,7 +242,6 @@
       name = "link",
       doc = "Should be used for C++ transitive linking.",
       useStarlarkThread = true,
-      useLocation = true,
       parameters = {
         @Param(
             name = "actions",
@@ -349,14 +345,12 @@
       boolean linkDepsStatically,
       Sequence<?> additionalInputs, // <FileT> expected
       Object grepIncludes,
-      Location location,
       StarlarkThread thread)
       throws InterruptedException, EvalException;
 
   @SkylarkCallable(
       name = "create_compilation_outputs",
       doc = "Create compilation outputs object.",
-      useLocation = true,
       parameters = {
         @Param(
             name = "objects",
@@ -376,7 +370,7 @@
             allowedTypes = {@ParamType(type = Depset.class), @ParamType(type = NoneType.class)}),
       })
   CompilationOutputsT createCompilationOutputsFromSkylark(
-      Object objectsObject, Object picObjectsObject, Location location) throws EvalException;
+      Object objectsObject, Object picObjectsObject) throws EvalException;
 
   @SkylarkCallable(
       name = "merge_compilation_outputs",
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcCompilationOutputsApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcCompilationOutputsApi.java
index 1248dd4..3a80faf 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcCompilationOutputsApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcCompilationOutputsApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi.cpp;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.FileApi;
 import com.google.devtools.build.lib.skylarkinterface.Param;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
@@ -38,13 +37,11 @@
       name = "object_files",
       doc = "Do not use. Use eiher 'objects' or 'pic_objects'.",
       useStarlarkThread = true,
-      useLocation = true,
       parameters = {
         @Param(name = "use_pic", doc = "use_pic", positional = false, named = true),
       })
   @Deprecated
-  Sequence<FileT> getSkylarkObjectFiles(boolean usePic, Location location, StarlarkThread thread)
-      throws EvalException;
+  Sequence<FileT> getSkylarkObjectFiles(boolean usePic, StarlarkThread thread) throws EvalException;
 
   @SkylarkCallable(name = "objects", documented = false, structField = true)
   Sequence<FileT> getSkylarkObjects() throws EvalException;
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcInfoApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcInfoApi.java
index 7e5a2c3..c24fc1c 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcInfoApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi.cpp;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.StructApi;
 import com.google.devtools.build.lib.skylarkinterface.Param;
@@ -25,7 +24,6 @@
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.NoneType;
-import com.google.devtools.build.lib.syntax.StarlarkThread;
 
 /** Wrapper for every C++ compilation and linking provider. */
 @SkylarkModule(
@@ -63,8 +61,6 @@
     @SkylarkCallable(
         name = NAME,
         doc = "The <code>CcInfo</code> constructor.",
-        useLocation = true,
-        useStarlarkThread = true,
         parameters = {
           @Param(
               name = "compilation_context",
@@ -91,8 +87,6 @@
         },
         selfCall = true)
     @SkylarkConstructor(objectType = CcInfoApi.class, receiverNameForDoc = NAME)
-    CcInfoApi createInfo(
-        Object ccCompilationContext, Object ccLinkingInfo, Location location, StarlarkThread thread)
-        throws EvalException;
+    CcInfoApi createInfo(Object ccCompilationContext, Object ccLinkingInfo) throws EvalException;
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcModuleApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcModuleApi.java
index abab54f..475d488 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcModuleApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcModuleApi.java
@@ -15,7 +15,6 @@
 package com.google.devtools.build.lib.skylarkbuildapi.cpp;
 
 import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.FileApi;
 import com.google.devtools.build.lib.skylarkbuildapi.SkylarkActionFactoryApi;
 import com.google.devtools.build.lib.skylarkbuildapi.SkylarkRuleContextApi;
@@ -507,7 +506,6 @@
   @SkylarkCallable(
       name = "create_library_to_link",
       doc = "Creates <code>LibraryToLink</code>",
-      useLocation = true,
       useStarlarkThread = true,
       parameters = {
         @Param(
@@ -598,14 +596,12 @@
       boolean alwayslink,
       String dynamicLibraryPath,
       String interfaceLibraryPath,
-      Location location,
       StarlarkThread thread)
       throws EvalException, InterruptedException;
 
   @SkylarkCallable(
       name = "create_linker_input",
       doc = "Creates a <code>LinkingContext</code>.",
-      useLocation = true,
       useStarlarkThread = true,
       enableOnlyWithFlag = FlagIdentifier.EXPERIMENTAL_CC_SHARED_LIBRARY,
       parameters = {
@@ -645,14 +641,12 @@
       Object librariesToLinkObject,
       Object userLinkFlagsObject,
       Object nonCodeInputs,
-      Location location,
       StarlarkThread thread)
       throws EvalException, InterruptedException;
 
   @SkylarkCallable(
       name = "create_linking_context",
       doc = "Creates a <code>LinkingContext</code>.",
-      useLocation = true,
       useStarlarkThread = true,
       parameters = {
         @Param(
@@ -693,7 +687,6 @@
       Object librariesToLinkObject,
       Object userLinkFlagsObject,
       Object nonCodeInputs, // <FileT> expected
-      Location location,
       StarlarkThread thread)
       throws EvalException, InterruptedException;
 
@@ -985,7 +978,6 @@
           "Should be used for creating library rules that can propagate information downstream in"
               + " order to be linked later by a top level rule that does transitive linking to"
               + " create an executable or dynamic library.",
-      useLocation = true,
       useStarlarkThread = true,
       parameters = {
         @Param(
@@ -1093,7 +1085,6 @@
       boolean disallowStaticLibraries,
       boolean disallowDynamicLibraries,
       Object grepIncludes,
-      Location location,
       StarlarkThread thread)
       throws InterruptedException, EvalException;
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/java/JavaCommonApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/java/JavaCommonApi.java
index b4189e9..0e95078 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/java/JavaCommonApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/java/JavaCommonApi.java
@@ -16,7 +16,6 @@
 
 import com.google.common.collect.ImmutableList;
 import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.FileApi;
 import com.google.devtools.build.lib.skylarkbuildapi.SkylarkActionFactoryApi;
 import com.google.devtools.build.lib.skylarkbuildapi.SkylarkRuleContextApi;
@@ -214,7 +213,6 @@
             type = Boolean.class,
             defaultValue = "False")
       },
-      useLocation = true,
       useStarlarkThread = true)
   JavaInfoT createJavaCompileAction(
       SkylarkRuleContextT skylarkRuleContext,
@@ -236,7 +234,6 @@
       Sequence<?> sourcepathEntries, // <FileT> expected.
       Sequence<?> resources, // <FileT> expected.
       Boolean neverlink,
-      Location loc,
       StarlarkThread thread)
       throws EvalException, InterruptedException;
 
@@ -278,14 +275,9 @@
             type = Object.class,
             allowedTypes = {@ParamType(type = JavaToolchainSkylarkApiProviderApi.class)},
             doc = "A JavaToolchainInfo to used to find the ijar tool."),
-      },
-      useLocation = true)
+      })
   FileApi runIjar(
-      SkylarkActionFactoryT actions,
-      FileT jar,
-      Object targetLabel,
-      JavaToolchainT javaToolchain,
-      Location location)
+      SkylarkActionFactoryT actions, FileT jar, Object targetLabel, JavaToolchainT javaToolchain)
       throws EvalException;
 
   @SkylarkCallable(
@@ -326,14 +318,9 @@
             type = Object.class,
             allowedTypes = {@ParamType(type = JavaToolchainSkylarkApiProviderApi.class)},
             doc = "A JavaToolchainInfo to used to find the stamp_jar tool."),
-      },
-      useLocation = true)
+      })
   FileApi stampJar(
-      SkylarkActionFactoryT actions,
-      FileT jar,
-      Label targetLabel,
-      JavaToolchainT javaToolchain,
-      Location location)
+      SkylarkActionFactoryT actions, FileT jar, Label targetLabel, JavaToolchainT javaToolchain)
       throws EvalException;
 
   @SkylarkCallable(
@@ -386,16 +373,14 @@
             allowedTypes = {@ParamType(type = JavaRuntimeInfoApi.class)},
             doc = "A JavaRuntimeInfo to be used for packing sources."),
       },
-      allowReturnNones = true,
-      useLocation = true)
+      allowReturnNones = true)
   FileApi packSources(
       SkylarkActionFactoryT actions,
       FileT outputJar,
       Sequence<?> sourceFiles, // <FileT> expected.
       Sequence<?> sourceJars, // <FileT> expected.
       JavaToolchainT javaToolchain,
-      JavaRuntimeT hostJavabase,
-      Location location)
+      JavaRuntimeT hostJavabase)
       throws EvalException;
 
   @SkylarkCallable(
@@ -412,12 +397,10 @@
             doc =
                 "A JavaToolchainInfo to be used for retrieving the ijar "
                     + "tool. Only set when use_ijar is True."),
-      },
-      useLocation = true)
+      })
   // TODO(b/78512644): migrate callers to passing explicit javacopts or using custom toolchains, and
   // delete
-  ImmutableList<String> getDefaultJavacOpts(JavaToolchainT javaToolchain, Location loc)
-      throws EvalException;
+  ImmutableList<String> getDefaultJavacOpts(JavaToolchainT javaToolchain) throws EvalException;
 
   @SkylarkCallable(
       name = "merge",
@@ -576,8 +559,6 @@
             type = JavaToolchainSkylarkApiProviderApi.class,
             doc = "The toolchain."),
       },
-      useLocation = true,
       enableOnlyWithFlag = FlagIdentifier.EXPERIMENTAL_GOOGLE_LEGACY_API)
-  Label getJavaToolchainLabel(JavaToolchainSkylarkApiProviderApi toolchain, Location location)
-      throws EvalException;
+  Label getJavaToolchainLabel(JavaToolchainSkylarkApiProviderApi toolchain) throws EvalException;
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/java/JavaInfoApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/java/JavaInfoApi.java
index 271cb71..069dec6 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/java/JavaInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/java/JavaInfoApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi.java;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.FileApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.StructApi;
@@ -236,7 +235,6 @@
                       + " tools can use this information for more efficient processing."),
         },
         selfCall = true,
-        useLocation = true,
         useStarlarkThread = true)
     @SkylarkConstructor(objectType = JavaInfoApi.class, receiverNameForDoc = "JavaInfo")
     JavaInfoApi<?> javaInfo(
@@ -248,7 +246,6 @@
         Sequence<?> runtimeDeps,
         Sequence<?> exports,
         Object jdepsApi,
-        Location loc,
         StarlarkThread thread)
         throws EvalException;
   }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformInfoApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformInfoApi.java
index 08a4944..c188bf8 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformInfoApi.java
@@ -15,7 +15,6 @@
 package com.google.devtools.build.lib.skylarkbuildapi.platform;
 
 import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.StructApi;
 import com.google.devtools.build.lib.skylarkinterface.Param;
@@ -27,6 +26,7 @@
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.Sequence;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics.FlagIdentifier;
+import com.google.devtools.build.lib.syntax.StarlarkThread;
 import java.util.Map;
 
 /** Info object representing data about a specific platform. */
@@ -120,7 +120,7 @@
               doc = "The exec properties for the platform.")
         },
         selfCall = true,
-        useLocation = true,
+        useStarlarkThread = true,
         enableOnlyWithFlag = FlagIdentifier.EXPERIMENTAL_PLATFORM_API)
     @SkylarkConstructor(objectType = PlatformInfoApi.class, receiverNameForDoc = "PlatformInfo")
     PlatformInfoT platformInfo(
@@ -128,7 +128,7 @@
         Object parent,
         Sequence<?> constraintValues,
         Object execProperties,
-        Location location)
+        StarlarkThread thread)
         throws EvalException;
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/ToolchainInfoApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/ToolchainInfoApi.java
index b953eb5..b8e5be3 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/ToolchainInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/ToolchainInfoApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi.platform;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.StructApi;
 import com.google.devtools.build.lib.skylarkinterface.Param;
@@ -23,6 +22,7 @@
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
 import com.google.devtools.build.lib.syntax.Dict;
 import com.google.devtools.build.lib.syntax.EvalException;
+import com.google.devtools.build.lib.syntax.StarlarkThread;
 
 /** Info object representing data about a specific toolchain. */
 @SkylarkModule(
@@ -44,7 +44,8 @@
         documented = false,
         extraKeywords = @Param(name = "kwargs", doc = "Dictionary of additional entries."),
         selfCall = true,
-        useLocation = true)
-    ToolchainInfoApi toolchainInfo(Dict<String, Object> kwargs, Location loc) throws EvalException;
+        useStarlarkThread = true)
+    ToolchainInfoApi toolchainInfo(Dict<String, Object> kwargs, StarlarkThread thread)
+        throws EvalException;
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/python/PyInfoApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/python/PyInfoApi.java
index 11b051f..d5a9c55 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/python/PyInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/python/PyInfoApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi.python;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.FileApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
 import com.google.devtools.build.lib.skylarkinterface.Param;
@@ -24,6 +23,7 @@
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
 import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.EvalException;
+import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.syntax.StarlarkValue;
 
 /** Provider instance for the Python rules. */
@@ -122,7 +122,7 @@
               doc = "The value for the new object's <code>has_py3_only_sources</code> field.")
         },
         selfCall = true,
-        useLocation = true)
+        useStarlarkThread = true)
     @SkylarkConstructor(objectType = PyInfoApi.class, receiverNameForDoc = "PyInfo")
     PyInfoApi<?> constructor(
         Depset transitiveSources,
@@ -130,7 +130,7 @@
         Object importsUncast,
         boolean hasPy2OnlySources,
         boolean hasPy3OnlySources,
-        Location loc)
+        StarlarkThread thread)
         throws EvalException;
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/python/PyRuntimeInfoApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/python/PyRuntimeInfoApi.java
index 6235a2a..f053951 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/python/PyRuntimeInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/python/PyRuntimeInfoApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi.python;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.FileApi;
 import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
 import com.google.devtools.build.lib.skylarkinterface.Param;
@@ -24,6 +23,7 @@
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
 import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.EvalException;
+import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.syntax.StarlarkValue;
 import javax.annotation.Nullable;
 
@@ -134,15 +134,15 @@
               named = true,
               doc = "The value for the new object's <code>python_version</code> field."),
         },
-        selfCall = true,
-        useLocation = true)
+        useStarlarkThread = true,
+        selfCall = true)
     @SkylarkConstructor(objectType = PyRuntimeInfoApi.class, receiverNameForDoc = "PyRuntimeInfo")
     PyRuntimeInfoApi<?> constructor(
         Object interpreterPathUncast,
         Object interpreterUncast,
         Object filesUncast,
         String pythonVersion,
-        Location loc)
+        StarlarkThread thread)
         throws EvalException;
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/RepositoryModuleApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/RepositoryModuleApi.java
index e9119e7..a5203f5 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/RepositoryModuleApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/RepositoryModuleApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi.repository;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkinterface.Param;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkGlobalLibrary;
@@ -108,7 +107,6 @@
             named = true,
             positional = false)
       },
-      useLocation = true,
       useStarlarkThread = true)
   BaseFunction repositoryRule(
       StarlarkFunction implementation,
@@ -118,7 +116,6 @@
       Boolean configure,
       Boolean remotable,
       String doc,
-      Location loc,
       StarlarkThread thread)
       throws EvalException;
 
@@ -128,8 +125,6 @@
           "When --incompatible_use_cc_configure_from_rules_cc is set to true, Bazel will "
               + "fail the build. Please see https://github.com/bazelbuild/bazel/issues/10134 for "
               + "details and migration instructions.",
-      useLocation = true,
       useStarlarkThread = true)
-  void failWithIncompatibleUseCcConfigureFromRulesCc(Location location, StarlarkThread thread)
-      throws EvalException;
+  void failWithIncompatibleUseCcConfigureFromRulesCc(StarlarkThread thread) throws EvalException;
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java
index 510d377..57fcdfc 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java
@@ -15,7 +15,6 @@
 package com.google.devtools.build.lib.skylarkbuildapi.repository;
 
 import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.core.StructApi;
 import com.google.devtools.build.lib.skylarkinterface.Param;
 import com.google.devtools.build.lib.skylarkinterface.ParamType;
@@ -25,6 +24,7 @@
 import com.google.devtools.build.lib.syntax.Dict;
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.Sequence;
+import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.syntax.StarlarkValue;
 
 /** Skylark API for the repository_rule's context. */
@@ -88,7 +88,7 @@
   @SkylarkCallable(
       name = "symlink",
       doc = "Creates a symlink on the filesystem.",
-      useLocation = true,
+      useStarlarkThread = true,
       parameters = {
         @Param(
             name = "from",
@@ -107,13 +107,13 @@
             },
             doc = "path of the symlink to create, relative to the repository directory."),
       })
-  void symlink(Object from, Object to, Location location)
+  void symlink(Object from, Object to, StarlarkThread thread)
       throws RepositoryFunctionExceptionT, EvalException, InterruptedException;
 
   @SkylarkCallable(
       name = "file",
       doc = "Generates a file in the repository directory with the provided content.",
-      useLocation = true,
+      useStarlarkThread = true,
       parameters = {
         @Param(
             name = "path",
@@ -145,7 +145,7 @@
                     + " the default and remove this parameter."),
       })
   void createFile(
-      Object path, String content, Boolean executable, Boolean legacyUtf8, Location location)
+      Object path, String content, Boolean executable, Boolean legacyUtf8, StarlarkThread thread)
       throws RepositoryFunctionExceptionT, EvalException, InterruptedException;
 
   @SkylarkCallable(
@@ -156,7 +156,7 @@
               + "the corresponding value. The result is written in <code>path</code>. An optional"
               + "<code>executable</code> argument (default to true) can be set to turn on or off"
               + "the executable bit.",
-      useLocation = true,
+      useStarlarkThread = true,
       parameters = {
         @Param(
             name = "path",
@@ -192,13 +192,13 @@
       Object template,
       Dict<?, ?> substitutions, // <String, String> expected
       Boolean executable,
-      Location location)
+      StarlarkThread thread)
       throws RepositoryFunctionExceptionT, EvalException, InterruptedException;
 
   @SkylarkCallable(
       name = "read",
       doc = "Reads the content of a file on the filesystem.",
-      useLocation = true,
+      useStarlarkThread = true,
       parameters = {
         @Param(
             name = "path",
@@ -209,7 +209,7 @@
             },
             doc = "path of the file to read from."),
       })
-  String readFile(Object path, Location location)
+  String readFile(Object path, StarlarkThread thread)
       throws RepositoryFunctionExceptionT, EvalException, InterruptedException;
 
   @SkylarkCallable(
@@ -226,7 +226,7 @@
               + " returns an <code>exec_result</code> structure containing the output of the"
               + " command. The <code>environment</code> map can be used to override some"
               + " environment variables to be passed to the process.",
-      useLocation = true,
+      useStarlarkThread = true,
       parameters = {
         @Param(
             name = "arguments",
@@ -267,7 +267,7 @@
       Dict<?, ?> environment, // <String, String> expected
       boolean quiet,
       String workingDirectory,
-      Location location)
+      StarlarkThread thread)
       throws EvalException, RepositoryFunctionExceptionT, InterruptedException;
 
   @SkylarkCallable(
@@ -275,7 +275,7 @@
       doc =
           "Deletes a file or a directory. Returns a bool, indicating whether the file or directory"
               + " was actually deleted by this call.",
-      useLocation = true,
+      useStarlarkThread = true,
       parameters = {
         @Param(
             name = "path",
@@ -287,7 +287,7 @@
                 "Path of the file to delete, relative to the repository directory, or absolute."
                     + " Can be a path or a string."),
       })
-  boolean delete(Object path, Location location)
+  boolean delete(Object path, StarlarkThread thread)
       throws EvalException, RepositoryFunctionExceptionT, InterruptedException;
 
   @SkylarkCallable(
@@ -299,7 +299,7 @@
               + "unified diff format</a> file. "
               + "The Bazel-native patch implementation doesn't support fuzz match and binary patch "
               + "like the patch command line tool.",
-      useLocation = true,
+      useStarlarkThread = true,
       parameters = {
         @Param(
             name = "patch_file",
@@ -318,7 +318,7 @@
             defaultValue = "0",
             doc = "strip the specified number of leading components from file names."),
       })
-  void patch(Object patchFile, Integer strip, Location location)
+  void patch(Object patchFile, Integer strip, StarlarkThread thread)
       throws EvalException, RepositoryFunctionExceptionT, InterruptedException;
 
   @SkylarkCallable(
@@ -327,7 +327,7 @@
           "Returns the path of the corresponding program or None "
               + "if there is no such program in the path.",
       allowReturnNones = true,
-      useLocation = true,
+      useStarlarkThread = true,
       parameters = {
         @Param(
             name = "program",
@@ -335,7 +335,7 @@
             named = false,
             doc = "Program to find in the path."),
       })
-  RepositoryPathApi<?> which(String program, Location location) throws EvalException;
+  RepositoryPathApi<?> which(String program, StarlarkThread thread) throws EvalException;
 
   @SkylarkCallable(
       name = "download",
@@ -343,7 +343,7 @@
           "Downloads a file to the output path for the provided url and returns a struct"
               + " containing a hash of the file with the fields <code>sha256</code> and"
               + " <code>integrity</code>.",
-      useLocation = true,
+      useStarlarkThread = true,
       parameters = {
         @Param(
             name = "url",
@@ -424,13 +424,13 @@
       String canonicalId,
       Dict<?, ?> auth, // <String, Dict<?, ?>> expected
       String integrity,
-      Location location)
+      StarlarkThread thread)
       throws RepositoryFunctionExceptionT, EvalException, InterruptedException;
 
   @SkylarkCallable(
       name = "extract",
       doc = "Extract an archive to the repository directory.",
-      useLocation = true,
+      useStarlarkThread = true,
       parameters = {
         @Param(
             name = "archive",
@@ -467,7 +467,7 @@
                     + " <code>build_file</code>, this field can be used to strip it from extracted"
                     + " files."),
       })
-  void extract(Object archive, Object output, String stripPrefix, Location location)
+  void extract(Object archive, Object output, String stripPrefix, StarlarkThread thread)
       throws RepositoryFunctionExceptionT, InterruptedException, EvalException;
 
   @SkylarkCallable(
@@ -476,7 +476,7 @@
           "Downloads a file to the output path for the provided url, extracts it, and returns"
               + " a struct containing a hash of the downloaded file with the fields"
               + " <code>sha256</code> and <code>integrity</code>.",
-      useLocation = true,
+      useStarlarkThread = true,
       parameters = {
         @Param(
             name = "url",
@@ -580,6 +580,6 @@
       String canonicalId,
       Dict<?, ?> auth, // <String, Dict<?, ?>> expected
       String integrity,
-      Location location)
+      StarlarkThread thread)
       throws RepositoryFunctionExceptionT, InterruptedException, EvalException;
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/test/CoverageCommonApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/test/CoverageCommonApi.java
index bd605d6..d595eb8 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/test/CoverageCommonApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/test/CoverageCommonApi.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.skylarkbuildapi.test;
 
-import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.skylarkbuildapi.SkylarkRuleContextApi;
 import com.google.devtools.build.lib.skylarkbuildapi.platform.ConstraintValueInfoApi;
 import com.google.devtools.build.lib.skylarkinterface.Param;
@@ -75,13 +74,11 @@
             noneable = true,
             defaultValue = "None",
             type = Sequence.class),
-      },
-      useLocation = true)
+      })
   InstrumentedFilesInfoApi instrumentedFilesInfo(
       RuleContextT skylarkRuleContext,
       Sequence<?> sourceAttributes, // <String> expected
       Sequence<?> dependencyAttributes, // <String> expected
-      Object extensions,
-      Location location)
+      Object extensions)
       throws EvalException;
 }