DioxusLabs / dioxus

Fullstack app framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
21.64k stars 833 forks source link

Manganis 0.6.0-alpha.5 using image() in asset! results in `macro expansion ignores token , and any following` #3229

Open hyziri opened 1 week ago

hyziri commented 1 week ago

Problem

When attempting to use the asset! macro as described in documentation here an error is thrown not allowing the usage of image() to specify image format & size of the asset.

20:35:26 [cargo] error: macro expansion ignores token `,` and any following
  --> src/main.rs:38:34
   |
37 |       const AUTUMN_LOGO: Asset = manganis::asset!(
   |  ________________________________-
38 | |         "/assets/autumn-logo.png",
   | |                                  ^
39 | |         asset::image().format(ImageType::Avif).size(64, 64)
40 | |     );
   | |_____- caused by the macro expansion here
   |
   = note: the usage of `manganis::asset!` is likely invalid in expression context

Setting the type of AUTUMN_LOGO to ImageAsset results in mismatched types error, unknown if this is even the intended solution though.

error[E0308]: mismatched types
  --> src/main.rs:37:37
   |
37 |       const AUTUMN_LOGO: ImageAsset = manganis::asset!(
   |  _____________________________________^
38 | |         "/assets/autumn-logo.png",
39 | |         asset::image().format(ImageType::Avif).size(64, 64)
40 | |     );
   | |_____^ expected `ImageAsset`, found `Asset`
   |
   = note: this error originates in the macro `manganis::asset` (in Nightly builds, run with -Z macro-backtrace for more info)

Steps To Reproduce

Steps to reproduce the behavior:

This GitHub repo is a minimal example of where this bug can be replicated.

Environment:

Questionnaire

I'm interested in fixing this myself but don't know where to start