Skip to content

Commit d3fde84

Browse files
committed
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.
1 parent 37bd466 commit d3fde84

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/libsyntax/parse/attr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use ast;
12-
use codemap::{spanned, Spanned, mk_sp};
12+
use codemap::{spanned, Spanned, mk_sp, Span};
1313
use parse::common::*; //resolve bug?
1414
use parse::token;
1515
use parse::parser::Parser;
@@ -129,10 +129,10 @@ impl<'a> ParserAttr for Parser<'a> {
129129
self.parse_attribute(true)
130130
}
131131
token::DOC_COMMENT(s) => {
132+
// we need to get the position of this token before we bump.
133+
let Span { lo, hi, .. } = self.span;
132134
self.bump();
133-
::attr::mk_sugared_doc_attr(self.id_to_interned_str(s),
134-
self.span.lo,
135-
self.span.hi)
135+
::attr::mk_sugared_doc_attr(self.id_to_interned_str(s), lo, hi)
136136
}
137137
_ => {
138138
break;

0 commit comments

Comments
 (0)