BUILD.gn: Gate `all_rust` target

This CL changes the recipe for `gn_all` to not pull in Rust targets when
`enable_rust` is set false.

Change-Id: I9b63146255122d0521fe929c6398fe2f8e6c1591
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4685588
Reviewed-by: Thomas Anderson <[email protected]>
Reviewed-by: Ɓukasz Anforowicz <[email protected]>
Reviewed-by: danakj <[email protected]>
Commit-Queue: Kalvin Lee <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1172776}
diff --git a/BUILD.gn b/BUILD.gn
index acd08b3..3576471 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -834,7 +834,9 @@
     ]
 
     # Rust build targets.
-    deps += [ ":all_rust" ]
+    if (enable_rust) {
+      deps += [ ":all_rust" ]
+    }
 
     if (!is_android && !is_ios) {
       deps += [ "//components/cronet:cronet_tests" ]
@@ -847,24 +849,20 @@
 group("all_rust") {
   testonly = true
 
-  # Unconditional because this includes things that should work whether or not
-  # Rust is enabled.
   deps = [ ":rust_build_tests" ]
 
-  if (toolchain_has_rust) {
-    # There is rust stuff behind flags in here.
-    deps += [ "//base:base_unittests" ]
+  # There is rust stuff behind flags in here.
+  deps += [ "//base:base_unittests" ]
 
-    if (enable_rust_mojo) {
-      deps += [
-        "//mojo/public/rust",
-        "//mojo/public/rust:mojo_rust_integration_unittests",
-        "//mojo/public/rust:mojo_rust_unittests",
-      ]
-    }
-    if (enable_rust_gtest_interop) {
-      deps += [ "//testing/rust_gtest_interop:rust_gtest_interop_unittests" ]
-    }
+  if (enable_rust_mojo) {
+    deps += [
+      "//mojo/public/rust",
+      "//mojo/public/rust:mojo_rust_integration_unittests",
+      "//mojo/public/rust:mojo_rust_unittests",
+    ]
+  }
+  if (enable_rust_gtest_interop) {
+    deps += [ "//testing/rust_gtest_interop:rust_gtest_interop_unittests" ]
   }
 }