mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-13 09:05:00 +00:00
Fix some cross crate existential type ICEs
This commit is contained in:
parent
70015373b4
commit
26edb28d31
@ -893,6 +893,9 @@ impl<'a, 'tcx> CrateMetadata {
|
||||
EntryKind::AssociatedType(container) => {
|
||||
(ty::AssociatedKind::Type, container, false)
|
||||
}
|
||||
EntryKind::AssociatedExistential(container) => {
|
||||
(ty::AssociatedKind::Existential, container, false)
|
||||
}
|
||||
_ => bug!("cannot get associated-item of `{:?}`", def_key)
|
||||
};
|
||||
|
||||
|
@ -680,6 +680,7 @@ impl<'a> Resolver<'a> {
|
||||
}
|
||||
module.populated.set(true);
|
||||
}
|
||||
Def::Existential(..) |
|
||||
Def::TraitAlias(..) => {
|
||||
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion));
|
||||
}
|
||||
|
@ -608,8 +608,8 @@ fn check_existential_types<'a, 'fcx, 'gcx, 'tcx>(
|
||||
if let ty::Opaque(def_id, substs) = ty.sty {
|
||||
trace!("check_existential_types: opaque_ty, {:?}, {:?}", def_id, substs);
|
||||
let generics = tcx.generics_of(def_id);
|
||||
// only check named existential types
|
||||
if generics.parent.is_none() {
|
||||
// only check named existential types defined in this crate
|
||||
if generics.parent.is_none() && def_id.is_local() {
|
||||
let opaque_node_id = tcx.hir().as_local_node_id(def_id).unwrap();
|
||||
if may_define_existential_type(tcx, fn_def_id, opaque_node_id) {
|
||||
trace!("check_existential_types may define. Generics: {:#?}", generics);
|
||||
|
13
src/test/ui/existential_types/auxiliary/cross_crate_ice.rs
Normal file
13
src/test/ui/existential_types/auxiliary/cross_crate_ice.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// Crate that exports an existential type. Used for testing cross-crate.
|
||||
|
||||
#![feature(const_fn)]
|
||||
#![crate_type="rlib"]
|
||||
|
||||
#![feature(existential_type)]
|
||||
|
||||
pub existential type Foo: std::fmt::Debug;
|
||||
|
||||
pub fn foo() -> Foo {
|
||||
5
|
||||
}
|
||||
|
22
src/test/ui/existential_types/auxiliary/cross_crate_ice2.rs
Normal file
22
src/test/ui/existential_types/auxiliary/cross_crate_ice2.rs
Normal file
@ -0,0 +1,22 @@
|
||||
// Crate that exports an existential type. Used for testing cross-crate.
|
||||
|
||||
#![feature(const_fn)]
|
||||
#![crate_type="rlib"]
|
||||
|
||||
#![feature(existential_type)]
|
||||
|
||||
pub trait View {
|
||||
type Tmp: Iterator<Item = u32>;
|
||||
|
||||
fn test(&self) -> Self::Tmp;
|
||||
}
|
||||
|
||||
pub struct X;
|
||||
|
||||
impl View for X {
|
||||
existential type Tmp: Iterator<Item = u32>;
|
||||
|
||||
fn test(&self) -> Self::Tmp {
|
||||
vec![1,2,3].into_iter()
|
||||
}
|
||||
}
|
16
src/test/ui/existential_types/cross_crate_ice.rs
Normal file
16
src/test/ui/existential_types/cross_crate_ice.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// aux-build:cross_crate_ice.rs
|
||||
// compile-pass
|
||||
|
||||
extern crate cross_crate_ice;
|
||||
|
||||
struct Bar(cross_crate_ice::Foo);
|
||||
|
||||
impl Bar {
|
||||
fn zero(&self) -> &cross_crate_ice::Foo {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = cross_crate_ice::foo();
|
||||
}
|
11
src/test/ui/existential_types/cross_crate_ice2.rs
Normal file
11
src/test/ui/existential_types/cross_crate_ice2.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// aux-build:cross_crate_ice2.rs
|
||||
// compile-pass
|
||||
|
||||
extern crate cross_crate_ice2;
|
||||
|
||||
use cross_crate_ice2::View;
|
||||
|
||||
fn main() {
|
||||
let v = cross_crate_ice2::X;
|
||||
v.test();
|
||||
}
|
Loading…
Reference in New Issue
Block a user