serde-deprecated / syntex

No longer maintained
112 stars 34 forks source link

Emit compiler diagnostics instead of panicking #78

Closed dtolnay closed 8 years ago

dtolnay commented 8 years ago

Fixes #66.

dtolnay commented 8 years ago

Before:

error: failed to run custom build command for `file:///github/serde/examples/serde-syntex-example v0.1.0`
Process didn't exit successfully: `/github/serde/examples/serde-syntex-example/target/debug/build/serde-syntex-example-9f0060ceb5920ffe/build-script-build` (exit code: 101)
--- stderr
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: "expected identifier, found `#`"', ../src/libcore/result.rs:746
note: Run with `RUST_BACKTRACE=1` for a backtrace.

After:

error: failed to run custom build command for `serde-syntex-example v0.1.0 (file:///github/serde/examples/serde-syntex-example)`
Process didn't exit successfully: `/github/serde/examples/serde-syntex-example/target/debug/build/serde-syntex-example-9f0060ceb5920ffe/build-script-build` (exit code: 101)
--- stderr
error: expected identifier, found `#`
 --> src/main.rs.in:7:8
  |>
7 |> struct #
  |>        ^
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Parse', ../src/libcore/result.rs:746
note: Run with `RUST_BACKTRACE=1` for a backtrace.
erickt commented 8 years ago

@homu r+ 958493a

erickt commented 8 years ago

<3

erickt commented 8 years ago

Drat, one downside to this is that this'll leak the syntex::Error type through the syntex::expand method. Think downstream projects should box up these error types so syntex doesn't leak?