feat: add a Cargo feature for mgf_dev-specific functionality #541

Merged
wetneb merged 2 commits from dev-feature into main 2025-07-28 09:15:52 +02:00
Owner

as discussed in #534 (comment)

as discussed in https://codeberg.org/mergiraf/mergiraf/issues/534#issuecomment-5994640
wetneb approved these changes 2025-07-28 09:15:44 +02:00
wetneb merged commit a2a18332a3 into main 2025-07-28 09:15:52 +02:00
Owner

After using it in #536, I'm not super duper convinced by the usefulness of having a feature… it forces us to recursively gate quite some things with it (including use statements, so that they're not marked as unnecessary). Do we really gain something with this? Isn't the compiler good enough at getting rid of code that's not used in a given binary, especially with the LTO optimization?

After using it in #536, I'm not super duper convinced by the usefulness of having a feature… it forces us to recursively gate quite some things with it (including `use` statements, so that they're not marked as unnecessary). Do we really gain something with this? Isn't the compiler good enough at getting rid of code that's not used in a given binary, especially with the LTO optimization?
Author
Owner

I agree it can be annoying – for me it's the fact that rust-analyzer blends out the feature-gated code and doesn't show diagnostics for it (although there is a solution).

One solution to the need for granular imports could be to put everything dev-specific into a separate module, and gate that under the feature. The commutative isomorphism code is mostly self-contained after all.

Isn't the compiler good enough at getting rid of code that's not used in a given binary?

Of course. It'll still compile the dev-only methods just to throw them away afterwards, which is a bit of a shame, but the resulting binary should be as lean as ever.

So overall I'm not too opposed to reverting this PR + turning on LTO in Cargo.toml (EDIT: nvm we have it turned on already)

I agree it can be annoying – for me it's the fact that rust-analyzer blends out the feature-gated code and doesn't show diagnostics for it ([although there is a solution](https://rust-analyzer.github.io/book/configuration.html#cargo.features)). One solution to the need for granular imports could be to put everything dev-specific into a separate module, and gate _that_ under the feature. The commutative isomorphism code is mostly self-contained after all. > Isn't the compiler good enough at getting rid of code that's not used in a given binary? Of course. It'll still compile the dev-only methods just to throw them away afterwards, which is a bit of a shame, but the resulting binary should be as lean as ever. So overall I'm not too opposed to reverting this PR ~+ turning on LTO in Cargo.toml~ (EDIT: nvm we have it turned on already)
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: mergiraf/mergiraf#541
No description provided.