Skip to content
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

A syntax error loses the span #879

Closed
antoyo opened this issue Aug 4, 2020 · 3 comments
Closed

A syntax error loses the span #879

antoyo opened this issue Aug 4, 2020 · 3 comments

Comments

@antoyo
Copy link

antoyo commented Aug 4, 2020

Hi.
There's a reproducer for this bug here.

When there is a syntax error, the span info is lost and that makes output errors like this:

 --> src/main.rs:8:1
  |
8 | #[hello_macro_derive]
  | ^^^^^^^^^^^^^^^^^^^^^
  | |
  | expected `i32`, found struct `std::string::String`
  | expected due to this

Thanks to fix the issue.

@mystor
Copy link
Collaborator

mystor commented Aug 4, 2020

This appears to be an instance of the compiler bug rust-lang/rust#43081, rather than being a bug in syn.

@dtolnay
Copy link
Owner

dtolnay commented Aug 4, 2020

Yeah this is rust-lang/rust#43081. If you insert println!("{:#?}", input) as the first line of hello_macro_derive you'll see that the spans all come in as #0 bytes(0..0) so it isn't syn losing them.

@dtolnay dtolnay closed this as completed Aug 4, 2020
@Aaron1011
Copy link
Contributor

The specific issue is tracked by rust-lang/rust#75734

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants