[visibility] Add the toolchain to the labels in the visibility error message

When printing the error message for visibility restrictions,
print the label with the toolchain to clarify how the
visiblity restriction is being encountered.

Change-Id: I5c52054415541261c2abcb5c95596b1604d49327
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/14640
Reviewed-by: Brett Wilson <brettw@chromium.org>
Commit-Queue: Aaron Wood <aaronwood@google.com>
diff --git a/docs/reference.md b/docs/reference.md
index 8dd8ba8..11e217f 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -6718,8 +6718,11 @@
     visibility = [ ":mything", "//foo:something_else" ]
 
   Any target in the current directory and any subdirectory thereof, plus
-  any targets in "//bar/" and any subdirectory thereof.
+  any targets in "//bar/" and any subdirectory thereof:
     visibility = [ "./*", "//bar/*" ]
+
+  All targets in the current buildfile that are in the same toolchain:
+    visibility = [ ":*($current_toolchain)" ]
 ```
 ### <a name="var_walk_keys"></a>**walk_keys**: Key(s) for managing the metadata collection walk.
 
diff --git a/src/gn/visibility.cc b/src/gn/visibility.cc
index 0878990..acbb500 100644
--- a/src/gn/visibility.cc
+++ b/src/gn/visibility.cc
@@ -92,16 +92,15 @@
                                      const Item* to,
                                      Err* err) {
   if (!to->visibility().CanSeeMe(from->label())) {
-    std::string to_label = to->label().GetUserVisibleName(false);
+    bool with_toolchain =
+        !from->settings()->is_default() || !to->settings()->is_default();
+    std::string to_label = to->label().GetUserVisibleName(with_toolchain);
+    std::string from_label = from->label().GetUserVisibleName(with_toolchain);
     *err = Err(from->defined_from(), "Dependency not allowed.",
-               "The item " + from->label().GetUserVisibleName(false) +
-                   "\n"
-                   "can not depend on " +
-                   to_label +
-                   "\n"
-                   "because it is not in " +
-                   to_label +
-                   "'s visibility list: " + to->visibility().Describe(0, true));
+               "The item " + from_label + "\n"
+                   "can not depend on " + to_label + "\n"
+                   "because it is not in " + to_label + "'s visibility list: " +
+                   to->visibility().Describe(0, true));
     return false;
   }
   return true;