-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustc --pretty=expanded outputs invalid syntax for #[derive(RustcDecodable)] #42213
Comments
The problem here, as far as I can tell, is a result of a combination of factors:
So the solutions are:
I'm not sure which is best here: fixing just 1 or 2 means other issues could slip by; fixing 3 seems like covering up the issue. 1 might be best for now, and if this issue re-emerges, then we can re-evaluate. |
On second thoughts, it seems reasonable for pprust to assume correct input. In that case, the correct fix would be: modify the closure printing code to omit return types of |
…ichton Fix implicit closure return type generation for libsyntax The `lambda` function for constructing closures in libsyntax was explicitly setting the return type to `_`, which resulted in incorrect corresponding syntax (as `|| -> _ x` is not valid, without the enclosing brackets). This meant the generated code, when printed, was invalid. I also took the opportunity to slightly improve the generated code for the `RustcEncodable::encode` method for unit structs. Fixes #42213.
Run
cargo rustc -- -Z unstable-options --pretty=expanded > lib-expanded.rs
rustc -Z parse-only lib-expanded.rs
With
Results
lib-expanded.rs:
Expected
rustc lib-expanded.rs
to succeed. Pretty printing should output valid rust syntax.Not sure if this is specific to
rustc_serialize
, I haven't tried to create a simpler testcase.The text was updated successfully, but these errors were encountered: