Skip to content

Commit

Permalink
Rollup merge of rust-lang#55879 - Xanewok:dont-panic-with-globs, r=nrc
Browse files Browse the repository at this point in the history
save-analysis: Don't panic for macro-generated use globs

Follow-up to rust-lang@c2bb7ca - as before, ignore the use globs in macro expansions.

Fixes rust-lang/rls#1117.
Closes rust-lang#55480.

r? @nrc
  • Loading branch information
pietroalbini authored Nov 12, 2018
2 parents 0c6fc22 + 04cc0d6 commit 35bb8bc
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 @@ -1254,21 +1254,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 35bb8bc

Please sign in to comment.