Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Check generated save-analysis, instead of bug!()ing
Injected crates don't have extern info. Let's skip them.
  • Loading branch information
sinkuu committed Apr 15, 2018
1 parent 2c7e83f commit c3dc014
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustc_save_analysis/lib.rs
Expand Up @@ -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());
Expand Down
2 changes: 2 additions & 0 deletions src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile
Expand Up @@ -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) $<
17 changes: 17 additions & 0 deletions 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))

0 comments on commit c3dc014

Please sign in to comment.