Skip to content

Add migrations to ModuleDef - #5953

Open
coolreader18 wants to merge 3 commits into
masterfrom
noa/migrations-schema
Open

coolreader18 wants to merge 3 commits into
masterfrom
noa/migrations-schema

Conversation

@coolreader18

Copy link
Copy Markdown
Contributor

Description of Changes

Adds migrations as a section of ModuleDef. The first commit adds a struct that contains all of the sections, so we don't have to do a linear search each time we modify one.

Rollback safety impact

n/a

Expected complexity level and risk

2

Testing


Stack created with GitHub Stacks CLI • Give Feedback 💬

@coolreader18
coolreader18 added this pull request to stack #5954 September 16, 2026 21:33
@coolreader18
coolreader18 requested a review from aasoni September 16, 2026 21:33
@coolreader18
coolreader18 force-pushed the noa/migrations-schema branch 2 times, most recently from 202b400 to eeda389 Compare September 24, 2026 17:16
@coolreader18
coolreader18 removed this pull request from stack #5954 September 24, 2026 17:23
@coolreader18
coolreader18 changed the base branch from noa/upd-rust-1.98 to noa/fix-environment September 24, 2026 17:24
@coolreader18
coolreader18 added this pull request to stack #5982 September 24, 2026 17:24
@coolreader18
coolreader18 marked this pull request as ready for review September 24, 2026 17:43
Comment thread crates/lib/src/db/raw_def/v10.rs Outdated
/// `AlgebraicTypeRef`s in other sections refer to this typespace.
/// See [`crate::db::raw_def::v9::RawModuleDefV9::typespace`] for validation requirements.
Typespace(Typespace),
macro_rules! with_v10_sections {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are we introducing a new macro here?

@cloutiertyler cloutiertyler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's with all the macro work as part of this PR. It doesn't seem relevant and makes the code considerably more difficult to read.

Base automatically changed from noa/fix-environment to master September 29, 2026 22:06
@coolreader18
coolreader18 removed this pull request from stack #5982 September 30, 2026 18:41
@coolreader18
coolreader18 added this pull request to stack #6026 September 30, 2026 18:46
@coolreader18

Copy link
Copy Markdown
Contributor Author

The first commit is to simplify the way we modify ModuleDefs - instead of doing a linear search for each one, and having all the different <section>_mut() methods have to be defined manually, we can use a macro to make it more reasonable to work with.

@coolreader18

Copy link
Copy Markdown
Contributor Author

It also means we're less likely to accidentally forget about a section, since we can exhaustively destructure the RawModuleDefV10Sections struct.

@coolreader18
coolreader18 force-pushed the noa/migrations-schema branch from 26dff90 to b93ecac Compare October 5, 2026 17:33

@joshua-spacetime joshua-spacetime left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you add a module def round trip test for a migration:

RawModuleDefV10 → validate → ModuleDef → RawModuleDefV10 → validate

@joshua-spacetime joshua-spacetime left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you generate the module defs for the other languages?

Comment on lines +7 to +9
impl<T> SectionPayload for Vec<T> {
fn skip_serializing(&self) -> bool {
self.is_empty()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this correct to do for empty environments? It's unclear based on this comment:

/// `None` means undeclared; an explicitly empty declaration is `Some(empty)`.

This branch has not been deployed

No deployments
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