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

wrong span for error #739

Closed
Dushistov opened this issue Dec 31, 2019 · 1 comment · Fixed by #740
Closed

wrong span for error #739

Dushistov opened this issue Dec 31, 2019 · 1 comment · Fixed by #740

Comments

@Dushistov
Copy link

If compile and run code bellow with syn 1.0.11 it prints:

err expected : span LineColumn { line: 1, column: 0 } LineColumn { line: 1, column: 0 }

But error location is near String it is not 'line 1, column: 0'.
If fix syntax: _: String, and print spans of arguments of function b all spans are correct.
So something wrong with error span calculation.

fn main() {
    let code = r#"
impl Foo {
   fn b(a: i32, String) {}
}
"#;
    let ast = match syn::parse_file(code) {
        Ok(x) => x,
        Err(err) => {
            println!(
                "err {} span {:?} {:?}",
                err,
                err.span().start(),
                err.span().end()
            );
            return;
        }
    };
}
@dtolnay
Copy link
Owner

dtolnay commented Jan 1, 2020

Thanks! Fixed in 1.0.12.

Dushistov added a commit to Dushistov/flapigen-rs that referenced this issue Jan 1, 2020
Dushistov added a commit to Dushistov/flapigen-rs that referenced this issue Jan 1, 2020
Breaking changes because of `fn foo(String)` not supported anymore,
should be `fn foo(_: String)`.
Used syn 1.0.12 because of dtolnay/syn#739 .
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

Successfully merging a pull request may close this issue.

2 participants