SkylarkRepositoryContext: show rule location in case of wrong checksum

This location associated with the function call is the very position
of the call of the download method, i.e., it is a position somewhere
within implementation function of a repository rule. As such it does
not provide more information than the type of rule that was used.
Therefore, replace it by the location wher the rule was defined,
as this is more likely to be the position where the wrong hash came
from.

Closes #7353.

Change-Id: Ie3a2609377d926a619cc56bffc14aec26585d983
PiperOrigin-RevId: 234483022
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java
index 7ff9f27..2457712 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java
@@ -361,7 +361,7 @@
     return null;
   }
 
-  private void warnAboutSha256Error(List<URL> urls, String sha256, Location location) {
+  private void warnAboutSha256Error(List<URL> urls, String sha256) {
     // Inform the user immediately, even though the file will still be downloaded.
     // This cannot be done by a regular error event, as all regular events are recorded
     // and only shown once the execution of the repository rule is finished.
@@ -370,13 +370,7 @@
     if (urls.size() > 0) {
       url = urls.get(0).toString();
     }
-    reportProgress(
-        "Will fail after download of "
-            + url
-            + ". Invalid SHA256 '"
-            + sha256
-            + "' specified at "
-            + location);
+    reportProgress("Will fail after download of " + url + ". Invalid SHA256 '" + sha256 + "'");
   }
 
   @Override
@@ -386,7 +380,7 @@
     List<URL> urls = getUrls(url);
     RepositoryFunctionException sha256Validation = validateSha256(sha256, location);
     if (sha256Validation != null) {
-      warnAboutSha256Error(urls, sha256, location);
+      warnAboutSha256Error(urls, sha256);
       sha256 = "";
     }
     SkylarkPath outputPath = getPath("download()", output);
@@ -463,7 +457,7 @@
     List<URL> urls = getUrls(url);
     RepositoryFunctionException sha256Validation = validateSha256(sha256, location);
     if (sha256Validation != null) {
-      warnAboutSha256Error(urls, sha256, location);
+      warnAboutSha256Error(urls, sha256);
       sha256 = "";
     }
 
@@ -552,7 +546,8 @@
                   + rule.getName()
                   + ": Syntactically invalid SHA256 checksum: '"
                   + sha256
-                  + "'"),
+                  + "' at "
+                  + rule.getLocation()),
           Transience.PERSISTENT);
     }
     return null;