diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index 1ad6a5f5be..a97dd12eea 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -1535,12 +1535,16 @@ def construct_arguments( if rustc_env_attr: target_has_location_expansion = has_location_expansion(rustc_env_attr.values()) + # Path mapping requires sandboxed execution, which these tags disable. + tags = getattr(attr, "tags", []) + requires_unsandboxed_execution = "no-sandbox" in tags or "local" in tags + args = struct( process_wrapper_flags = process_wrapper_flags, rustc_path = rustc_path, rustc_flags = rustc_flags, extra_rustc_flags = rust_flags_args, - supports_path_mapping = not target_has_location_expansion, + supports_path_mapping = not target_has_location_expansion and not requires_unsandboxed_execution, all = all_args, ) diff --git a/test/path_mapping/BUILD.bazel b/test/path_mapping/BUILD.bazel new file mode 100644 index 0000000000..a3f67bf12b --- /dev/null +++ b/test/path_mapping/BUILD.bazel @@ -0,0 +1,7 @@ +load("@rules_rust//rust:defs.bzl", "rust_test") + +rust_test( + name = "no_sandbox_test", + srcs = ["no_sandbox_test.rs"], + tags = ["no-sandbox"], +) diff --git a/test/path_mapping/no_sandbox_test.rs b/test/path_mapping/no_sandbox_test.rs new file mode 100644 index 0000000000..1e5dd2c549 --- /dev/null +++ b/test/path_mapping/no_sandbox_test.rs @@ -0,0 +1,4 @@ +#[test] +fn runs_without_sandboxing() { + assert_eq!(2 + 2, 4); +}