Public entry point to all Rust rules and supported APIs.

Rules

Aspects

rust_unpretty

load("@rules_rust//rust:defs.bzl", "rust_unpretty")

rust_unpretty(name, deps, mode)

Executes rust unpretty on a specific target.

Similar to rust_unpretty_aspect, but allows specifying a list of dependencies within the build system.

For example, given the following example targets:

load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")

rust_library(
    name = "hello_lib",
    srcs = ["src/lib.rs"],
)

rust_test(
    name = "greeting_test",
    srcs = ["tests/greeting.rs"],
    deps = [":hello_lib"],
)

Rust expand can be set as a build target with the following:

load("@rules_rust//rust:defs.bzl", "rust_unpretty")

rust_unpretty(
    name = "hello_library_expand",
    testonly = True,
    deps = [
        ":hello_lib",
        ":greeting_test",
    ],
    mode = "expand",
)

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
depsRust targets to run unpretty on.List of labelsoptional[]
modeThe value to pass to --unprettyStringoptional"expanded"

rust_unpretty_aspect

load("@rules_rust//rust:defs.bzl", "rust_unpretty_aspect")

rust_unpretty_aspect()

Executes Rust expand on specified targets.

This aspect applies to existing rust_library, rust_test, and rust_binary rules.

As an example, if the following is defined in examples/hello_lib/BUILD.bazel:

load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")

rust_library(
    name = "hello_lib",
    srcs = ["src/lib.rs"],
)

rust_test(
    name = "greeting_test",
    srcs = ["tests/greeting.rs"],
    deps = [":hello_lib"],
)

Then the targets can be expanded with the following command:

$ bazel build --aspects=@rules_rust//rust:defs.bzl%rust_unpretty_aspect \
              --output_groups=rust_unpretty_expanded \
              //hello_lib:all

ASPECT ATTRIBUTES

ATTRIBUTES