Skip to content

Commit c3dc014

Browse files
committed
Check generated save-analysis, instead of bug!()ing
Injected crates don't have extern info. Let's skip them.
1 parent 2c7e83f commit c3dc014

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/librustc_save_analysis/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
115115
let span = match *self.tcx.extern_crate(n.as_def_id()) {
116116
Some(ExternCrate { span, .. }) => span,
117117
None => {
118-
bug!("no data for crate {}", n);
118+
debug!("Skipping crate {}, no data", n);
119+
continue;
119120
}
120121
};
121122
let lo_loc = self.span_utils.sess.codemap().lookup_char_pos(span.lo());

src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
all: extern_absolute_paths.rs extern_in_paths.rs krate2
44
$(RUSTC) extern_absolute_paths.rs -Zsave-analysis
5+
cat $(TMPDIR)/save-analysis/extern_absolute_paths.json | "$(PYTHON)" validate_json.py
56
$(RUSTC) extern_in_paths.rs -Zsave-analysis
7+
cat $(TMPDIR)/save-analysis/extern_in_paths.json | "$(PYTHON)" validate_json.py
68

79
krate2: krate2.rs
810
$(RUSTC) $<
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright 2018 The Rust Project Developers. See the COPYRIGHT
4+
# file at the top-level directory of this distribution and at
5+
# http://rust-lang.org/COPYRIGHT.
6+
#
7+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10+
# option. This file may not be copied, modified, or distributed
11+
# except according to those terms.
12+
13+
import sys
14+
import json
15+
16+
crates = json.loads(sys.stdin.readline().strip())["prelude"]["external_crates"]
17+
assert any(map(lambda c: c["id"]["name"] == "krate2", crates))

0 commit comments

Comments
 (0)