Check generated save-analysis, instead of bug!()ing

Injected crates don't have extern info. Let's skip them.
This commit is contained in:
Shotaro Yamada 2018-04-15 20:47:45 +09:00
parent 2c7e83f746
commit c3dc014378
3 changed files with 21 additions and 1 deletions

View File

@ -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());

View File

@ -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) $<

View File

@ -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))