1
Fork 0

Fix spans for use view statements and their treatment in save-analysis

This commit is contained in:
Nick Cameron 2014-12-27 23:45:50 +13:00
parent 0201334439
commit 35a6f6247b
3 changed files with 9 additions and 8 deletions

View file

@ -1162,8 +1162,8 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
} }
match i.node { match i.node {
ast::ViewItemUse(ref path) => { ast::ViewItemUse(ref item) => {
match path.node { match item.node {
ast::ViewPathSimple(ident, ref path, id) => { ast::ViewPathSimple(ident, ref path, id) => {
let sub_span = self.span.span_for_last_ident(path.span); let sub_span = self.span.span_for_last_ident(path.span);
let mod_id = match self.lookup_type_ref(id) { let mod_id = match self.lookup_type_ref(id) {
@ -1184,7 +1184,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
// 'use' always introduces an alias, if there is not an explicit // 'use' always introduces an alias, if there is not an explicit
// one, there is an implicit one. // one, there is an implicit one.
let sub_span = let sub_span =
match self.span.sub_span_before_token(path.span, token::Eq) { match self.span.sub_span_after_keyword(item.span, keywords::As) {
Some(sub_span) => Some(sub_span), Some(sub_span) => Some(sub_span),
None => sub_span, None => sub_span,
}; };

View file

@ -294,8 +294,8 @@ impl<'a> SpanUtils<'a> {
} }
pub fn sub_span_after_keyword(&self, pub fn sub_span_after_keyword(&self,
span: Span, span: Span,
keyword: keywords::Keyword) -> Option<Span> { keyword: keywords::Keyword) -> Option<Span> {
let mut toks = self.retokenise_span(span); let mut toks = self.retokenise_span(span);
loop { loop {
let ts = toks.real_token(); let ts = toks.real_token();

View file

@ -5917,7 +5917,7 @@ impl<'a> Parser<'a> {
} }
/// Matches view_path : MOD? IDENT EQ non_global_path /// Matches view_path : MOD? non_global_path as IDENT
/// | MOD? non_global_path MOD_SEP LBRACE RBRACE /// | MOD? non_global_path MOD_SEP LBRACE RBRACE
/// | MOD? non_global_path MOD_SEP LBRACE ident_seq RBRACE /// | MOD? non_global_path MOD_SEP LBRACE ident_seq RBRACE
/// | MOD? non_global_path MOD_SEP STAR /// | MOD? non_global_path MOD_SEP STAR
@ -6029,7 +6029,7 @@ impl<'a> Parser<'a> {
} }
let mut rename_to = path[path.len() - 1u]; let mut rename_to = path[path.len() - 1u];
let path = ast::Path { let path = ast::Path {
span: mk_sp(lo, self.span.hi), span: mk_sp(lo, self.last_span.hi),
global: false, global: false,
segments: path.into_iter().map(|identifier| { segments: path.into_iter().map(|identifier| {
ast::PathSegment { ast::PathSegment {
@ -6041,7 +6041,8 @@ impl<'a> Parser<'a> {
if self.eat_keyword(keywords::As) { if self.eat_keyword(keywords::As) {
rename_to = self.parse_ident() rename_to = self.parse_ident()
} }
P(spanned(lo, self.last_span.hi, P(spanned(lo,
self.last_span.hi,
ViewPathSimple(rename_to, path, ast::DUMMY_NODE_ID))) ViewPathSimple(rename_to, path, ast::DUMMY_NODE_ID)))
} }