Skip to content

Commit 08d70f5

Browse files
committed
Use struct-like syntax in tool_extended!
Using struct-like syntax allows rustfmt to format macro invocations, instead of giving up and ignoring them. Using a separate macro invocation per tool makes the macro slightly simpler, and isolates syntax errors to individual invocations.
1 parent 725fccd commit 08d70f5

File tree

1 file changed

+36
-18
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+36
-18
lines changed

src/bootstrap/src/core/build_steps/tool.rs

+36-18
Original file line numberDiff line numberDiff line change
@@ -1008,14 +1008,15 @@ impl Step for LibcxxVersionTool {
10081008

10091009
macro_rules! tool_extended {
10101010
(
1011-
$($name:ident,
1012-
$path:expr,
1013-
$tool_name:expr,
1014-
stable = $stable:expr
1015-
$(,add_bins_to_sysroot = $add_bins_to_sysroot:expr)?
1016-
;)+) => {
1017-
$(
1018-
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
1011+
$name:ident {
1012+
path: $path:expr,
1013+
tool_name: $tool_name:expr,
1014+
stable: $stable:expr
1015+
$( , add_bins_to_sysroot: $add_bins_to_sysroot:expr )?
1016+
$( , )?
1017+
}
1018+
) => {
1019+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
10191020
pub struct $name {
10201021
pub compiler: Compiler,
10211022
pub target: TargetSelection,
@@ -1063,7 +1064,6 @@ macro_rules! tool_extended {
10631064
)
10641065
}
10651066
}
1066-
)+
10671067
}
10681068
}
10691069

@@ -1109,15 +1109,33 @@ fn run_tool_build_step(
11091109
}
11101110
}
11111111

1112-
tool_extended!(
1113-
Cargofmt, "src/tools/rustfmt", "cargo-fmt", stable=true;
1114-
CargoClippy, "src/tools/clippy", "cargo-clippy", stable=true;
1115-
Clippy, "src/tools/clippy", "clippy-driver", stable=true, add_bins_to_sysroot = ["clippy-driver", "cargo-clippy"];
1116-
Miri, "src/tools/miri", "miri", stable=false, add_bins_to_sysroot = ["miri"];
1117-
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=false, add_bins_to_sysroot = ["cargo-miri"];
1118-
Rls, "src/tools/rls", "rls", stable=true;
1119-
Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, add_bins_to_sysroot = ["rustfmt", "cargo-fmt"];
1120-
);
1112+
tool_extended!(Cargofmt { path: "src/tools/rustfmt", tool_name: "cargo-fmt", stable: true });
1113+
tool_extended!(CargoClippy { path: "src/tools/clippy", tool_name: "cargo-clippy", stable: true });
1114+
tool_extended!(Clippy {
1115+
path: "src/tools/clippy",
1116+
tool_name: "clippy-driver",
1117+
stable: true,
1118+
add_bins_to_sysroot: ["clippy-driver", "cargo-clippy"]
1119+
});
1120+
tool_extended!(Miri {
1121+
path: "src/tools/miri",
1122+
tool_name: "miri",
1123+
stable: false,
1124+
add_bins_to_sysroot: ["miri"]
1125+
});
1126+
tool_extended!(CargoMiri {
1127+
path: "src/tools/miri/cargo-miri",
1128+
tool_name: "cargo-miri",
1129+
stable: false,
1130+
add_bins_to_sysroot: ["cargo-miri"]
1131+
});
1132+
tool_extended!(Rls { path: "src/tools/rls", tool_name: "rls", stable: true });
1133+
tool_extended!(Rustfmt {
1134+
path: "src/tools/rustfmt",
1135+
tool_name: "rustfmt",
1136+
stable: true,
1137+
add_bins_to_sysroot: ["rustfmt", "cargo-fmt"]
1138+
});
11211139

11221140
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
11231141
pub struct TestFloatParse {

0 commit comments

Comments
 (0)