Skip to content

Commit 075c0bf

Browse files
authored
Use IndexMap in byte_seq_parser macro (#438)
This make map iteration deterministic and makes tiny builds reproducible. Fixes #437.
1 parent eaed50d commit 075c0bf

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
- Improve nick matching to avoid highlighting message incorrectly. (#430)
44
- Fix resetting message color when a color prefix (0x03) is not followed by a
55
color code. (#434)
6+
- Refactor an internal macro to make tiny builds deterministic, allowing
7+
reproducible builds. (#437)
68

79
# 2024/01/01: 0.12.0
810

Cargo.lock

Lines changed: 26 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/term_input_macros/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ edition = "2021"
88
proc-macro = true
99

1010
[dependencies]
11+
indexmap = "2.7.0"
1112
proc-macro2 = "1.0"
1213
quote = "1.0"
1314
syn = { version = "2.0", features = ["full", "extra-traits"] }

crates/term_input_macros/src/tree.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
use crate::syntax::*;
22

3+
use indexmap::map::IndexMap;
34
use proc_macro2::TokenStream;
45
use quote::quote;
56
use quote::TokenStreamExt;
6-
use std::collections::HashMap;
77

88
struct Node {
99
idx: usize,
1010
value: Option<syn::Expr>,
11-
next: HashMap<u8, Node>,
11+
12+
// Note: `IndexMap` to be able to deterministically iterate the map and generate code
13+
// deterministically, which allows reproducible builds.
14+
next: IndexMap<u8, Node>,
1215
}
1316

1417
impl Node {
1518
fn new(idx: usize) -> Self {
1619
Node {
1720
idx,
1821
value: None,
19-
next: HashMap::new(),
22+
next: IndexMap::new(),
2023
}
2124
}
2225

0 commit comments

Comments
 (0)