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

Incorrect span for public StructFields #26083

Closed
chellmuth opened this issue Jun 7, 2015 · 0 comments
Closed

Incorrect span for public StructFields #26083

chellmuth opened this issue Jun 7, 2015 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@chellmuth
Copy link
Contributor

Public StructFields spans do not cover the entire field declaration. This causes problems in tools like rustfmt that use the span to re-format the field (https://github.com/nrc/rustfmt/issues/95).

For example, a compile error to show the span:

struct Foo {
    pub bar: u8,
    pub bar: u8,
}

fn main() { }

I would expect to see the span start at pub:

loon:rust cjh$ rustc pub-struct-field-span.rs
pub-struct-field-span.rs:3:5: 3:16 error: field `bar` is already declared [E0124]
pub-struct-field-span.rs:3     pub bar: u8,
                               ^~~~~~~~~~~
pub-struct-field-span.rs:2:5: 2:16 note: previously declared here
pub-struct-field-span.rs:2     pub bar: u8,
                               ^~~~~~~~~~~
error: aborting due to previous error

Instead, I see:

loon:rust cjh$ rustc pub-struct-field-span.rs
pub-struct-field-span.rs:3:9: 3:16 error: field `bar` is already declared [E0124]
pub-struct-field-span.rs:3     pub bar: u8,
                                   ^~~~~~~
pub-struct-field-span.rs:2:9: 2:16 note: previously declared here
pub-struct-field-span.rs:2     pub bar: u8,
                                   ^~~~~~~
error: aborting due to previous error

Meta

loon:rust cjh$ rustc --version --verbose
rustc 1.2.0-nightly (613e57b44 2015-06-01) (built 2015-06-01)
binary: rustc
commit-hash: 613e57b448c88591b6076a8cea9799f1f3876687
commit-date: 2015-06-01
build-date: 2015-06-01
host: x86_64-apple-darwin
release: 1.2.0-nightly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

2 participants