Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rust generated code with struct of percent value #5889

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

ogoffart
Copy link
Member

We wouldn't detect percent as a unit product in

if t.as_unit_product().is_some() {
// number needs to be converted to the right things because intermediate
// result might be f64 and that's usually not what the type of the tuple is in the end
let t = rust_primitive_type(t).unwrap();
quote!(as #t)

Percent is not strictly of percent unit because that unit doesn't combine with other unit (as per the comment in default_unit) But since it converts to number, it is then an unitless value. (scalar)

Fixes #5887

We wouldn't detect percent as a unit product in
https://github.com/slint-ui/slint/blob/43c7f57b0ff0ee10e7275cd635dc5e6aa0ef4be1/internal/compiler/generator/rust.rs#L2418-L2422

Percent is not strictly of percent unit because that unit doesn't
combine with other unit (as per the comment in `default_unit`)
But since it converts to number, it is then an unitless value. (scalar)

Fixes #5887
@ogoffart ogoffart requested a review from tronical August 21, 2024 12:24
@ogoffart ogoffart added the candidate-for-bugfix-release Label for PRs that would make sense to cherry-pick into a spontaneously created bug fix release bran label Aug 21, 2024
@ogoffart ogoffart merged commit 85063dc into master Aug 21, 2024
35 checks passed
@ogoffart ogoffart deleted the olivier/fix-5887 branch August 21, 2024 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
candidate-for-bugfix-release Label for PRs that would make sense to cherry-pick into a spontaneously created bug fix release bran
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compilation error non-primitive cast: '(f64, f64)' as '(f32, f32)' in function returning struct
2 participants