mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-13 08:48:19 +00:00
order cycles by debug_name first
We used to sort just by the ingredient index, but since those are now added dynamically, that can be fairly unstable in some of the tests. We now sort by the "debug name" of the ingredient first, which is more reliably stable.
This commit is contained in:
parent
03a62c8ce5
commit
a5395665ce
3 changed files with 14 additions and 4 deletions
|
@ -281,7 +281,12 @@ impl Runtime {
|
|||
// (at least for this execution, not necessarily across executions),
|
||||
// no matter where it started on the stack. Find the minimum
|
||||
// key and rotate it to the front.
|
||||
let min = v.iter().min().unwrap();
|
||||
let min = v
|
||||
.iter()
|
||||
.map(|key| (key.ingredient_index.debug_name(db), key))
|
||||
.min()
|
||||
.unwrap()
|
||||
.1;
|
||||
let index = v.iter().position(|p| p == min).unwrap();
|
||||
v.rotate_left(index);
|
||||
|
||||
|
|
|
@ -201,6 +201,11 @@ impl IngredientIndex {
|
|||
pub fn successor(self, index: usize) -> Self {
|
||||
IngredientIndex(self.0 + 1 + index as u32)
|
||||
}
|
||||
|
||||
/// Return the "debug name" of this ingredient (e.g., the name of the tracked struct it represents)
|
||||
pub(crate) fn debug_name(self, db: &dyn Database) -> &'static str {
|
||||
db.lookup_ingredient(self).debug_name()
|
||||
}
|
||||
}
|
||||
|
||||
/// The "storage" struct stores all the data for the jars.
|
||||
|
|
|
@ -220,8 +220,8 @@ fn inner_cycle() {
|
|||
assert!(err.is_err());
|
||||
let expected = expect![[r#"
|
||||
[
|
||||
"cycle_b(0)",
|
||||
"cycle_a(0)",
|
||||
"cycle_b(0)",
|
||||
]
|
||||
"#]];
|
||||
expected.assert_debug_eq(&err.unwrap_err().cycle);
|
||||
|
@ -328,8 +328,8 @@ fn cycle_mixed_1() {
|
|||
|
||||
let expected = expect![[r#"
|
||||
[
|
||||
"cycle_c(0)",
|
||||
"cycle_b(0)",
|
||||
"cycle_c(0)",
|
||||
]
|
||||
"#]];
|
||||
expected.assert_debug_eq(&cycle_c(db, abc).unwrap_err().cycle);
|
||||
|
@ -379,8 +379,8 @@ fn cycle_deterministic_order() {
|
|||
"cycle_b(0)",
|
||||
],
|
||||
[
|
||||
"cycle_b(0)",
|
||||
"cycle_a(0)",
|
||||
"cycle_b(0)",
|
||||
],
|
||||
)
|
||||
"#]];
|
||||
|
|
Loading…
Reference in a new issue