Skip to content

Keep preprocessors/backends execution order deterministic#2801

Merged
ehuss merged 2 commits into
rust-lang:masterfrom
HollowMan6:btreemap
Aug 18, 2025
Merged

Keep preprocessors/backends execution order deterministic#2801
ehuss merged 2 commits into
rust-lang:masterfrom
HollowMan6:btreemap

Conversation

@HollowMan6
Copy link
Copy Markdown
Contributor

@HollowMan6 HollowMan6 commented Aug 18, 2025

There's a regression caused by recent refactor work, as it used to execute preprocessors/backends in a deterministic way, but now this is not the case, which causes trouble when some backends implicitly depend on the result from another backend and happen to work (e.g. mdbook-pdf). The root cause is that a HashMap has no order, so this PR switches this into BTreeMap instead.

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Aug 18, 2025
@ehuss
Copy link
Copy Markdown
Contributor

ehuss commented Aug 18, 2025

Just for clarification, this doesn't appear to preserve the order in book.toml (I don't think it did in the past, either, though it was alphabetical). I'm fine with merging this, but I just wanted to verify we're both understanding this correctly.

I'm wondering, if a renderer requires a certain order if it would make sense to instead have an explicit order like preprocessors do?

@HollowMan6
Copy link
Copy Markdown
Contributor Author

Just for clarification, this doesn't appear to preserve the order in book.toml (I don't think it did in the past, either, though it was alphabetical). I'm fine with merging this, but I just wanted to verify we're both understanding this correctly.

Ah...😅 To be honest, I didn't really check the source code in the past until today I found mdbook-pdf is broken, and I imagined it used to preserve the order in book.toml. But in any case, it's good to have deterministic execution order, so that mdbook-pdf won't be broken.

I'm wondering, if a renderer requires a certain order if it would make sense to instead have an explicit order like preprocessors do?

It can be good to have an explicit order like preprocessors do in the long run, but it's not necessary for mdbook-pdf then in the short term, as it solely relies on html backend's generated files, and p is after h if it's executed in alphabetical order.

@HollowMan6 HollowMan6 changed the title Maintain preprocessors/backends execution order as defined in book.toml Keep preprocessors/backends execution order deterministic Aug 18, 2025
Copy link
Copy Markdown
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ehuss ehuss enabled auto-merge August 18, 2025 18:44
HollowMan6 and others added 2 commits August 18, 2025 11:58
There's a regression caused by recent refactor work, as it used to execute preprocessors/backends in a deterministic way, but now this is not the case, which causes trouble when some backends implicitly depend on the result from another backend and happen to work (e.g. mdbook-pdf). The root cause is that a HashMap has no order, so this PR switches this into `BTreeMap` instead.

Signed-off-by: Hollow Man <hollowman@opensuse.org>
@ehuss ehuss added this pull request to the merge queue Aug 18, 2025
Merged via the queue into rust-lang:master with commit 29ae40c Aug 18, 2025
14 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: waiting on a review label Aug 18, 2025
@HollowMan6 HollowMan6 deleted the btreemap branch August 18, 2025 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants