mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 11:44:28 +00:00
Fix spans for use
view statements and their treatment in save-analysis
This commit is contained in:
parent
0201334439
commit
35a6f6247b
@ -1162,8 +1162,8 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
||||
}
|
||||
|
||||
match i.node {
|
||||
ast::ViewItemUse(ref path) => {
|
||||
match path.node {
|
||||
ast::ViewItemUse(ref item) => {
|
||||
match item.node {
|
||||
ast::ViewPathSimple(ident, ref path, id) => {
|
||||
let sub_span = self.span.span_for_last_ident(path.span);
|
||||
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
|
||||
// one, there is an implicit one.
|
||||
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),
|
||||
None => sub_span,
|
||||
};
|
||||
|
@ -294,8 +294,8 @@ impl<'a> SpanUtils<'a> {
|
||||
}
|
||||
|
||||
pub fn sub_span_after_keyword(&self,
|
||||
span: Span,
|
||||
keyword: keywords::Keyword) -> Option<Span> {
|
||||
span: Span,
|
||||
keyword: keywords::Keyword) -> Option<Span> {
|
||||
let mut toks = self.retokenise_span(span);
|
||||
loop {
|
||||
let ts = toks.real_token();
|
||||
|
@ -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 ident_seq RBRACE
|
||||
/// | MOD? non_global_path MOD_SEP STAR
|
||||
@ -6029,7 +6029,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
let mut rename_to = path[path.len() - 1u];
|
||||
let path = ast::Path {
|
||||
span: mk_sp(lo, self.span.hi),
|
||||
span: mk_sp(lo, self.last_span.hi),
|
||||
global: false,
|
||||
segments: path.into_iter().map(|identifier| {
|
||||
ast::PathSegment {
|
||||
@ -6041,7 +6041,8 @@ impl<'a> Parser<'a> {
|
||||
if self.eat_keyword(keywords::As) {
|
||||
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)))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user