Skip to content

Commit d17f62d

Browse files
authored
Rollup merge of rust-lang#57836 - oli-obk:existential_crisis, r=estebank
Fix some cross crate existential type ICEs fixes rust-lang#53443
2 parents 5749bac + 5d6faf7 commit d17f62d

File tree

7 files changed

+66
-2
lines changed

7 files changed

+66
-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,12 @@
1+
// Crate that exports an existential type. Used for testing cross-crate.
2+
3+
#![crate_type="rlib"]
4+
5+
#![feature(existential_type)]
6+
7+
pub existential type Foo: std::fmt::Debug;
8+
9+
pub fn foo() -> Foo {
10+
5
11+
}
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Crate that exports an existential type. Used for testing cross-crate.
2+
3+
#![crate_type="rlib"]
4+
5+
#![feature(existential_type)]
6+
7+
pub trait View {
8+
type Tmp: Iterator<Item = u32>;
9+
10+
fn test(&self) -> Self::Tmp;
11+
}
12+
13+
pub struct X;
14+
15+
impl View for X {
16+
existential type Tmp: Iterator<Item = u32>;
17+
18+
fn test(&self) -> Self::Tmp {
19+
vec![1,2,3].into_iter()
20+
}
21+
}
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)