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 spans generated for top-level attributes #36530

Closed
KyleMayes opened this issue Sep 16, 2016 · 5 comments
Closed

Incorrect spans generated for top-level attributes #36530

KyleMayes opened this issue Sep 16, 2016 · 5 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@KyleMayes
Copy link
Contributor

@mikhail-m1

Pull request #36354 broke the spans for top-level attributes.

Self-contained example (that used to work):

#![feature(rustc_private)]

extern crate syntax;

use syntax::parse::{self, ParseSess};

fn main() {
    let session = ParseSess::new();
    let mut parser = parse::new_parser_from_source_str(&session, vec![], "".into(), "#[test]".into());
    let attr = parser.parse_attribute(false).unwrap();
    assert_eq!(attr.span.lo.0, 0);
    assert_eq!(attr.span.hi.0, 7);
}

Now I get:

thread 'main' panicked at 'assertion failed: `(left == right)` (left: `6`, right: `7`)', test.rs:12

So the generated spans are one byte too short.

Meta

rustc 1.13.0-nightly (6ffdda1ba 2016-09-14)
binary: rustc
commit-hash: 6ffdda1ba183c981d57e63b59c88184be449eee4
commit-date: 2016-09-14
host: x86_64-unknown-linux-gnu
release: 1.13.0-nightly
@TimNN
Copy link
Contributor

TimNN commented Sep 16, 2016

You can also easily see the effects by looking at the highlighting of the errors in

#[foo]
mod foo {   
    #![foo]
}

@TimNN TimNN added the A-diagnostics Area: Messages for errors, warnings, and lints label Sep 16, 2016
@mikhail-m1
Copy link
Contributor

Hi, I'll try fix it today or tomorrow

2016-09-16 13:20 GMT+03:00 Tim Neumann [email protected]:

You can also easily see the effects by looking at the highlighting
reported by the error of

#[foo]mod foo {
#![foo]
}


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#36530 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFZrXbg_Ku_lrvEvM7p_9yOGgakhZT5tks5qqm1xgaJpZM4J-xWn
.

Manishearth added a commit to Manishearth/rust that referenced this issue Sep 17, 2016
sophiajt pushed a commit to sophiajt/rust that referenced this issue Sep 21, 2016
sophiajt pushed a commit to sophiajt/rust that referenced this issue Sep 21, 2016
sophiajt pushed a commit to sophiajt/rust that referenced this issue Sep 22, 2016
@thepowersgang
Copy link
Contributor

The test for this issue is failing in the nightly builds - https://buildbot.rust-lang.org/builders/nightly-dist-rustc-linux/builds/659/steps/distcheck/logs/stdio

@TimNN
Copy link
Contributor

TimNN commented Sep 25, 2016

@thepowersgang: There's already a potential fix: #36678

@TimNN
Copy link
Contributor

TimNN commented Sep 25, 2016

(By the way, I'm gonna close this, since the PR fixing this has been merged).

@TimNN TimNN closed this as completed Sep 25, 2016
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

4 participants