Skip to content

Commit 677ed75

Browse files
committed
Extract a split_flags helper in header directive parsing
1 parent c38aeb0 commit 677ed75

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/tools/compiletest/src/header.rs

+16-9
Original file line numberDiff line numberDiff line change
@@ -321,16 +321,23 @@ impl TestProps {
321321
|r| r,
322322
);
323323

324-
if let Some(flags) = config.parse_name_value_directive(ln, COMPILE_FLAGS) {
325-
self.compile_flags.extend(
326-
flags
327-
.split("'")
328-
.enumerate()
329-
.flat_map(|(i, f)| {
324+
fn split_flags(flags: &str) -> Vec<String> {
325+
// Individual flags can be single-quoted to preserve spaces; see
326+
// <https://github.com/rust-lang/rust/pull/115948/commits/957c5db6>.
327+
flags
328+
.split("'")
329+
.enumerate()
330+
.flat_map(
331+
|(i, f)| {
330332
if i % 2 == 1 { vec![f] } else { f.split_whitespace().collect() }
331-
})
332-
.map(|s| s.to_owned()),
333-
);
333+
},
334+
)
335+
.map(move |s| s.to_owned())
336+
.collect::<Vec<_>>()
337+
}
338+
339+
if let Some(flags) = config.parse_name_value_directive(ln, COMPILE_FLAGS) {
340+
self.compile_flags.extend(split_flags(&flags));
334341
}
335342
if config.parse_name_value_directive(ln, INCORRECT_COMPILER_FLAGS).is_some() {
336343
panic!("`compiler-flags` directive should be spelled `compile-flags`");

0 commit comments

Comments
 (0)