`rustfmt_aspect` now appropriately uses a config (#748)
* `rustfmt_aspect` now appropriately uses a config
* Config is considered an input
diff --git a/rust/private/rustfmt.bzl b/rust/private/rustfmt.bzl
index 43051e5..d38c2a8 100644
--- a/rust/private/rustfmt.bzl
+++ b/rust/private/rustfmt.bzl
@@ -44,7 +44,7 @@
def _perform_check(edition, srcs, ctx):
toolchain = find_toolchain(ctx)
-
+ config = ctx.file._config
marker = ctx.actions.declare_file(ctx.label.name + ".rustfmt.ok")
args = ctx.actions.args()
@@ -52,6 +52,8 @@
args.add(marker)
args.add("--")
args.add(toolchain.rustfmt)
+ args.add("--config-path")
+ args.add(config)
args.add("--edition")
args.add(edition)
args.add("--check")
@@ -59,7 +61,7 @@
ctx.actions.run(
executable = ctx.executable._process_wrapper,
- inputs = srcs,
+ inputs = srcs + [config],
outputs = [marker],
tools = [toolchain.rustfmt],
arguments = [args],
@@ -108,6 +110,11 @@
source files are also ignored by this aspect.
""",
attrs = {
+ "_config": attr.label(
+ doc = "The `rustfmt.toml` file used for formatting",
+ allow_single_file = True,
+ default = Label("//:rustfmt.toml"),
+ ),
"_process_wrapper": attr.label(
doc = "A process wrapper for running rustfmt on all platforms",
cfg = "exec",