)]}'
{
  "commit": "828c8071f39aa94a3bcfebb391b864aeb41453e9",
  "tree": "4eada66d22b8683c860dc6710c3f35dd9522fdd1",
  "parents": [
    "6a9359232eff24fa6f30978ac2d84bef615d591d"
  ],
  "author": {
    "name": "UebelAndre",
    "email": "github@uebelandre.com",
    "time": "Wed Dec 27 09:02:43 2023 -0800"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Wed Dec 27 17:02:43 2023 +0000"
  },
  "message": "Added `rust_unpretty_aspect` and `rust_unpretty` rules (#2356)\n\nProposal for https://github.com/bazelbuild/rules_rust/issues/1642\r\nDuplicates https://github.com/bazelbuild/rules_rust/pull/1643 (special\r\nthanks to @freeformstu)\r\n\r\n### Summary\r\n\r\nRustc can be used to expand all macros so that you can inspect the\r\ngenerated source files easier.\r\n\r\nThis feature is enabled via `-Zunpretty\u003d{mode}`. The `-Z` flag is only\r\navailable in the nightly\r\nversion of `rustc` (https://github.com/rust-lang/rust/issues/43364).\r\n\r\n\r\n### Unprettying\r\n\r\nBuild and test your targets normally.\r\n\r\n```\r\nbazel build //:ok_binary   \r\nINFO: Analyzed target //:ok_binary (0 packages loaded, 0 targets configured).\r\nINFO: Found 1 target...\r\nTarget //:ok_binary up-to-date:\r\n  bazel-bin/ok_binary\r\nINFO: Elapsed time: 0.081s, Critical Path: 0.00s\r\nINFO: 1 process: 1 internal.\r\nINFO: Build completed successfully, 1 total action\r\n```\r\n\r\nUse the aspect to generate the expanded files in as a one-off build.\r\n\r\n(`.bazelrc`)\r\n```\r\n# Enable unpretty for all targets in the workspace\r\nbuild:unpretty --aspects\u003d@rules_rust//rust:defs.bzl%rust_unpretty_aspect\r\nbuild:unpretty --output_groups\u003d+rust_unpretty\r\n\r\n# `unpretty` requires the nightly toolchain. See tracking issue:\r\n# https://github.com/rust-lang/rust/issues/43364\r\nbuild:unpretty --@rules_rust//rust/toolchain/channel\u003dnightly\r\n```\r\n\r\n```\r\nbazel build --config\u003dunpretty //:ok_binary\r\nINFO: Analyzed target //:ok_binary (1 packages loaded, 2 targets configured).\r\nINFO: Found 1 target...\r\nAspect @rules_rust//rust/private:unpretty.bzl%rust_unpretty_aspect of //:ok_binary up-to-date:\r\n  bazel-bin/ok_binary.expand.rs\r\nINFO: Elapsed time: 0.149s, Critical Path: 0.00s\r\nINFO: 1 process: 1 internal.\r\nINFO: Build completed successfully, 1 total action\r\n```\r\n\r\nTargeting tests is valid as well.\r\n\r\n```\r\nbazel build --config\u003dunpretty //:ok_test  \r\nINFO: Analyzed target //:ok_test (0 packages loaded, 2 targets configured).\r\nINFO: Found 1 target...\r\nAspect @rules_rust//rust/private:unpretty.bzl%rust_expand_aspect of //:ok_test up-to-date:\r\n  bazel-bin/test-397521499/ok_test.expand.rs\r\nINFO: Elapsed time: 0.113s, Critical Path: 0.00s\r\nINFO: 1 process: 1 internal.\r\nINFO: Build completed successfully, 1 total action\r\n```\r\n\r\nFinally, manually wire up a `rust_unpretty` target explicitly if you\r\nwant a target to build. This rule is unique compared to the aspect in\r\nthat it forces a transition to a nightly toolchain so that `-Zunpretty`\r\ncan be used.\r\n\r\n```starlark\r\nload(\"@rules_rust//rust:defs.bzl\", \"rust_binary\", \"rust_unpretty\")\r\n\r\nrust_binary(\r\n    name \u003d \"ok_binary\",\r\n    srcs \u003d [\"src/main.rs\"],\r\n    edition \u003d \"2021\",\r\n)\r\n\r\nrust_unpretty(\r\n    name \u003d \"ok_binary_expand\",\r\n    deps \u003d [\":ok_binary\"],\r\n)\r\n```\r\n\r\n```\r\nbazel build //:ok_binary_expand\r\nINFO: Analyzed target //:ok_binary_expand (0 packages loaded, 1 target configured).\r\nINFO: Found 1 target...\r\nTarget //:ok_binary_expand up-to-date:\r\n  bazel-bin/ok_binary.expand.rs\r\nINFO: Elapsed time: 0.090s, Critical Path: 0.00s\r\nINFO: 1 process: 1 internal.\r\nINFO: Build completed successfully, 1 total action\r\n```",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "9d23e7b2470edf8f535e99e03d937182c8df6850",
      "old_mode": 33188,
      "old_path": ".bazelci/presubmit.yml",
      "new_id": "80f88d4bbccb7c58531d5bad8f1dae05537d8f2b",
      "new_mode": 33188,
      "new_path": ".bazelci/presubmit.yml"
    },
    {
      "type": "modify",
      "old_id": "00e698c685cc850b5ebd5f805be86241271ac387",
      "old_mode": 33188,
      "old_path": ".bazelrc",
      "new_id": "0667486fb57c72a47b73e438520e2e3c0030c744",
      "new_mode": 33188,
      "new_path": ".bazelrc"
    },
    {
      "type": "modify",
      "old_id": "8573048e3d1f42b164799fea73a46f6d07b6fa35",
      "old_mode": 33188,
      "old_path": "rust/defs.bzl",
      "new_id": "3cee1afe54b3eeee2f598ff92c26ef02990a66de",
      "new_mode": 33188,
      "new_path": "rust/defs.bzl"
    },
    {
      "type": "modify",
      "old_id": "3e89d50ae94952561bcb7c20667e1b22fc28824c",
      "old_mode": 33188,
      "old_path": "rust/private/rust.bzl",
      "new_id": "bed6f81c46ea4dfb040d49787954666a68cbc7d8",
      "new_mode": 33188,
      "new_path": "rust/private/rust.bzl"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "81b04e0f5b22b2d4bcde553ed59d2160ca687ab4",
      "new_mode": 33188,
      "new_path": "rust/private/unpretty.bzl"
    },
    {
      "type": "modify",
      "old_id": "f1ba2025520df2f8d2bb504e61ffe8077ea9ae4c",
      "old_mode": 33188,
      "old_path": "rust/settings/BUILD.bazel",
      "new_id": "1f23709fb7fd5988a97772c2b33d0488b038c88c",
      "new_mode": 33188,
      "new_path": "rust/settings/BUILD.bazel"
    },
    {
      "type": "modify",
      "old_id": "6cb5147c1aa5b6a6e884d79c487305a68b3eb719",
      "old_mode": 33188,
      "old_path": "test/unit/force_all_deps_direct/force_all_deps_direct_test.bzl",
      "new_id": "39e705aaf06892921c4dad1e293e10acd2006fdc",
      "new_mode": 33188,
      "new_path": "test/unit/force_all_deps_direct/force_all_deps_direct_test.bzl"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "3f0f77363f263d5ce275f6e890f2d56bd0d2555d",
      "new_mode": 33188,
      "new_path": "test/unpretty/BUILD.bazel"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "9005e0d32dbd0f2114fbc88f24073268b88fc14e",
      "new_mode": 33188,
      "new_path": "test/unpretty/proc_macro.rs"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "f167085f2ab03bd0a7a1f77182eccb7c9a846cb0",
      "new_mode": 33188,
      "new_path": "test/unpretty/proc_macro.unpretty.expanded.rs"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "c5f92f044fa9b5339d53529731c4df1820f36282",
      "new_mode": 33188,
      "new_path": "test/unpretty/proc_macro_test.rs"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "7261e999e959c6208fb485414db34172cf7595d8",
      "new_mode": 33188,
      "new_path": "test/unpretty/proc_macro_test.unpretty.expanded.rs"
    }
  ]
}
