Skip to content

InvalidDocError: Unexpected doc 'undefined' #39

@moritztim

Description

@moritztim

I get this error when trying to format a simple rust file:

fn main() {
    println!("Hello, world!");
}
[error] src/main.rs: InvalidDocError: Unexpected doc 'undefined', 
[error] Expected it to be 'string' or 'object'.
[error]     at traverseDoc (file:///project_path/node_modules/prettier/index.mjs:17474:13)
[error]     at propagateBreaks (file:///project_path/node_modules/prettier/index.mjs:17613:3)
[error]     at printDocToString (file:///project_path/node_modules/prettier/index.mjs:18200:3)
[error]     at coreFormat (file:///project_path/node_modules/prettier/index.mjs:20542:18)
[error]     at async formatWithCursor (file:///project_path/node_modules/prettier/index.mjs:20743:14)
[error]     at async formatFiles (file:///project_path/node_modules/prettier/internal/cli.mjs:4213:18)
[error]     at async main (file:///project_path/node_modules/prettier/internal/cli.mjs:4865:5)
[error]     at async Module.run (file:///project_path/node_modules/prettier/internal/cli.mjs:4811:5)

Package.json:

	"dependencies": {
		"prettier": "^3.5.3",
		"prettier-plugin-rust": "^0.1.9"
	}

Prettier config:

useTabs: true
proseWrap: never
printWidth: 80

trailingComma: all
plugins:
  - prettier-plugin-rust

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions