Skip to content

Allow different reprs to still work#687

Merged
serban300 merged 13 commits intomasterfrom
jsdw-fix-discriminant-idx
Jan 28, 2025
Merged

Allow different reprs to still work#687
serban300 merged 13 commits intomasterfrom
jsdw-fix-discriminant-idx

Conversation

@jsdw
Copy link
Copy Markdown
Contributor

@jsdw jsdw commented Jan 27, 2025

Don't output suffixes when generating the index array in the const fun, to avoid the suffix types from conflicting with the declared type of the index array (usize) which leads to compile errors when indexes are from discriminants and are not usizes.

Should fix #686

@jsdw jsdw marked this pull request as ready for review January 27, 2025 18:02
@serban300
Copy link
Copy Markdown
Contributor

@jsdw please, can you also update the version to 3.7.2 ?

@jsdw
Copy link
Copy Markdown
Contributor Author

jsdw commented Jan 27, 2025

Done!

I have to head out now but if it's failing tests or anything I'll sort it out later or in the morning!

} else {
Err(syn::Error::new(
discriminant.span(),
"Discriminant must be an integer literal in the range 0..255",
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.

Forcing this to be an integer is a breaking change.

Potential fix: #695

if index.is_none() {
if let Some((_, Expr::Lit(ExprLit { lit: Lit::Int(disc_lit), .. }))) = &v.discriminant {
index = disc_lit.base10_parse::<usize>().ok()
}
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.

This is ignoring the discriminant when defined with an expression.

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.

Derive encode/decode compile error[E0308]: mismatched types

5 participants