{"record":{"id":"e671ca29c2bd3bb8","repo":"DioxusLabs/dioxus","slug":"syntax-error-in-line-line-column-column-err","errorCode":null,"errorMessage":"Syntax Error in line {line} column {column}:\n{err}","messagePattern":"Syntax Error in line (.+?) column (.+?):\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/cli/autoformat.rs","lineNumber":255,"sourceCode":"        tab_spaces,\n        split_line_attributes,\n    ))\n}\n\n/// Format rust code using prettyplease\nfn format_rust(input: &str) -> Result<String> {\n    let syntax_tree = syn::parse_file(input)\n        .map_err(format_syn_error)\n        .context(\"Failed to parse Rust syntax\")?;\n    let output = prettyplease::unparse(&syntax_tree);\n    Ok(output)\n}\n\nfn format_syn_error(err: syn::Error) -> Error {\n    let start = err.span().start();\n    let line = start.line;\n    let column = start.column;\n    anyhow::anyhow!(\"Syntax Error in line {line} column {column}:\\n{err}\")\n}\n\n#[tokio::test]\nasync fn test_auto_fmt() {\n    let test_rsx = r#\"\n                    //\n\n\n\n                        div {}\n\n\n                    //\n                    //\n                    //\n\n                    \"#\n    .to_string();","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/cli/src/cli/autoformat.rs#L237-L273","documentation":"dx fmt formats Rust sources by parsing each file with syn::parse_file and re-printing with prettyplease. If a file is not valid Rust, format_rust maps the syn::Error through format_syn_error, producing a message with the 1-based line and column of the error span plus the parser's own description. Formatting of that file aborts and the command returns an error.","triggerScenarios":"Running dx fmt (autoformat) on a project where at least one .rs file has invalid Rust syntax — unclosed brace, stray token, truncated file. syn::parse_file fails and the span's line/column are reported.","commonSituations":"A half-saved or merge-conflicted file; generated code with syntax errors; running dx fmt before fixing errors that rust-analyzer/rustc already flagged.","solutions":["Open the file at the reported line and column and fix the syntax error described in {err}","Run cargo check for the same file to get rustc's fuller diagnostics on the same problem","If the file is generated or disposable, restore it (git checkout) and re-run dx fmt"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Fail fast with rustc's diagnostics before dx fmt\ncargo check --message-format=short 2>&1 | grep '^error' && echo 'fix syntax first' ","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep rust-analyzer clean before running dx fmt","Run cargo check in CI before any formatting step","Never leave merge-conflict markers or half-edited files in the tree when formatting"],"tags":["cli","format","syn","syntax-error"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}