Skip to content

Commit

Permalink
save-analysis: Don't panic for macro-generated use globs
Browse files Browse the repository at this point in the history
Follow-up to
c2bb7ca.
  • Loading branch information
Xanewok authored and nikomatsakis committed Nov 20, 2018
1 parent 396e009 commit 90580ca
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,21 +1256,25 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
Vec::new()
};

let sub_span =
self.span.sub_span_of_token(use_tree.span, token::BinOp(token::Star));
if !self.span.filter_generated(use_tree.span) {
let span =
self.span_from_span(sub_span.expect("No span found for use glob"));
self.dumper.import(&access, Import {
kind: ImportKind::GlobUse,
ref_id: None,
span,
alias_span: None,
name: "*".to_owned(),
value: names.join(", "),
parent,
});
self.write_sub_paths(&path);
// Otherwise it's a span with wrong macro expansion info, which
// we don't want to track anyway, since it's probably macro-internal `use`
if let Some(sub_span) =
self.span.sub_span_of_token(use_tree.span, token::BinOp(token::Star))
{
if !self.span.filter_generated(use_tree.span) {
let span = self.span_from_span(sub_span);

self.dumper.import(&access, Import {
kind: ImportKind::GlobUse,
ref_id: None,
span,
alias_span: None,
name: "*".to_owned(),
value: names.join(", "),
parent,
});
self.write_sub_paths(&path);
}
}
}
ast::UseTreeKind::Nested(ref nested_items) => {
Expand Down

0 comments on commit 90580ca

Please sign in to comment.