Updated platform triple values from strings to structs ("triple") (#1804)

diff --git a/rust/platform/triple_mappings.bzl b/rust/platform/triple_mappings.bzl
index 003013c..6a17d8b 100644
--- a/rust/platform/triple_mappings.bzl
+++ b/rust/platform/triple_mappings.bzl
@@ -264,7 +264,9 @@
     Returns:
         str: A system name
     """
-    return triple(target_triple).system
+    if type(target_triple) == "string":
+        target_triple = triple(target_triple)
+    return target_triple.system
 
 def triple_to_arch(target_triple):
     """Returns a system architecture name for a given platform triple
@@ -277,7 +279,9 @@
     Returns:
         str: A cpu architecture
     """
-    return triple(target_triple).arch
+    if type(target_triple) == "string":
+        target_triple = triple(target_triple)
+    return target_triple.arch
 
 def triple_to_abi(target_triple):
     """Returns a system abi name for a given platform triple
@@ -290,7 +294,9 @@
     Returns:
         str: The triple's abi
     """
-    return triple(target_triple).system
+    if type(target_triple) == "string":
+        target_triple = triple(target_triple)
+    return target_triple.system
 
 def system_to_dylib_ext(system):
     return _SYSTEM_TO_DYLIB_EXT[system]
diff --git a/rust/private/repository_utils.bzl b/rust/private/repository_utils.bzl
index 63ef1f8..d497c92 100644
--- a/rust/private/repository_utils.bzl
+++ b/rust/private/repository_utils.bzl
@@ -7,7 +7,6 @@
     "system_to_dylib_ext",
     "system_to_staticlib_ext",
     "system_to_stdlib_linkflags",
-    "triple_to_system",
 )
 
 DEFAULT_TOOLCHAIN_NAME_PREFIX = "toolchain_for"
@@ -51,12 +50,11 @@
     Returns:
         str: The contents of a BUILD file
     """
-    system = triple_to_system(target_triple)
     return _build_file_for_compiler_template.format(
-        binary_ext = system_to_binary_ext(system),
-        staticlib_ext = system_to_staticlib_ext(system),
-        dylib_ext = system_to_dylib_ext(system),
-        target_triple = target_triple,
+        binary_ext = system_to_binary_ext(target_triple.system),
+        staticlib_ext = system_to_staticlib_ext(target_triple.system),
+        dylib_ext = system_to_dylib_ext(target_triple.system),
+        target_triple = target_triple.str,
     )
 
 _build_file_for_cargo_template = """\
@@ -75,9 +73,8 @@
     Returns:
         str: The contents of a BUILD file
     """
-    system = triple_to_system(target_triple)
     return _build_file_for_cargo_template.format(
-        binary_ext = system_to_binary_ext(system),
+        binary_ext = system_to_binary_ext(target_triple.system),
     )
 
 _build_file_for_rustfmt_template = """\
@@ -103,9 +100,8 @@
     Returns:
         str: The contents of a BUILD file
     """
-    system = triple_to_system(target_triple)
     return _build_file_for_rustfmt_template.format(
-        binary_ext = system_to_binary_ext(system),
+        binary_ext = system_to_binary_ext(target_triple.system),
     )
 
 _build_file_for_clippy_template = """\
@@ -132,9 +128,8 @@
     Returns:
         str: The contents of a BUILD file
     """
-    system = triple_to_system(exec_triple)
     return _build_file_for_rust_analyzer_proc_macro_srv.format(
-        binary_ext = system_to_binary_ext(system),
+        binary_ext = system_to_binary_ext(exec_triple.system),
     )
 
 def BUILD_for_clippy(target_triple):
@@ -146,8 +141,9 @@
     Returns:
         str: The contents of a BUILD file
     """
-    system = triple_to_system(target_triple)
-    return _build_file_for_clippy_template.format(binary_ext = system_to_binary_ext(system))
+    return _build_file_for_clippy_template.format(
+        binary_ext = system_to_binary_ext(target_triple.system),
+    )
 
 _build_file_for_llvm_tools = """\
 filegroup(
@@ -167,15 +163,14 @@
     """Emits a BUILD file the llvm-tools binaries.
 
     Args:
-        target_triple (str): The triple of the target platform
+        target_triple (struct): The triple of the target platform
 
     Returns:
         str: The contents of a BUILD file
     """
-    system = triple_to_system(target_triple)
     return _build_file_for_llvm_tools.format(
-        binary_ext = system_to_binary_ext(system),
-        target_triple = target_triple,
+        binary_ext = system_to_binary_ext(target_triple.system),
+        target_triple = target_triple.str,
     )
 
 _build_file_for_stdlib_template = """\
@@ -208,17 +203,16 @@
     """Emits a BUILD file the stdlib archive.
 
     Args:
-        target_triple (str): The triple of the target platform
+        target_triple (triple): The triple of the target platform
 
     Returns:
         str: The contents of a BUILD file
     """
-    system = triple_to_system(target_triple)
     return _build_file_for_stdlib_template.format(
-        binary_ext = system_to_binary_ext(system),
-        staticlib_ext = system_to_staticlib_ext(system),
-        dylib_ext = system_to_dylib_ext(system),
-        target_triple = target_triple,
+        binary_ext = system_to_binary_ext(target_triple.system),
+        staticlib_ext = system_to_staticlib_ext(target_triple.system),
+        dylib_ext = system_to_dylib_ext(target_triple.system),
+        target_triple = target_triple.str,
     )
 
 _build_file_for_rust_toolchain_template = """\
@@ -265,8 +259,8 @@
     Args:
         workspace_name (str): The name of the workspace that this toolchain resides in
         name (str): The name of the toolchain declaration
-        exec_triple (str): The rust-style target that this compiler runs on
-        target_triple (str): The rust-style target triple of the tool
+        exec_triple (triple): The rust-style target that this compiler runs on
+        target_triple (triple): The rust-style target triple of the tool
         include_rustc_srcs (bool, optional): Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False.
         allocator_library (str, optional): Target that provides allocator functions when rust_library targets are embedded in a cc_binary.
         default_edition (str): Default Rust edition.
@@ -280,9 +274,8 @@
     Returns:
         str: A rendered template of a `rust_toolchain` declaration
     """
-    system = triple_to_system(target_triple)
     if stdlib_linkflags == None:
-        stdlib_linkflags = ", ".join(['"%s"' % x for x in system_to_stdlib_linkflags(system)])
+        stdlib_linkflags = ", ".join(['"%s"' % x for x in system_to_stdlib_linkflags(target_triple.system)])
 
     rustc_srcs = "None"
     if include_rustc_srcs:
@@ -302,16 +295,16 @@
     return _build_file_for_rust_toolchain_template.format(
         toolchain_name = name,
         workspace_name = workspace_name,
-        binary_ext = system_to_binary_ext(system),
-        staticlib_ext = system_to_staticlib_ext(system),
-        dylib_ext = system_to_dylib_ext(system),
+        binary_ext = system_to_binary_ext(target_triple.system),
+        staticlib_ext = system_to_staticlib_ext(target_triple.system),
+        dylib_ext = system_to_dylib_ext(target_triple.system),
         rustc_srcs = rustc_srcs,
         allocator_library = allocator_library_label,
         stdlib_linkflags = stdlib_linkflags,
-        system = system,
+        system = target_triple.system,
         default_edition = default_edition,
-        exec_triple = exec_triple,
-        target_triple = target_triple,
+        exec_triple = exec_triple.str,
+        target_triple = target_triple.str,
         rustfmt_label = rustfmt_label,
         llvm_cov_label = llvm_cov_label,
         llvm_profdata_label = llvm_profdata_label,
@@ -351,7 +344,7 @@
 
     Args:
         ctx (repository_ctx): The repository rule's context object.
-        target_triple (str): The platform triple to download rustfmt for.
+        target_triple (struct): The platform triple to download rustfmt for.
         version (str): The version or channel of rustfmt.
         iso_date (str): The date of the tool (or None, if the version is a specific version).
 
@@ -376,7 +369,7 @@
     Args:
         ctx (repository_ctx): A repository_ctx.
         iso_date (str): The date of the tool (or None, if the version is a specific version).
-        target_triple (str): The Rust-style target that this compiler runs on.
+        target_triple (struct): The Rust-style target that this compiler runs on.
         version (str): The version of the tool among \"nightly\", \"beta\", or an exact version.
 
     Returns:
@@ -394,46 +387,49 @@
 
     return BUILD_for_compiler(target_triple)
 
-def load_clippy(ctx):
+def load_clippy(ctx, iso_date, target_triple, version):
     """Loads Clippy and yields corresponding BUILD for it
 
     Args:
         ctx (repository_ctx): A repository_ctx.
+        iso_date (str): The date of the tool (or None, if the version is a specific version).
+        target_triple (struct): The Rust-style target that this compiler runs on.
+        version (str): The version of the tool among \"nightly\", \"beta\", or an exact version.
 
     Returns:
         str: The BUILD file contents for Clippy
     """
-
-    target_triple = ctx.attr.exec_triple
     load_arbitrary_tool(
         ctx,
-        iso_date = ctx.attr.iso_date,
+        iso_date = iso_date,
         target_triple = target_triple,
         tool_name = "clippy",
         tool_subdirectories = ["clippy-preview"],
-        version = ctx.attr.version,
+        version = version,
     )
 
     return BUILD_for_clippy(target_triple)
 
-def load_cargo(ctx):
+def load_cargo(ctx, iso_date, target_triple, version):
     """Loads Cargo and yields corresponding BUILD for it
 
     Args:
         ctx (repository_ctx): A repository_ctx.
+        iso_date (str): The date of the tool (or None, if the version is a specific version).
+        target_triple (struct): The Rust-style target that this compiler runs on.
+        version (str): The version of the tool among \"nightly\", \"beta\", or an exact version.
 
     Returns:
         str: The BUILD file contents for Cargo
     """
 
-    target_triple = ctx.attr.exec_triple
     load_arbitrary_tool(
         ctx,
-        iso_date = ctx.attr.iso_date,
+        iso_date = iso_date,
         target_triple = target_triple,
         tool_name = "cargo",
         tool_subdirectories = ["cargo"],
-        version = ctx.attr.version,
+        version = version,
     )
 
     return BUILD_for_cargo(target_triple)
@@ -475,18 +471,20 @@
 
     return getattr(repository_ctx.attr, "include_rustc_srcs", False)
 
-def load_rust_src(ctx, sha256 = ""):
+def load_rust_src(ctx, iso_date, version, sha256 = ""):
     """Loads the rust source code. Used by the rust-analyzer rust-project.json generator.
 
     Args:
         ctx (ctx): A repository_ctx.
+        version (str): The version of the tool among "nightly", "beta', or an exact version.
+        iso_date (str): The date of the tool (or None, if the version is a specific version).
         sha256 (str): The sha256 value for the `rust-src` artifact
     """
-    tool_suburl = produce_tool_suburl("rust-src", None, ctx.attr.version, ctx.attr.iso_date)
+    tool_suburl = produce_tool_suburl("rust-src", None, version, iso_date)
     url = ctx.attr.urls[0].format(tool_suburl)
 
-    tool_path = produce_tool_path("rust-src", None, ctx.attr.version)
-    archive_path = tool_path + _get_tool_extension(ctx)
+    tool_path = produce_tool_path("rust-src", version, None)
+    archive_path = tool_path + _get_tool_extension(getattr(ctx.attr, "urls", None))
     sha256 = sha256 or getattr(ctx.attr, "sha256s", {}).get(archive_path) or FILE_KEY_TO_SHA.get(archive_path) or ""
     ctx.download_and_extract(
         url,
@@ -549,7 +547,7 @@
 
     Args:
         ctx (repository_ctx): A repository_ctx.
-        target_triple (str): The rust-style target triple of the tool
+        target_triple (struct): The rust-style target triple of the tool
 
     Returns:
         str: The BUILD file contents for this stdlib
@@ -560,7 +558,7 @@
         iso_date = ctx.attr.iso_date,
         target_triple = target_triple,
         tool_name = "rust-std",
-        tool_subdirectories = ["rust-std-{}".format(target_triple)],
+        tool_subdirectories = ["rust-std-{}".format(target_triple.str)],
         version = ctx.attr.version,
     )
 
@@ -624,24 +622,24 @@
     """Produces a fully qualified Rust tool name for URL
 
     Args:
-        tool_name: The name of the tool per static.rust-lang.org
-        target_triple: The rust-style target triple of the tool
-        version: The version of the tool among "nightly", "beta', or an exact version.
-        iso_date: The date of the tool (or None, if the version is a specific version).
+        tool_name (str): The name of the tool per `static.rust-lang.org`.
+        target_triple (struct): The rust-style target triple of the tool.
+        version (str): The version of the tool among "nightly", "beta', or an exact version.
+        iso_date (str): The date of the tool (or None, if the version is a specific version).
 
     Returns:
         str: The fully qualified url path for the specified tool.
     """
-    path = produce_tool_path(tool_name, target_triple, version)
+    path = produce_tool_path(tool_name, version, target_triple)
     return iso_date + "/" + path if (iso_date and version in ("beta", "nightly")) else path
 
-def produce_tool_path(tool_name, target_triple, version):
+def produce_tool_path(tool_name, version, target_triple = None):
     """Produces a qualified Rust tool name
 
     Args:
-        tool_name: The name of the tool per static.rust-lang.org
-        target_triple: The rust-style target triple of the tool
-        version: The version of the tool among "nightly", "beta', or an exact version.
+        tool_name (str): The name of the tool per static.rust-lang.org
+        version (str): The version of the tool among "nightly", "beta', or an exact version.
+        target_triple (struct, optional): The rust-style target triple of the tool
 
     Returns:
         str: The qualified path for the specified tool.
@@ -650,7 +648,13 @@
         fail("No tool name was provided")
     if not version:
         fail("No tool version was provided")
-    return "-".join([e for e in [tool_name, version, target_triple] if e])
+
+    # Not all tools require a triple. E.g. `rustc_src` (Rust source files for rust-analyzer).
+    platform_triple = None
+    if target_triple:
+        platform_triple = target_triple.str
+
+    return "-".join([e for e in [tool_name, version, platform_triple] if e])
 
 def lookup_tool_sha256(ctx, tool_name, target_triple, version, iso_date, sha256):
     """Looks up the sha256 hash of a specific tool archive.
@@ -664,7 +668,7 @@
     Args:
         ctx (repository_ctx): A repository_ctx (no attrs required).
         tool_name (str): The name of the given tool per the archive naming.
-        target_triple (str): The rust-style target triple of the tool
+        target_triple (struct): The rust-style target triple of the tool.
         version (str): The version of the tool among "nightly", "beta', or an exact version.
         iso_date (str): The date of the tool (ignored if the version is a specific version).
         sha256 (str): The expected hash of hash of the Rust tool.
@@ -673,7 +677,7 @@
         str: The sha256 of the tool archive, or an empty string if the hash could not be found.
     """
     tool_suburl = produce_tool_suburl(tool_name, target_triple, version, iso_date)
-    archive_path = tool_suburl + _get_tool_extension(ctx)
+    archive_path = tool_suburl + _get_tool_extension(getattr(ctx.attr, "urls", None))
     return getattr(ctx.attr, "sha256s", dict()).get(archive_path) or FILE_KEY_TO_SHA.get(archive_path) or sha256
 
 def load_arbitrary_tool(ctx, tool_name, tool_subdirectories, version, iso_date, target_triple, sha256 = ""):
@@ -701,7 +705,7 @@
             tool_subdirectories = ["clippy-preview", "rustc"]
         version (str): The version of the tool among "nightly", "beta', or an exact version.
         iso_date (str): The date of the tool (ignored if the version is a specific version).
-        target_triple (str): The rust-style target triple of the tool
+        target_triple (struct): The rust-style target triple of the tool.
         sha256 (str, optional): The expected hash of hash of the Rust tool. Defaults to "".
     """
     check_version_valid(version, iso_date, param_prefix = tool_name + "_")
@@ -716,7 +720,7 @@
         if new_url not in urls:
             urls.append(new_url)
 
-    tool_path = produce_tool_path(tool_name, target_triple, version)
+    tool_path = produce_tool_path(tool_name, version, target_triple)
 
     sha256 = lookup_tool_sha256(ctx, tool_name, target_triple, version, iso_date, sha256)
 
@@ -744,8 +748,9 @@
         ret[url] = auth
     return ret
 
-def _get_tool_extension(ctx):
-    urls = getattr(ctx.attr, "urls", DEFAULT_STATIC_RUST_URL_TEMPLATES)
+def _get_tool_extension(urls = None):
+    if urls == None:
+        urls = DEFAULT_STATIC_RUST_URL_TEMPLATES
     if urls[0][-7:] == ".tar.gz":
         return ".tar.gz"
     elif urls[0][-7:] == ".tar.xz":
diff --git a/rust/repositories.bzl b/rust/repositories.bzl
index c587840..6dbd530 100644
--- a/rust/repositories.bzl
+++ b/rust/repositories.bzl
@@ -2,11 +2,8 @@
 
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
 load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
-load("//rust/platform:triple.bzl", "get_host_triple")
-load(
-    "//rust/platform:triple_mappings.bzl",
-    "triple_to_constraint_set",
-)
+load("//rust/platform:triple.bzl", "get_host_triple", "triple")
+load("//rust/platform:triple_mappings.bzl", "triple_to_constraint_set")
 load("//rust/private:common.bzl", "DEFAULT_NIGHTLY_ISO_DATE", "rust_common")
 load(
     "//rust/private:repository_utils.bzl",
@@ -261,17 +258,33 @@
 
     # Conditionally download rustc sources. Generally used for `rust-analyzer`
     if should_include_rustc_srcs(ctx):
-        load_rust_src(ctx)
+        load_rust_src(
+            ctx = ctx,
+            iso_date = ctx.attr.iso_date,
+            version = ctx.attr.version,
+        )
+
+    exec_triple = triple(ctx.attr.exec_triple)
 
     build_components = [
         load_rust_compiler(
             ctx = ctx,
             iso_date = ctx.attr.iso_date,
-            target_triple = ctx.attr.exec_triple,
+            target_triple = exec_triple,
             version = ctx.attr.version,
         ),
-        load_clippy(ctx),
-        load_cargo(ctx),
+        load_clippy(
+            ctx = ctx,
+            iso_date = ctx.attr.iso_date,
+            target_triple = exec_triple,
+            version = ctx.attr.version,
+        ),
+        load_cargo(
+            ctx = ctx,
+            iso_date = ctx.attr.iso_date,
+            target_triple = exec_triple,
+            version = ctx.attr.version,
+        ),
     ]
 
     if ctx.attr.rustfmt_version:
@@ -288,7 +301,7 @@
             rustfmt_version, _, rustfmt_iso_date = rustfmt_version.partition("/")
         build_components.append(load_rustfmt(
             ctx = ctx,
-            target_triple = ctx.attr.exec_triple,
+            target_triple = triple(ctx.attr.exec_triple),
             version = rustfmt_version,
             iso_date = rustfmt_iso_date,
         ))
@@ -296,9 +309,16 @@
     # Rust 1.45.0 and nightly builds after 2020-05-22 need the llvm-tools gzip to get the libLLVM dylib
     include_llvm_tools = ctx.attr.version >= "1.45.0" or (ctx.attr.version == "nightly" and ctx.attr.iso_date > "2020-05-22")
     if include_llvm_tools:
-        build_components.append(load_llvm_tools(ctx, ctx.attr.exec_triple))
+        build_components.append(load_llvm_tools(
+            ctx = ctx,
+            target_triple = exec_triple,
+        ))
 
-    build_components.append(load_rust_stdlib(ctx, ctx.attr.target_triple))
+    target_triple = triple(ctx.attr.target_triple)
+    build_components.append(load_rust_stdlib(
+        ctx = ctx,
+        target_triple = target_triple,
+    ))
 
     stdlib_linkflags = None
     if "BAZEL_RUST_STDLIB_LINKFLAGS" in ctx.os.environ:
@@ -306,10 +326,10 @@
 
     build_components.append(BUILD_for_rust_toolchain(
         name = "rust_toolchain",
-        exec_triple = ctx.attr.exec_triple,
+        exec_triple = exec_triple,
         include_rustc_srcs = should_include_rustc_srcs(ctx),
         allocator_library = ctx.attr.allocator_library,
-        target_triple = ctx.attr.target_triple,
+        target_triple = target_triple,
         stdlib_linkflags = stdlib_linkflags,
         workspace_name = ctx.attr.name,
         default_edition = ctx.attr.edition,
@@ -532,7 +552,11 @@
     )
 
 def _rust_analyzer_toolchain_tools_repository_impl(repository_ctx):
-    load_rust_src(repository_ctx)
+    load_rust_src(
+        ctx = repository_ctx,
+        iso_date = repository_ctx.attr.iso_date,
+        version = repository_ctx.attr.version,
+    )
 
     repository_ctx.file("WORKSPACE.bazel", """workspace(name = "{}")""".format(
         repository_ctx.name,
@@ -543,7 +567,7 @@
         load_rust_compiler(
             ctx = repository_ctx,
             iso_date = repository_ctx.attr.iso_date,
-            target_triple = host_triple.str,
+            target_triple = host_triple,
             version = repository_ctx.attr.version,
         ),
     ]
@@ -551,7 +575,7 @@
 
     proc_macro_srv = None
     if includes_rust_analyzer_proc_macro_srv(repository_ctx.attr.version, repository_ctx.attr.iso_date):
-        build_contents.append(BUILD_for_rust_analyzer_proc_macro_srv(host_triple.str))
+        build_contents.append(BUILD_for_rust_analyzer_proc_macro_srv(host_triple))
         proc_macro_srv = "//:rust_analyzer_proc_macro_srv"
 
     build_contents.append(BUILD_for_rust_analyzer_toolchain(
@@ -648,17 +672,19 @@
     rustc = "//:rustc"
     rustc_lib = "//:rustc_lib"
 
+    exec_triple = triple(repository_ctx.attr.exec_triple)
+
     build_contents = [
         load_rust_compiler(
             ctx = repository_ctx,
             iso_date = repository_ctx.attr.iso_date,
-            target_triple = repository_ctx.attr.exec_triple,
+            target_triple = exec_triple,
             version = repository_ctx.attr.version,
         ),
         load_rustfmt(
             ctx = repository_ctx,
             iso_date = repository_ctx.attr.iso_date,
-            target_triple = repository_ctx.attr.exec_triple,
+            target_triple = exec_triple,
             version = repository_ctx.attr.version,
         ),
         BUILD_for_rustfmt_toolchain(
diff --git a/test/load_arbitrary_tool/load_arbitrary_tool_test.bzl b/test/load_arbitrary_tool/load_arbitrary_tool_test.bzl
index 495b6bb..deeba9c 100644
--- a/test/load_arbitrary_tool/load_arbitrary_tool_test.bzl
+++ b/test/load_arbitrary_tool/load_arbitrary_tool_test.bzl
@@ -14,7 +14,7 @@
         tool_subdirectories = ["cargo"],
         version = "1.53.0",
         iso_date = None,
-        target_triple = host_triple.str,
+        target_triple = host_triple,
     )
 
     repo_path = repository_ctx.path(".")
diff --git a/test/unit/repository_utils/repository_utils_test.bzl b/test/unit/repository_utils/repository_utils_test.bzl
index f4073db..10cafc2 100644
--- a/test/unit/repository_utils/repository_utils_test.bzl
+++ b/test/unit/repository_utils/repository_utils_test.bzl
@@ -1,6 +1,7 @@
 """Unit tests for repository_utils.bzl."""
 
 load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
+load("//rust/platform:triple.bzl", "triple")
 
 # buildifier: disable=bzl-visibility
 load(
@@ -11,6 +12,8 @@
     "select_rust_version",
 )
 
+_PLATFORM_TRIPLE = triple("x86_64-unknown-linux-gnu")
+
 def _produce_tool_suburl_test_impl(ctx):
     env = unittest.begin(ctx)
     asserts.equals(
@@ -20,7 +23,7 @@
             iso_date = "2020-05-22",
             tool_name = "rust-std",
             version = "nightly",
-            target_triple = "x86_64-unknown-linux-gnu",
+            target_triple = _PLATFORM_TRIPLE,
         ),
     )
     asserts.equals(
@@ -29,7 +32,7 @@
         produce_tool_suburl(
             tool_name = "rust-std",
             version = "nightly",
-            target_triple = "x86_64-unknown-linux-gnu",
+            target_triple = _PLATFORM_TRIPLE,
         ),
     )
     asserts.equals(
@@ -71,7 +74,7 @@
         produce_tool_path(
             tool_name = "rust-std",
             version = "nightly",
-            target_triple = "x86_64-unknown-linux-gnu",
+            target_triple = _PLATFORM_TRIPLE,
         ),
     )
     asserts.equals(
@@ -95,7 +98,7 @@
         lookup_tool_sha256(
             ctx,
             tool_name = "rustc",
-            target_triple = "x86_64-unknown-linux-gnu",
+            target_triple = _PLATFORM_TRIPLE,
             version = "1.65.0",
             iso_date = "2022-11-02",
             sha256 = "",
@@ -109,7 +112,7 @@
         lookup_tool_sha256(
             ctx,
             tool_name = "rustc",
-            target_triple = "x86_64-unknown-linux-gnu",
+            target_triple = _PLATFORM_TRIPLE,
             version = "1.65.0",
             iso_date = "2022-11-02",
             sha256 = "FAKE_SHA256_FROM_ARG",
@@ -123,7 +126,7 @@
         lookup_tool_sha256(
             ctx,
             tool_name = "rust-std",
-            target_triple = "x86_64-unknown-linux-gnu",
+            target_triple = _PLATFORM_TRIPLE,
             version = "nightly",
             iso_date = "2022-11-02",
             sha256 = "",
@@ -137,7 +140,7 @@
         lookup_tool_sha256(
             ctx,
             tool_name = "rust-std",
-            target_triple = "x86_64-unknown-linux-gnu",
+            target_triple = _PLATFORM_TRIPLE,
             version = "nightly",
             iso_date = "2022-11-01",
             sha256 = "",
@@ -151,7 +154,7 @@
         lookup_tool_sha256(
             ctx,
             tool_name = "rust-std",
-            target_triple = "x86_64-unknown-linux-gnu",
+            target_triple = _PLATFORM_TRIPLE,
             version = "nightly",
             iso_date = "2022-11-01",
             sha256 = "FAKE_SHA256_FROM_ARG",