Skip to content

Commit 8d9c682

Browse files
authored
Unrolled build for #151670
Rollup merge of #151670 - Enselic:proc-macro-struct, r=Zalathar compiletest: Parse aux `proc-macro` directive into struct This PR does not introduce any changes. It is pure refactoring to make PR #151258 smaller so it is easier to see what that PR is about, as discussed [here](#151258 (comment)). r? @Zalathar
2 parents 0462e8f + 30e41de commit 8d9c682

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/tools/compiletest/src/directives/auxiliary.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ pub struct AuxCrate {
2525
pub path: String,
2626
}
2727

28+
/// The value of a `proc-macro` directive.
29+
#[derive(Clone, Debug, Default)]
30+
pub(crate) struct ProcMacro {
31+
/// With `proc-macro: bar.rs` this will be `bar.rs`.
32+
pub path: String,
33+
}
34+
2835
/// Properties parsed from `aux-*` test directives.
2936
#[derive(Clone, Debug, Default)]
3037
pub(crate) struct AuxProps {
@@ -37,7 +44,7 @@ pub(crate) struct AuxProps {
3744
/// to build and pass with the `--extern` flag.
3845
pub(crate) crates: Vec<AuxCrate>,
3946
/// Same as `builds`, but for proc-macros.
40-
pub(crate) proc_macros: Vec<String>,
47+
pub(crate) proc_macros: Vec<ProcMacro>,
4148
/// Similar to `builds`, but also uses the resulting dylib as a
4249
/// `-Zcodegen-backend` when compiling the test file.
4350
pub(crate) codegen_backend: Option<String>,
@@ -53,7 +60,7 @@ impl AuxProps {
5360
.chain(builds.iter().map(String::as_str))
5461
.chain(bins.iter().map(String::as_str))
5562
.chain(crates.iter().map(|c| c.path.as_str()))
56-
.chain(proc_macros.iter().map(String::as_str))
63+
.chain(proc_macros.iter().map(|p| p.path.as_str()))
5764
.chain(codegen_backend.iter().map(String::as_str))
5865
}
5966
}
@@ -74,8 +81,8 @@ pub(super) fn parse_and_update_aux(
7481
config.push_name_value_directive(ln, AUX_BUILD, &mut aux.builds, |r| r.trim().to_string());
7582
config.push_name_value_directive(ln, AUX_BIN, &mut aux.bins, |r| r.trim().to_string());
7683
config.push_name_value_directive(ln, AUX_CRATE, &mut aux.crates, parse_aux_crate);
77-
config
78-
.push_name_value_directive(ln, PROC_MACRO, &mut aux.proc_macros, |r| r.trim().to_string());
84+
config.push_name_value_directive(ln, PROC_MACRO, &mut aux.proc_macros, parse_proc_macro);
85+
7986
if let Some(r) = config.parse_name_value_directive(ln, AUX_CODEGEN_BACKEND) {
8087
aux.codegen_backend = Some(r.trim().to_owned());
8188
}
@@ -99,3 +106,7 @@ fn parse_aux_crate(r: String) -> AuxCrate {
99106

100107
AuxCrate { extern_modifiers: modifiers, name, path }
101108
}
109+
110+
fn parse_proc_macro(r: String) -> ProcMacro {
111+
ProcMacro { path: r.trim().to_string() }
112+
}

src/tools/compiletest/src/runtest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,13 +1298,13 @@ impl<'test> TestCx<'test> {
12981298
}
12991299

13001300
for proc_macro in &self.props.aux.proc_macros {
1301-
self.build_auxiliary(proc_macro, &aux_dir, Some(AuxType::ProcMacro));
1302-
let crate_name = path_to_crate_name(proc_macro);
1301+
self.build_auxiliary(&proc_macro.path, &aux_dir, Some(AuxType::ProcMacro));
1302+
let crate_name = path_to_crate_name(&proc_macro.path);
13031303
add_extern(
13041304
rustc,
13051305
None, // `extern_modifiers`
13061306
&crate_name,
1307-
proc_macro,
1307+
&proc_macro.path,
13081308
AuxType::ProcMacro,
13091309
);
13101310
}

0 commit comments

Comments
 (0)