Skip to content

stdin formatting fails if mod file not found #562

Closed
@johannhof

Description

@johannhof
echo "mod abc; fn main(){let a =1\n; \n let b = 2;}" | rustfmt

result:

stdin:1:5: 1:8 error: file not found for module `abc`
stdin:1 mod abc; fn main(){let a =1
            ^~~

For file formatting it's quite okay since you have a location to search modules in, but obviously this behavior is not ideal when piping from stdin.

The error is generated by syntex_syntax. Maybe we can parse syntax items more granularly and ignore this kind of error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPanic, non-idempotency, invalid code, etc.p-high

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions