DioxusLabs/dioxus · error

Syntax Error in line

Error message

Syntax Error in line {line} column {column}:
{err}

What it means

Conversion of a syn::parse_file failure into an anyhow error by format_syn_error, embedding the line and column of the offending span. Fires during `dx fmt` when the source passed to format_rust is not valid Rust — typically partially edited or incomplete code inside an rsx! macro — so prettyplease cannot reformat it.

Solutions

  1. There is an RSX syntax error at the reported line and column. Fix the syntax and re-run dx fmt.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/cli/src/cli/autoformat.rs:255 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/e671ca29c2bd3bb8. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/cli/autoformat.rs:255

        tab_spaces,
        split_line_attributes,
    ))
}

/// Format rust code using prettyplease
fn format_rust(input: &str) -> Result<String> {
    let syntax_tree = syn::parse_file(input)
        .map_err(format_syn_error)
        .context("Failed to parse Rust syntax")?;
    let output = prettyplease::unparse(&syntax_tree);
    Ok(output)
}

fn format_syn_error(err: syn::Error) -> Error {
    let start = err.span().start();
    let line = start.line;
    let column = start.column;
    anyhow::anyhow!("Syntax Error in line {line} column {column}:\n{err}")
}

#[tokio::test]
async fn test_auto_fmt() {
    let test_rsx = r#"
                    //



                        div {}


                    //
                    //
                    //

                    "#
    .to_string();

View on GitHub (pinned to 24f6a829df)