Skip to content

Incorrect spans generated for top-level attributes #36530

Closed
@KyleMayes

Description

@KyleMayes

@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions