Skip to content

Commit a277435

Browse files
committed
Rollup merge of rust-lang#55879 - Xanewok:dont-panic-with-globs, r=nrc
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
2 parents 5134d9c + 04cc0d6 commit a277435

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
@@ -1254,21 +1254,25 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
12541254
Vec::new()
12551255
};
12561256

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

0 commit comments

Comments
 (0)