From d3fde8476b9cdce734dcec6b2003a482c5908235 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Thu, 22 May 2014 22:55:48 +1000 Subject: syntax: put the correct span on doc-comments inside a module. The position of the .bump call (before extracting the span fields) was causing a doc-comment to have the span of the next token, not itself. --- src/libsyntax/parse/attr.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 80ee459a62d..ef0004d6ee0 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -9,7 +9,7 @@ // except according to those terms. use ast; -use codemap::{spanned, Spanned, mk_sp}; +use codemap::{spanned, Spanned, mk_sp, Span}; use parse::common::*; //resolve bug? use parse::token; use parse::parser::Parser; @@ -129,10 +129,10 @@ impl<'a> ParserAttr for Parser<'a> { self.parse_attribute(true) } token::DOC_COMMENT(s) => { + // we need to get the position of this token before we bump. + let Span { lo, hi, .. } = self.span; self.bump(); - ::attr::mk_sugared_doc_attr(self.id_to_interned_str(s), - self.span.lo, - self.span.hi) + ::attr::mk_sugared_doc_attr(self.id_to_interned_str(s), lo, hi) } _ => { break; -- cgit 1.4.1-3-g733a5