Marwes / combine

A parser combinator library for Rust
https://docs.rs/combine/*/combine/
MIT License
1.29k stars 93 forks source link

`expected` error strings always quote what was expected, even if it isn't a literal #334

Closed epage closed 2 years ago

epage commented 2 years ago

toml_edit sets some expected for not what character is next but what grammar item is expected (e.g. "key").

This means they are quoted, like literals. See review comments on https://github.com/rust-lang/cargo/pull/10086

epage commented 2 years ago

I'd propose we have a

enum Item {
    Literal(String),
   Other(String),
}

(obviously some naming could be improved)

We could have some impl Froms to keep the API compatible.

I'm willing to implement this, just looking for a go ahead.

Marwes commented 2 years ago

It would be a breaking change to make this change to the "easy errors" now and I am not willing to do that for just this (the error handling could use an overhaul though). So you may need to implement your own errors, or convert the easy errors before displaying them.

epage commented 2 years ago

In looking to see if there was a way to do this without a breaking change, it turned out combine already has all the information it needs. In case you weren't referring to the formatting change as a breaking change (since most textual outputs are not considered stable and stability wasn't mentioned for #333), I am preparing a PR with the change. At least within combine's docs, it works exactly as expected!