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

dx fmt formating is not accepted by cargo fmt --check #3433

Open
LuckyTurtleDev opened this issue Dec 22, 2024 · 0 comments
Open

dx fmt formating is not accepted by cargo fmt --check #3433

LuckyTurtleDev opened this issue Dec 22, 2024 · 0 comments

Comments

@LuckyTurtleDev
Copy link

Problem
The formatting which is created by dx fmt is not accepted by cargo fmt --check.

Steps To Reproduce

Steps to reproduce the behavior:
create a new dioxus project with the following main.rs

use dioxus::prelude::*;

fn main() {
	dioxus::launch(App);
}

enum BookType {
	AudioBook,
	EBook,
}

#[component]
fn App() -> Element {
	let value = BookType::AudioBook;
	rsx! {
		"hello world"
		match value {
			BookType::AudioBook => rsx! {
			div { "audio icon eeeeeeeeeeeeeeeeeeeeeeeeee" }
		},
			BookType::EBook => rsx! {
			div { "book icon eeeeeeeeeeeeeeeeeeeeeeeeeee" }
		},
		}
	}
}

the code was formatted with cargo fmt and the following rustfmt.toml config:

edition = "2021"

hard_tabs = true
tab_spaces = 4

run dx fmt and you get the follwing code:

use dioxus::prelude::*;
fn main() {
	dioxus::launch(App);
}
enum BookType {
	AudioBook,
	EBook,
}
#[component]
fn App() -> Element {
	let value = BookType::AudioBook;
	rsx! {
		"hello world"
		match value {
		    BookType::AudioBook => rsx! {
			div { "audio icon eeeeeeeeeeeeeeeeeeeeeeeeee" }
		},
		    BookType::EBook => rsx! {
			div { "book icon eeeeeeeeeeeeeeeeeeeeeeeeeee" }
		},
		}
	}
}

This code has 2 tabs and 4 space in front of the BookType instead of 3 tabs.

❯ cargo fmt --check
Diff in /home/lukas/git/dx-fmt-test/src/main.rs:15:
        rsx! {
                "hello world"
                match value {
-                   BookType::AudioBook => rsx! {
+                       BookType::AudioBook => rsx! {
                        div { "audio icon eeeeeeeeeeeeeeeeeeeeeeeeee" }
                },
-                   BookType::EBook => rsx! {
+                       BookType::EBook => rsx! {
                        div { "book icon eeeeeeeeeeeeeeeeeeeeeeeeeee" }
                },
                }


❯ echo $?
1

Expected behavior

  • Create code with 3 spaces in front of BookType
  • Create code which is accepted by cargo fmt --check

Screenshots

Additional Information
I use dx fmt and cargo +nightly fmt both for formatting, since dx did not support the nightly features of cargo fmt.
Running dx fmt even without --all-code did change a lot cargo fmt nightly formatting.
So i regular run dx fmt first and then cargo +nightly fmt to be able to format rsx and get the cargo fmt nightly features.
To check if the code is formatted i run the following commands at the CI:

    - run: cargo +nightly fmt --all -- --check
    - run: cargo +stable fmt --all
    - run: dx fmt --check

However this fail because dx fmt format the at different way as cargo fmt.

Environment:

  • Dioxus version: dioxus 0.6.1 (was built without git repository)
  • Rust version: rustc 1.83.0 (90b35a623 2024-11-26)
  • OS info: Arch linux
  • App platform: web (but the others should be affected too)

Questionnaire

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

No branches or pull requests

1 participant