You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of only touching rsx! and render! macros, the autoformatter tries to format all macros. This causes issues with macros that use syntax different from the rsx macros.
use dioxus::prelude::*;fnmain(){
dioxus_web::launch(app);}fnapp(cx:Scope) -> Element{let message = format!("Hello, {}!", "World");render!{message}}
Actual Behaviour
The dx fmt command panics:
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Error("Expected Ident or Expression")', /home/deck/.local/share/cargo/registry/src/in
dex.crates.io-6f17d22bba15001f/dioxus-autofmt-0.4.0/src/lib.rs:71:50
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error formatting file: /home/deck/Downloads/dioxus-broken-fmt-example/src/main.rs
task 7 panicked
If you change the format! macro call to format!("Hello, {0}!", "World") so that it is acceptable rsx syntax, it is formatted to format!( "Hello, {0}!", "World" ) (notice the added spaces). Dioxus should not change that macro call, and cargo fmt also reverts it to without the spaces.
Environment:
Dioxus version: v0.4.0
Rust version: rustc 1.71.1 (eb26296b5 2023-08-03)
OS info: Arch Linux
App platform: web (but should affect all platforms)
Questionnaire
I'm interested in fixing this myself but don't know where to start
I would like to fix and I have a solution
I don't have time to fix this right now, but maybe later
The text was updated successfully, but these errors were encountered:
❯ find src -name \*.rs | xargs -n 1 dx fmt -f
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("Expected Ident or Expression")', /private/tmp/nix-build-dioxus-cli-0.4.1.drv-0/dioxus-cli-0.4.1-vendor.tar.gz/dioxus-autofmt/src/lib.rs:71:50
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
formatted src/main.rs
Problem
Instead of only touching
rsx!
andrender!
macros, the autoformatter tries to format all macros. This causes issues with macros that use syntax different from the rsx macros.Steps To Reproduce
Steps to reproduce the behavior:
cargo new dioxus-broken-fmt-example
cd dioxus-broken-fmt-example
cargo add dioxus dioxus-web
src/main.rs
dx fmt
Expected behavior
The file should be formatted to the following:
Actual Behaviour
The
dx fmt
command panics:If you change the
format!
macro call toformat!("Hello, {0}!", "World")
so that it is acceptable rsx syntax, it is formatted toformat!( "Hello, {0}!", "World" )
(notice the added spaces). Dioxus should not change that macro call, andcargo fmt
also reverts it to without the spaces.Environment:
rustc 1.71.1 (eb26296b5 2023-08-03)
web
(but should affect all platforms)Questionnaire
The text was updated successfully, but these errors were encountered: