diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-03-22 23:38:00 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-22 23:38:00 -0400 |
| commit | b5dad3a1ab28cbaacc4f71e56c063ed6be132eb0 (patch) | |
| tree | 4d848d78455bf724b9925a99956d6f55b2d9f123 | |
| parent | cc98dfc8d265a40c6e1463022b862ede01f4ed26 (diff) | |
| parent | 8a6ef505750152cf9034dfe26858b241221a3400 (diff) | |
| download | rust-b5dad3a1ab28cbaacc4f71e56c063ed6be132eb0.tar.gz rust-b5dad3a1ab28cbaacc4f71e56c063ed6be132eb0.zip | |
Rollup merge of #40542 - abonander:issue_40535, r=jseyfried
Correctly get source for metatdata-only crate type Closes #40535 However, I'm not sure how to approach writing a regression test since I'm still working on a reduced test case from the code that caused the ICE in the first place. It's not enough to have an unknown `extern crate` in a metadata crate, it depends on a few extra arguments but I'm not sure which yet. Also replaced the `unwrap()` with a more informative `expect()`. r? @jseyfried
| -rw-r--r-- | src/librustc_metadata/creader.rs | 3 | ||||
| -rw-r--r-- | src/test/run-make/issue-40535/Makefile | 11 | ||||
| -rw-r--r-- | src/test/run-make/issue-40535/bar.rs | 13 | ||||
| -rw-r--r-- | src/test/run-make/issue-40535/baz.rs | 11 | ||||
| -rw-r--r-- | src/test/run-make/issue-40535/foo.rs | 14 |
5 files changed, 51 insertions, 1 deletions
diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 5af4db60411..fcdb968dc06 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -236,7 +236,8 @@ impl<'a> CrateLoader<'a> { // path (this is a top-level dependency) as we don't want to // implicitly load anything inside the dependency lookup path. let prev_kind = source.dylib.as_ref().or(source.rlib.as_ref()) - .unwrap().1; + .or(source.rmeta.as_ref()) + .expect("No sources for crate").1; if ret.is_none() && (prev_kind == kind || prev_kind == PathKind::All) { ret = Some(cnum); } diff --git a/src/test/run-make/issue-40535/Makefile b/src/test/run-make/issue-40535/Makefile new file mode 100644 index 00000000000..7d513a86a7f --- /dev/null +++ b/src/test/run-make/issue-40535/Makefile @@ -0,0 +1,11 @@ +# The ICE occurred in the following situation: +# * `foo` declares `extern crate bar, baz`, depends only on `bar` (forgetting `baz` in `Cargo.toml`) +# * `bar` declares and depends on `extern crate baz` +# * All crates built in metadata-only mode (`cargo check`) +all: + # cc https://github.com/rust-lang/rust/issues/40623 + $(RUSTC) baz.rs --emit=metadata --out-dir=$(TMPDIR) + $(RUSTC) bar.rs --emit=metadata --extern baz=$(TMPDIR)/libbaz.rmeta --out-dir=$(TMPDIR) + $(RUSTC) foo.rs --emit=metadata --extern bar=$(TMPDIR)/libbar.rmeta --out-dir=$(TMPDIR) 2>&1 | \ + grep -vq "unexpectedly panicked" + # ^ Succeeds if it doesn't find the ICE message diff --git a/src/test/run-make/issue-40535/bar.rs b/src/test/run-make/issue-40535/bar.rs new file mode 100644 index 00000000000..4c22f181975 --- /dev/null +++ b/src/test/run-make/issue-40535/bar.rs @@ -0,0 +1,13 @@ +// Copyright 2017 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. + +#![crate_type = "lib"] + +extern crate baz; diff --git a/src/test/run-make/issue-40535/baz.rs b/src/test/run-make/issue-40535/baz.rs new file mode 100644 index 00000000000..737a918a039 --- /dev/null +++ b/src/test/run-make/issue-40535/baz.rs @@ -0,0 +1,11 @@ +// Copyright 2017 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. + +#![crate_type = "lib"] diff --git a/src/test/run-make/issue-40535/foo.rs b/src/test/run-make/issue-40535/foo.rs new file mode 100644 index 00000000000..53a8c8636b1 --- /dev/null +++ b/src/test/run-make/issue-40535/foo.rs @@ -0,0 +1,14 @@ +// Copyright 2017 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. + +#![crate_type = "lib"] + +extern crate bar; +extern crate baz; |
