about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIgor Matuszewski <Xanewok@gmail.com>2018-11-11 21:05:09 +0100
committerIgor Matuszewski <Xanewok@gmail.com>2018-11-11 21:42:20 +0100
commit04cc0d651e8b40dffbcd3865c1e2c2cfc1663911 (patch)
treefb18f2f346ba290f48039ffb6f6875181a0a2426
parent5a2ca1a6f18aa93d3120761f614ec2d39b4cb1ac (diff)
downloadrust-04cc0d651e8b40dffbcd3865c1e2c2cfc1663911.tar.gz
rust-04cc0d651e8b40dffbcd3865c1e2c2cfc1663911.zip
save-analysis: Don't panic for macro-generated use globs
Follow-up to
https://github.com/rust-lang/rust/commit/c2bb7cadf24e82b80f403c09e800fe5fad504caf.
-rw-r--r--src/librustc_save_analysis/dump_visitor.rs34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs
index 9bc3fbe7c24..0c0f50c1fd7 100644
--- a/src/librustc_save_analysis/dump_visitor.rs
+++ b/src/librustc_save_analysis/dump_visitor.rs
@@ -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) => {