Skip to content

Commit 90580ca

Browse files
Xanewoknikomatsakis
authored andcommitted
save-analysis: Don't panic for macro-generated use globs
Follow-up to c2bb7ca.
1 parent 396e009 commit 90580ca

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/librustc_save_analysis/dump_visitor.rs

+19-15
Original file line numberDiff line numberDiff line change
@@ -1256,21 +1256,25 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
12561256
Vec::new()
12571257
};
12581258

1259-
let sub_span =
1260-
self.span.sub_span_of_token(use_tree.span, token::BinOp(token::Star));
1261-
if !self.span.filter_generated(use_tree.span) {
1262-
let span =
1263-
self.span_from_span(sub_span.expect("No span found for use glob"));
1264-
self.dumper.import(&access, Import {
1265-
kind: ImportKind::GlobUse,
1266-
ref_id: None,
1267-
span,
1268-
alias_span: None,
1269-
name: "*".to_owned(),
1270-
value: names.join(", "),
1271-
parent,
1272-
});
1273-
self.write_sub_paths(&path);
1259+
// Otherwise it's a span with wrong macro expansion info, which
1260+
// we don't want to track anyway, since it's probably macro-internal `use`
1261+
if let Some(sub_span) =
1262+
self.span.sub_span_of_token(use_tree.span, token::BinOp(token::Star))
1263+
{
1264+
if !self.span.filter_generated(use_tree.span) {
1265+
let span = self.span_from_span(sub_span);
1266+
1267+
self.dumper.import(&access, Import {
1268+
kind: ImportKind::GlobUse,
1269+
ref_id: None,
1270+
span,
1271+
alias_span: None,
1272+
name: "*".to_owned(),
1273+
value: names.join(", "),
1274+
parent,
1275+
});
1276+
self.write_sub_paths(&path);
1277+
}
12741278
}
12751279
}
12761280
ast::UseTreeKind::Nested(ref nested_items) => {

0 commit comments

Comments
 (0)