about summary refs log tree commit diff
diff options
context:
space:
mode:
authorShotaro Yamada <sinkuu@sinkuu.xyz>2018-04-15 20:47:45 +0900
committerShotaro Yamada <sinkuu@sinkuu.xyz>2018-04-15 21:41:28 +0900
commitc3dc014378e855bf41fd75e5b4ff956b67766656 (patch)
tree762151275f4e41ba11d25dc445494d561d58f4b7
parent2c7e83f746297578c3f31a7b1440e30fdfd67c67 (diff)
downloadrust-c3dc014378e855bf41fd75e5b4ff956b67766656.tar.gz
rust-c3dc014378e855bf41fd75e5b4ff956b67766656.zip
Check generated save-analysis, instead of `bug!()`ing
Injected crates don't have extern info. Let's skip them.
-rw-r--r--src/librustc_save_analysis/lib.rs3
-rw-r--r--src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile2
-rw-r--r--src/test/run-make-fulldeps/save-analysis-rfc2126/validate_json.py17
3 files changed, 21 insertions, 1 deletions
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs
index 34a9b57c9dc..f494e982f7f 100644
--- a/src/librustc_save_analysis/lib.rs
+++ b/src/librustc_save_analysis/lib.rs
@@ -115,7 +115,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
             let span = match *self.tcx.extern_crate(n.as_def_id()) {
                 Some(ExternCrate { span, .. }) => span,
                 None => {
-                    bug!("no data for crate {}", n);
+                    debug!("Skipping crate {}, no data", n);
+                    continue;
                 }
             };
             let lo_loc = self.span_utils.sess.codemap().lookup_char_pos(span.lo());
diff --git a/src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile b/src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile
index 2f5ed6716d6..a132668ec7c 100644
--- a/src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile
+++ b/src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile
@@ -2,7 +2,9 @@
 
 all: extern_absolute_paths.rs extern_in_paths.rs krate2
 	$(RUSTC) extern_absolute_paths.rs -Zsave-analysis
+	cat $(TMPDIR)/save-analysis/extern_absolute_paths.json | "$(PYTHON)" validate_json.py
 	$(RUSTC) extern_in_paths.rs -Zsave-analysis
+	cat $(TMPDIR)/save-analysis/extern_in_paths.json | "$(PYTHON)" validate_json.py
 
 krate2: krate2.rs
 	$(RUSTC) $<
diff --git a/src/test/run-make-fulldeps/save-analysis-rfc2126/validate_json.py b/src/test/run-make-fulldeps/save-analysis-rfc2126/validate_json.py
new file mode 100644
index 00000000000..caab8d0d626
--- /dev/null
+++ b/src/test/run-make-fulldeps/save-analysis-rfc2126/validate_json.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+# Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+import sys
+import json
+
+crates = json.loads(sys.stdin.readline().strip())["prelude"]["external_crates"]
+assert any(map(lambda c: c["id"]["name"] == "krate2", crates))