Skip to content

Commit af1e430

Browse files
committed
Add a macro for hashmap key-values
1 parent 9ad81cb commit af1e430

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

compiler/base/orchestrator/src/coordinator.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ use crate::{
3333
DropErrorDetailsExt, TaskAbortExt as _,
3434
};
3535

36+
macro_rules! kvs {
37+
($($k:expr => $v:expr),+$(,)?) => {
38+
[
39+
$((Into::into($k), Into::into($v)),)+
40+
].into_iter()
41+
};
42+
}
43+
3644
pub mod limits;
3745

3846
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -393,7 +401,7 @@ impl LowerRequest for ExecuteRequest {
393401

394402
let mut envs = HashMap::new();
395403
if self.backtrace {
396-
envs.insert("RUST_BACKTRACE".to_owned(), "1".to_owned());
404+
envs.extend(kvs!("RUST_BACKTRACE" => "1"));
397405
}
398406

399407
ExecuteCommandRequest {
@@ -522,7 +530,7 @@ impl LowerRequest for CompileRequest {
522530
}
523531
let mut envs = HashMap::new();
524532
if self.backtrace {
525-
envs.insert("RUST_BACKTRACE".to_owned(), "1".to_owned());
533+
envs.extend(kvs!("RUST_BACKTRACE" => "1"));
526534
}
527535

528536
ExecuteCommandRequest {
@@ -685,7 +693,7 @@ impl LowerRequest for MiriRequest {
685693
ExecuteCommandRequest {
686694
cmd: "cargo".to_owned(),
687695
args: vec!["miri-playground".to_owned()],
688-
envs: HashMap::from_iter([("MIRIFLAGS".to_owned(), miriflags)]),
696+
envs: kvs!("MIRIFLAGS" => miriflags).collect(),
689697
cwd: None,
690698
}
691699
}

0 commit comments

Comments
 (0)