Skip to content

Commit 26edb28

Browse files
committed
Fix some cross crate existential type ICEs
1 parent 7001537 commit 26edb28

File tree

7 files changed

+68
-2
lines changed

7 files changed

+68
-2
lines changed

src/librustc_metadata/decoder.rs

+3
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,9 @@ impl<'a, 'tcx> CrateMetadata {
893893
EntryKind::AssociatedType(container) => {
894894
(ty::AssociatedKind::Type, container, false)
895895
}
896+
EntryKind::AssociatedExistential(container) => {
897+
(ty::AssociatedKind::Existential, container, false)
898+
}
896899
_ => bug!("cannot get associated-item of `{:?}`", def_key)
897900
};
898901

src/librustc_resolve/build_reduced_graph.rs

+1
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ impl<'a> Resolver<'a> {
680680
}
681681
module.populated.set(true);
682682
}
683+
Def::Existential(..) |
683684
Def::TraitAlias(..) => {
684685
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion));
685686
}

src/librustc_typeck/check/wfcheck.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,8 @@ fn check_existential_types<'a, 'fcx, 'gcx, 'tcx>(
608608
if let ty::Opaque(def_id, substs) = ty.sty {
609609
trace!("check_existential_types: opaque_ty, {:?}, {:?}", def_id, substs);
610610
let generics = tcx.generics_of(def_id);
611-
// only check named existential types
612-
if generics.parent.is_none() {
611+
// only check named existential types defined in this crate
612+
if generics.parent.is_none() && def_id.is_local() {
613613
let opaque_node_id = tcx.hir().as_local_node_id(def_id).unwrap();
614614
if may_define_existential_type(tcx, fn_def_id, opaque_node_id) {
615615
trace!("check_existential_types may define. Generics: {:#?}", generics);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Crate that exports an existential type. Used for testing cross-crate.
2+
3+
#![feature(const_fn)]
4+
#![crate_type="rlib"]
5+
6+
#![feature(existential_type)]
7+
8+
pub existential type Foo: std::fmt::Debug;
9+
10+
pub fn foo() -> Foo {
11+
5
12+
}
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Crate that exports an existential type. Used for testing cross-crate.
2+
3+
#![feature(const_fn)]
4+
#![crate_type="rlib"]
5+
6+
#![feature(existential_type)]
7+
8+
pub trait View {
9+
type Tmp: Iterator<Item = u32>;
10+
11+
fn test(&self) -> Self::Tmp;
12+
}
13+
14+
pub struct X;
15+
16+
impl View for X {
17+
existential type Tmp: Iterator<Item = u32>;
18+
19+
fn test(&self) -> Self::Tmp {
20+
vec![1,2,3].into_iter()
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// aux-build:cross_crate_ice.rs
2+
// compile-pass
3+
4+
extern crate cross_crate_ice;
5+
6+
struct Bar(cross_crate_ice::Foo);
7+
8+
impl Bar {
9+
fn zero(&self) -> &cross_crate_ice::Foo {
10+
&self.0
11+
}
12+
}
13+
14+
fn main() {
15+
let _ = cross_crate_ice::foo();
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// aux-build:cross_crate_ice2.rs
2+
// compile-pass
3+
4+
extern crate cross_crate_ice2;
5+
6+
use cross_crate_ice2::View;
7+
8+
fn main() {
9+
let v = cross_crate_ice2::X;
10+
v.test();
11+
}

0 commit comments

Comments
 (0)