rustc 1.30.0-dev
binary: rustc
commit-hash: b5590423e6ceb048dd7d792382e960d66b7615d2
commit-date: 2018-08-16
host: x86_64-pc-windows-msvc
release: 1.30.0-dev
LLVM version: 7.0
a/Cargo.toml
[package]
name = "a"
version = "0.1.0"
a/src/lib.rs
#![feature(existential_type)]
pub existential type Foo: std::fmt::Debug;
pub fn foo() -> Foo {
5
}
b/Cargo.toml
[package]
name = "b"
version = "0.1.0"
[dependencies]
a = { path = "../a" }
b/src/main.rs
extern crate a;
fn main() {
let _ = a::foo();
}
ICE
thread 'main' panicked at 'librustc_resolve\build_reduced_graph.rs:741: unexpected definition: Existential(DefId(9/0:3))', librustc\util\bug.rs:47:26
stack backtrace:
0: std::sys::windows::backtrace::unwind_backtrace
at C:\Stuff\Sources\rustsrc\src\libstd\sys\windows\backtrace\mod.rs:95
1: std::sys_common::backtrace::print
at C:\Stuff\Sources\rustsrc\src\libstd\sys_common\backtrace.rs:59
2: std::panicking::default_hook::{{closure}}
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:211
3: std::panicking::default_hook
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:227
4: rustc::util::common::panic_hook
at C:\Stuff\Sources\rustsrc\src\librustc\util\common.rs:51
5: std::panicking::rust_panic_with_hook
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:479
6: std::panicking::begin_panic<alloc::string::String>
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:409
7: rustc::util::bug::opt_span_bug_fmt::{{closure}}<syntax_pos::span_encoding::Span>
at C:\Stuff\Sources\rustsrc\src\librustc\util\bug.rs:47
8: rustc::ty::context::tls::with_opt::{{closure}}<closure,!>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:2008
9: rustc::ty::context::tls::with_context_opt<closure,!>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1939
10: rustc::ty::context::tls::with_opt<closure,!>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:2008
11: rustc::util::bug::opt_span_bug_fmt<syntax_pos::span_encoding::Span>
at C:\Stuff\Sources\rustsrc\src\librustc\util\bug.rs:42
12: rustc::util::bug::bug_fmt
at C:\Stuff\Sources\rustsrc\src\librustc\util\bug.rs:22
13: rustc_resolve::Resolver::populate_module_if_necessary
at C:\Stuff\Sources\rustsrc\src\librustc_resolve\build_reduced_graph.rs:813
14: rustc_resolve::Resolver::build_reduced_graph_for_item
at C:\Stuff\Sources\rustsrc\src\librustc_resolve\build_reduced_graph.rs:441
15: rustc_resolve::build_reduced_graph::{{impl}}::visit_item
at C:\Stuff\Sources\rustsrc\src\librustc_resolve\build_reduced_graph.rs:991
16: syntax::visit::walk_item<rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor>
at C:\Stuff\Sources\rustsrc\src\libsyntax\visit.rs:245
17: rustc_resolve::build_reduced_graph::{{impl}}::visit_item
at C:\Stuff\Sources\rustsrc\src\librustc_resolve\build_reduced_graph.rs:992
18: syntax::ext::expand::AstFragment::visit_with<rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor>
at C:\Stuff\Sources\rustsrc\src\libsyntax\ext\expand.rs:120
19: rustc_resolve::macros::{{impl}}::visit_ast_fragment_with_placeholders
at C:\Stuff\Sources\rustsrc\src\librustc_resolve\macros.rs:209
20: syntax::ext::expand::MacroExpander::collect_invocations
at C:\Stuff\Sources\rustsrc\src\libsyntax\ext\expand.rs:478
21: syntax::ext::expand::MacroExpander::expand_fragment
at C:\Stuff\Sources\rustsrc\src\libsyntax\ext\expand.rs:318
22: syntax::ext::expand::MacroExpander::expand_crate
at C:\Stuff\Sources\rustsrc\src\libsyntax\ext\expand.rs:292
23: rustc_driver::driver::phase_2_configure_and_expand_inner::{{closure}}<closure>
at C:\Stuff\Sources\rustsrc\src\librustc_driver\driver.rs:1006
24: rustc::util::common::time<syntax::ast::Crate,closure>
at C:\Stuff\Sources\rustsrc\src\librustc\util\common.rs:157
25: rustc_driver::driver::phase_2_configure_and_expand<closure>
at C:\Stuff\Sources\rustsrc\src\librustc_driver\driver.rs:764
26: rustc_driver::driver::compile_input
at C:\Stuff\Sources\rustsrc\src\librustc_driver\driver.rs:184
27: rustc_driver::run_compiler_with_pool
at C:\Stuff\Sources\rustsrc\src\librustc_driver\lib.rs:562
28: scoped_tls::ScopedKey<syntax::Globals>::set<syntax::Globals,closure,(core::result::Result<(), rustc::session::CompileIncomplete>, core::option::Option<rustc::session::Session>)>
at C:\Users\Arnavion\.cargo\registry\src\github.com-1ecc6299db9ec823\scoped-tls-0.1.2\src\lib.rs:155
29: std::panic::{{impl}}::call_once<(),closure>
at C:\Stuff\Sources\rustsrc\src\libstd\panic.rs:313
30: panic_unwind::__rust_maybe_catch_panic
at C:\Stuff\Sources\rustsrc\src\libpanic_unwind\lib.rs:102
31: std::panicking::try<(),std::panic::AssertUnwindSafe<closure>>
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:289
32: rustc_driver::run<closure>
at C:\Stuff\Sources\rustsrc\src\librustc_driver\lib.rs:187
33: rustc_driver::main
at C:\Stuff\Sources\rustsrc\src\librustc_driver\lib.rs:1737
34: std::rt::lang_start::{{closure}}<()>
at C:\Stuff\Sources\rustsrc\src\libstd\rt.rs:74
35: std::panicking::try::do_call<closure,i32>
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:310
36: panic_unwind::__rust_maybe_catch_panic
at C:\Stuff\Sources\rustsrc\src\libpanic_unwind\lib.rs:102
37: std::panicking::try<i32,closure>
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:289
38: std::rt::lang_start_internal
at C:\Stuff\Sources\rustsrc\src\libstd\rt.rs:58
39: main
40: __scrt_common_main_seh
at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283
41: BaseThreadInitThunk
42: RtlUserThreadStart
query stack during panic:
end of query stack
error: internal compiler error: unexpected panic
Resolver::build_reduced_graph_for_external_crate_def needs an arm for Def::Existential ? @oli-obk
Edit: Easy playground repro
Oops. Yea. I assumed this would work since impl Trait works.
Is the fix just to have self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion)); ? I added that and it passes the repro in the OP, but my real code triggers another ICE at:
where the as_local_node_id returns None
If you think the fix for this ICE is just that one self.define() call, I can start making a minimal repro for this second ICE too.
I think they are closely related. We should probably run
{
intravisit::walk_ty(self, ty);
return;
}
in case as_local_node_id returns None. A repro for that would be nice though. It should probably suffice to add some lifetimes to the existential type or its concrete type.
My real code's existential types do not have lifetimes, though they do have 'static bounds.
pub existential type GetResponse: Future<Output = crate::Result<crate::Mod>> + 'static;
pub existential type DownloadResponse: Stream<Item = crate::Result<crate::reqwest_async::Chunk>> + 'static;
Adding 'static bounds to the OP code did not repro the same crash.
The concrete type for the first one is compiler-created because it's the return type of an async block.
pub fn get(&self, mod_name: &factorio_mods_common::ModName) -> GetResponse {
...
async {
....
}
}
I believe this is sugar for std::future::GenFuture, so that should also not have any lifetimes.
The second one's concrete type is my own Stream impl that also does not have lifetimes.
It'll take me some time to get a repro because something is broken with the rustc I built locally (it started hitting #53469 even though it was fine before, not sure why). If you want you can find the real code at https://github.com/Arnavion/fac-rs/tree/3a6afed4. The existential types are in the factorio-mods-web crate and imported by the workspace root crate. It won't compile because I'm still in the process of migrating it to std::future, but atleast it shouldn't ICE.
factorio-mods-web
Rust + factorio? <3
It'll take me some time to get a repro because something is broken with the rustc I built locally
the issue you are hitting is that a delay_span_bug is hidden from you. I'm fixing that later today
@oli-obk The #53469 I started hitting was because of two different versions of libsyntax_pos in stage1 builds, as I described here. So with stage2 builds I don't have that problem,
So I've got a repro for the issue where as_local_node_id returns None. It happens when using the imported existential type in a struct or enum definition, like:
b/src/main.rs
extern crate a;
struct Bar(a::Foo);
fn main() {
}
ICE
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore\option.rs:345:21
stack backtrace:
0: std::sys::windows::backtrace::unwind_backtrace
at C:\Stuff\Sources\rustsrc\src\libstd\sys\windows\backtrace\mod.rs:95
1: std::sys_common::backtrace::print
at C:\Stuff\Sources\rustsrc\src\libstd\sys_common\backtrace.rs:59
2: std::panicking::default_hook::{{closure}}
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:211
3: std::panicking::default_hook
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:227
4: rustc::util::common::panic_hook
at C:\Stuff\Sources\rustsrc\src\librustc\util\common.rs:51
5: std::panicking::rust_panic_with_hook
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:479
6: std::panicking::continue_panic_fmt
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:390
7: std::panicking::rust_begin_panic
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:325
8: core::panicking::panic_fmt
at C:\Stuff\Sources\rustsrc\src\libcore\panicking.rs:77
9: core::panicking::panic
at C:\Stuff\Sources\rustsrc\src\libcore\panicking.rs:52
10: rustc::middle::resolve_lifetime::{{impl}}::visit_ty
at C:\Stuff\Sources\rustsrc\src\librustc\middle\resolve_lifetime.rs:626
11: rustc::hir::intravisit::walk_item<rustc::middle::resolve_lifetime::LifetimeContext>
at C:\Stuff\Sources\rustsrc\src\librustc\hir\intravisit.rs:539
12: rustc::middle::resolve_lifetime::{{impl}}::visit_item
at C:\Stuff\Sources\rustsrc\src\librustc\middle\resolve_lifetime.rs:539
13: rustc::middle::resolve_lifetime::resolve_lifetimes
at C:\Stuff\Sources\rustsrc\src\librustc\middle\resolve_lifetime.rs:392
14: rustc::ty::query::{{impl}}::compute
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:820
15: rustc::ty::context::tls::with_context<closure,alloc::rc::Rc<rustc::middle::privacy::AccessLevels<syntax::ast::NodeId>>>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1953
16: rustc::dep_graph::graph::DepGraph::with_task_impl<rustc::ty::context::TyCtxt,rustc::hir::def_id::CrateNum,alloc::rc::Rc<rustc::middle::resolve_lifetime::ResolveLifetimes>>
at C:\Stuff\Sources\rustsrc\src\librustc\dep_graph\graph.rs:266
17: rustc::ty::context::tls::with_related_context<closure,(alloc::rc::Rc<rustc::middle::resolve_lifetime::ResolveLifetimes>, rustc::dep_graph::graph::DepNodeIndex)>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1964
18: rustc::ty::context::TyCtxt::force_query_with_job<rustc::ty::query::queries::resolve_lifetimes>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:543
19: rustc::ty::context::TyCtxt::get_query<rustc::ty::query::queries::resolve_lifetimes>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:640
20: core::ops::function::FnOnce::call_once<closure,(rustc::ty::context::TyCtxt, rustc::hir::def_id::DefIndex)>
at C:\Stuff\Sources\rustsrc\src\libcore\ops\function.rs:238
21: rustc::ty::query::{{impl}}::compute
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:820
22: rustc::ty::context::tls::with_context<closure,alloc::rc::Rc<rustc::middle::privacy::AccessLevels<syntax::ast::NodeId>>>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1953
23: rustc::dep_graph::graph::DepGraph::with_task_impl<rustc::ty::context::TyCtxt,rustc::hir::def_id::DefIndex,core::option::Option<alloc::rc::Rc<std::collections::hash::map::HashMap<rustc::hir::ItemLocalId, alloc::rc::Rc<alloc::vec::Vec<rustc::middle::resolve_lifetime::Set1<rustc::middle::resolve_lifetime::Region>>>, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>>>>
at C:\Stuff\Sources\rustsrc\src\librustc\dep_graph\graph.rs:266
24: rustc::ty::context::tls::with_related_context<closure,(core::option::Option<alloc::rc::Rc<std::collections::hash::map::HashMap<rustc::hir::ItemLocalId, alloc::rc::Rc<alloc::vec::Vec<rustc::middle::resolve_lifetime::Set1<rustc::middle::resolve_lifetime::Region>>>, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>>>, rustc::dep_graph::graph::DepNodeIndex)>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1964
25: rustc::ty::context::TyCtxt::force_query_with_job<rustc::ty::query::queries::object_lifetime_defaults_map>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:543
26: rustc::ty::context::TyCtxt::get_query<rustc::ty::query::queries::object_lifetime_defaults_map>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:640
27: rustc::ty::context::TyCtxt::object_lifetime_defaults
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:2787
28: rustc_typeck::collect::generics_of
at C:\Stuff\Sources\rustsrc\src\librustc_typeck\collect.rs:915
29: rustc::ty::query::__query_compute::generics_of<closure,rustc::ty::Generics*>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:790
30: rustc::ty::query::{{impl}}::compute
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:820
31: rustc::ty::context::tls::with_context<closure,alloc::rc::Rc<rustc::traits::specialize::specialization_graph::Graph>>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1953
32: rustc::dep_graph::graph::DepGraph::with_task_impl<rustc::ty::context::TyCtxt,rustc::hir::def_id::DefId,rustc::ty::Generics*>
at C:\Stuff\Sources\rustsrc\src\librustc\dep_graph\graph.rs:266
33: rustc::ty::context::tls::with_related_context<closure,(rustc::ty::Generics*, rustc::dep_graph::graph::DepNodeIndex)>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1964
34: rustc::ty::context::TyCtxt::force_query_with_job<rustc::ty::query::queries::generics_of>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:543
35: rustc::ty::context::TyCtxt::get_query<rustc::ty::query::queries::generics_of>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:640
36: rustc::ty::context::TyCtxt::generics_of
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:869
37: rustc_typeck::collect::{{impl}}::visit_item
at C:\Stuff\Sources\rustsrc\src\librustc_typeck\collect.rs:113
38: rustc::hir::Crate::visit_all_item_likes<rustc::hir::itemlikevisit::DeepVisitor<rustc_typeck::collect::CollectItemTypesVisitor>>
at C:\Stuff\Sources\rustsrc\src\librustc\hir\mod.rs:719
39: rustc::util::common::time<(),closure>
at C:\Stuff\Sources\rustsrc\src\librustc\util\common.rs:157
40: rustc_typeck::check_crate
at C:\Stuff\Sources\rustsrc\src\librustc_typeck\lib.rs:342
41: rustc::ty::context::tls::enter_context<closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, alloc::boxed::Box<Any>, rustc::dep_graph::graph::DepGraph), rustc::session::CompileIncomplete>, rustc::session::CompileIncomplete>>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1868
42: std::thread::local::LocalKey<core::cell::Cell<fn(syntax_pos::span_encoding::Span, mut core::fmt::Formatter*) -> core::result::Result<(), core::fmt::Error>>>::with<core::cell::Cell<fn(syntax_pos::span_encoding::Span, mut core::fmt::Formatter*) -> core::result::Result<(), core::fmt::Error>>,closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, alloc::boxed
::Box<Any>, rustc::dep_graph::graph::DepGraph), rustc::session::CompileIncomplete>, rustc::session::CompileIncomplete>>
at C:\Stuff\Sources\rustsrc\src\libstd\thread\local.rs:248
43: rustc::ty::context::TyCtxt::create_and_enter<closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, alloc::boxed::Box<Any>, rustc::dep_graph::graph::DepGraph), rustc::session::CompileIncomplete>, rustc::session::CompileIncomplete>>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1186
44: rustc_driver::driver::compile_input
at C:\Stuff\Sources\rustsrc\src\librustc_driver\driver.rs:285
45: rustc_driver::run_compiler_with_pool
at C:\Stuff\Sources\rustsrc\src\librustc_driver\lib.rs:562
46: scoped_tls::ScopedKey<syntax::Globals>::set<syntax::Globals,closure,(core::result::Result<(), rustc::session::CompileIncomplete>, core::option::Option<rustc::session::Session>)>
at C:\Users\Arnavion\.cargo\registry\src\github.com-1ecc6299db9ec823\scoped-tls-0.1.2\src\lib.rs:155
47: std::panic::{{impl}}::call_once<(),closure>
at C:\Stuff\Sources\rustsrc\src\libstd\panic.rs:313
48: panic_unwind::__rust_maybe_catch_panic
at C:\Stuff\Sources\rustsrc\src\libpanic_unwind\lib.rs:102
49: std::panicking::try<(),std::panic::AssertUnwindSafe<closure>>
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:289
50: rustc_driver::run<closure>
at C:\Stuff\Sources\rustsrc\src\librustc_driver\lib.rs:187
51: rustc_driver::main
at C:\Stuff\Sources\rustsrc\src\librustc_driver\lib.rs:1737
52: std::rt::lang_start::{{closure}}<()>
at C:\Stuff\Sources\rustsrc\src\libstd\rt.rs:74
53: std::panicking::try::do_call<closure,i32>
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:310
54: panic_unwind::__rust_maybe_catch_panic
at C:\Stuff\Sources\rustsrc\src\libpanic_unwind\lib.rs:102
55: std::panicking::try<i32,closure>
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:289
56: std::rt::lang_start_internal
at C:\Stuff\Sources\rustsrc\src\libstd\rt.rs:58
57: main
58: __scrt_common_main_seh
at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:288
59: BaseThreadInitThunk
60: RtlUserThreadStart
query stack during panic:
#0 [resolve_lifetimes] resolving lifetimes
#1 [object_lifetime_defaults_map] looking up lifetime defaults for a region
#2 [generics_of] processing `Bar`
end of query stack
Your suggestion did fix that error by the way.
--- a/src/librustc/middle/resolve_lifetime.rs
+++ b/src/librustc/middle/resolve_lifetime.rs
@@ -623,7 +623,13 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
}
hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => {
if let Def::Existential(exist_ty_did) = path.def {
- let id = self.tcx.hir.as_local_node_id(exist_ty_did).unwrap();
+ let id = match self.tcx.hir.as_local_node_id(exist_ty_did) {
+ Some(id) => id,
+ None => {
+ intravisit::walk_ty(self, ty);
+ return;
+ },
+ };
// Resolve the lifetimes in the bounds to the lifetime defs in the generics.
// `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to
With the above patch, there is a new ICE when using the field inside an inherent method.
extern crate a;
struct Bar(a::Foo);
impl Bar {
fn zero(&self) -> &a::Foo {
&self.0
}
}
fn main() {
}
ICE
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore\option.rs:345:21
stack backtrace:
0: std::sys::windows::backtrace::unwind_backtrace
at C:\Stuff\Sources\rustsrc\src\libstd\sys\windows\backtrace\mod.rs:95
1: std::sys_common::backtrace::print
at C:\Stuff\Sources\rustsrc\src\libstd\sys_common\backtrace.rs:59
2: std::panicking::default_hook::{{closure}}
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:211
3: std::panicking::default_hook
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:227
4: rustc::util::common::panic_hook
at C:\Stuff\Sources\rustsrc\src\librustc\util\common.rs:51
5: std::panicking::rust_panic_with_hook
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:479
6: std::panicking::continue_panic_fmt
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:390
7: std::panicking::rust_begin_panic
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:325
8: core::panicking::panic_fmt
at C:\Stuff\Sources\rustsrc\src\libcore\panicking.rs:77
9: core::panicking::panic
at C:\Stuff\Sources\rustsrc\src\libcore\panicking.rs:52
10: rustc::ty::fold::{{impl}}::fold_ty<closure,closure>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\fold.rs:221
11: rustc::ty::structural_impls::{{impl}}::super_fold_with<rustc::ty::fold::BottomUpFolder<closure, closure>>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\structural_impls.rs:851
12: rustc::ty::fold::{{impl}}::fold_ty<closure,closure>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\fold.rs:219
13: rustc_typeck::check::wfcheck::check_where_clauses
at C:\Stuff\Sources\rustsrc\src\librustc_typeck\check\wfcheck.rs:503
14: rustc_typeck::check::wfcheck::check_fn_or_method
at C:\Stuff\Sources\rustsrc\src\librustc_typeck\check\wfcheck.rs:544
15: rustc::ty::context::tls::with_related_context<closure,()>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1964
16: rustc::infer::InferCtxtBuilder::enter<closure,()>
at C:\Stuff\Sources\rustsrc\src\librustc\infer\mod.rs:469
17: rustc_typeck::check::wfcheck::check_associated_item
at C:\Stuff\Sources\rustsrc\src\librustc_typeck\check\wfcheck.rs:182
18: rustc_typeck::check::wfcheck::check_impl_item
at C:\Stuff\Sources\rustsrc\src\librustc_typeck\check\wfcheck.rs:174
19: rustc::ty::query::{{impl}}::compute
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:820
20: rustc::ty::context::tls::with_context<closure,()>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1953
21: rustc::dep_graph::graph::DepGraph::with_task_impl<rustc::ty::context::TyCtxt,rustc::hir::def_id::DefId,()>
at C:\Stuff\Sources\rustsrc\src\librustc\dep_graph\graph.rs:266
22: rustc::ty::context::tls::with_related_context<closure,((), rustc::dep_graph::graph::DepNodeIndex)>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1964
23: rustc::ty::context::TyCtxt::force_query_with_job<rustc::ty::query::queries::check_impl_item_well_formed>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:543
24: rustc::ty::context::TyCtxt::get_query<rustc::ty::query::queries::check_impl_item_well_formed>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:640
25: rustc::ty::context::TyCtxt::ensure_query<rustc::ty::query::queries::check_impl_item_well_formed>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\query\plumbing.rs:602
26: rustc_typeck::check::wfcheck::{{impl}}::visit_impl_item
at C:\Stuff\Sources\rustsrc\src\librustc_typeck\check\wfcheck.rs:934
27: rustc::hir::Crate::visit_all_item_likes<rustc::hir::itemlikevisit::DeepVisitor<rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor>>
at C:\Stuff\Sources\rustsrc\src\librustc\hir\mod.rs:727
28: rustc::session::Session::track_errors<closure,()>
at C:\Stuff\Sources\rustsrc\src\librustc\session\mod.rs:320
29: rustc::util::common::time<core::result::Result<(), rustc::util::common::ErrorReported>,closure>
at C:\Stuff\Sources\rustsrc\src\librustc\util\common.rs:157
30: rustc_typeck::check_crate
at C:\Stuff\Sources\rustsrc\src\librustc_typeck\lib.rs:368
31: rustc::ty::context::tls::enter_context<closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, alloc::boxed::Box<Any>, rustc::dep_graph::graph::DepGraph), rustc::session::CompileIncomplete>, rustc::session::CompileIncomplete>>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1868
32: std::thread::local::LocalKey<core::cell::Cell<fn(syntax_pos::span_encoding::Span, mut core::fmt::Formatter*) -> core::result::Result<(), core::fmt::Error>>>::with<core::cell::Cell<fn(syntax_pos::span_encoding::Span, mut core::fmt::Formatter*) -> core::result::Result<(), core::fmt::Error>>,closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, alloc::boxed::Box<Any>, rustc::dep_graph::graph::DepGraph), rustc::session::CompileIncomplete>, rustc::session::CompileIncomplete>>
at C:\Stuff\Sources\rustsrc\src\libstd\thread\local.rs:248
33: rustc::ty::context::TyCtxt::create_and_enter<closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, alloc::boxed::Box<Any>, rustc::dep_graph::graph::DepGraph), rustc::session::CompileIncomplete>, rustc::session::CompileIncomplete>>
at C:\Stuff\Sources\rustsrc\src\librustc\ty\context.rs:1186
34: rustc_driver::driver::compile_input
at C:\Stuff\Sources\rustsrc\src\librustc_driver\driver.rs:285
35: rustc_driver::run_compiler_with_pool
at C:\Stuff\Sources\rustsrc\src\librustc_driver\lib.rs:562
36: scoped_tls::ScopedKey<syntax::Globals>::set<syntax::Globals,closure,(core::result::Result<(), rustc::session::CompileIncomplete>, core::option::Option<rustc::session::Session>)>
at C:\Users\Arnavion\.cargo\registry\src\github.com-1ecc6299db9ec823\scoped-tls-0.1.2\src\lib.rs:155
37: std::panic::{{impl}}::call_once<(),closure>
at C:\Stuff\Sources\rustsrc\src\libstd\panic.rs:313
38: panic_unwind::__rust_maybe_catch_panic
at C:\Stuff\Sources\rustsrc\src\libpanic_unwind\lib.rs:102
39: std::panicking::try<(),std::panic::AssertUnwindSafe<closure>>
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:289
40: rustc_driver::run<closure>
at C:\Stuff\Sources\rustsrc\src\librustc_driver\lib.rs:187
41: rustc_driver::main
at C:\Stuff\Sources\rustsrc\src\librustc_driver\lib.rs:1737
42: std::rt::lang_start::{{closure}}<()>
at C:\Stuff\Sources\rustsrc\src\libstd\rt.rs:74
43: std::panicking::try::do_call<closure,i32>
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:310
44: panic_unwind::__rust_maybe_catch_panic
at C:\Stuff\Sources\rustsrc\src\libpanic_unwind\lib.rs:102
45: std::panicking::try<i32,closure>
at C:\Stuff\Sources\rustsrc\src\libstd\panicking.rs:289
46: std::rt::lang_start_internal
at C:\Stuff\Sources\rustsrc\src\libstd\rt.rs:58
47: main
48: __scrt_common_main_seh
at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:288
49: BaseThreadInitThunk
50: RtlUserThreadStart
query stack during panic:
#0 [check_impl_item_well_formed] processing `Bar::zero`
end of query stack
For me another variant of this issues is blocker:
a/Cargo.toml and b/Cargo.toml - is same
a/src/lib.rs:
#![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()
}
}
and b/src/main.rs:
extern crate a;
use a::View;
fn main() {
let v = a::X;
v.test();
}
ICE
error: internal compiler error: librustc_metadata/decoder.rs:834: cannot get associated-item of `DefKey { parent: Some(DefIndex(0:7)), disambiguated_data: DisambiguatedDefPathData { data: AssocExistentialInImpl("Tmp"), disambiguator: 0 } }`
thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:586:9
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::print
at libstd/sys_common/backtrace.rs:71
at libstd/sys_common/backtrace.rs:59
2: std::panicking::default_hook::{{closure}}
at libstd/panicking.rs:211
3: std::panicking::default_hook
at libstd/panicking.rs:227
4: rustc::util::common::panic_hook
5: std::panicking::rust_panic_with_hook
at libstd/panicking.rs:481
6: std::panicking::begin_panic
7: rustc_errors::Handler::bug
8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
9: rustc::ty::context::tls::with_opt::{{closure}}
10: rustc::ty::context::tls::with_context_opt
11: rustc::ty::context::tls::with_opt
12: rustc::util::bug::opt_span_bug_fmt
13: rustc::util::bug::bug_fmt
14: rustc_metadata::decoder::<impl rustc_metadata::cstore::CrateMetadata>::get_associated_item
15: rustc_metadata::cstore_impl::provide_extern::associated_item
16: rustc::ty::query::__query_compute::associated_item
17: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::associated_item<'tcx>>::compute
18: rustc::ty::context::tls::with_context
19: rustc::dep_graph::graph::DepGraph::with_task_impl
20: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
21: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
22: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
23: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::next
24: rustc::traits::project::assoc_ty_def
25: rustc::infer::InferCtxt::commit_if_ok
26: rustc::traits::project::opt_normalize_projection_type
27: rustc::traits::project::normalize_projection_type
28: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
29: <rustc_data_structures::accumulate_vec::AccumulateVec<A> as core::iter::traits::FromIterator<<A as rustc_data_structures::array_vec::Array>::Element>>::from_iter
30: rustc::ty::fold::TypeFoldable::fold_with
31: rustc::infer::InferCtxt::partially_normalize_associated_types_in
32: rustc_typeck::check::method::confirm::ConfirmContext::confirm
33: rustc_typeck::check::FnCtxt::check_expr_kind
34: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
35: rustc_typeck::check::FnCtxt::check_block_with_expected
36: rustc_typeck::check::FnCtxt::check_expr_kind
37: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
38: rustc_typeck::check::FnCtxt::check_return_expr
39: rustc_typeck::check::check_fn
40: rustc::ty::context::tls::with_related_context
41: rustc::infer::InferCtxtBuilder::enter
42: rustc_typeck::check::typeck_tables_of
43: rustc::ty::query::__query_compute::typeck_tables_of
44: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_tables_of<'tcx>>::compute
45: rustc::ty::context::tls::with_context
46: rustc::dep_graph::graph::DepGraph::with_task_impl
47: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
48: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
49: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
50: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
51: rustc_typeck::check::typeck_item_bodies
52: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_item_bodies<'tcx>>::compute
53: rustc::ty::context::tls::with_context
54: rustc::dep_graph::graph::DepGraph::with_task_impl
55: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
56: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
57: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
58: rustc_typeck::check_crate
59: rustc::ty::context::tls::enter_context
60: <std::thread::local::LocalKey<T>>::with
61: rustc::ty::context::TyCtxt::create_and_enter
62: rustc_driver::driver::compile_input
63: rustc_driver::run_compiler_with_pool
64: <scoped_tls::ScopedKey<T>>::set
65: <scoped_tls::ScopedKey<T>>::set
66: syntax::with_globals
67: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
68: __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:102
69: rustc_driver::run
70: rustc_driver::main
71: std::rt::lang_start::{{closure}}
72: std::panicking::try::do_call
at libstd/rt.rs:59
at libstd/panicking.rs:310
73: __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:102
74: std::rt::lang_start_internal
at libstd/panicking.rs:289
at libstd/panic.rs:392
at libstd/rt.rs:58
75: main
76: __libc_start_main
77: <unknown>
query stack during panic:
#0 [associated_item] processing `<a::X as a::View>::Tmp`
#1 [typeck_tables_of] processing `main`
#2 [typeck_item_bodies] type-checking all item bodies
end of query stack
Is there any progress on this?
@Arnavion how do you feel about making a PR with your patch that has a partial fix? It looks like that would be enough to unblock me from using existential types in my project.
A bunch of stuff changed with oli-obk's recent change so the second patch won't apply directly. I'll retest and put up a fork.
@tikue
For the first ICE (function that returns existential type in crate A called from crate B), the patch (on top of 46880f41b7aeb897b8245474196bba9dc11f0e88) is
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs
index 25a7ff9cd3..02a28a1e2f 100644
--- a/src/librustc_resolve/build_reduced_graph.rs
+++ b/src/librustc_resolve/build_reduced_graph.rs
@@ -736,6 +736,9 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
Def::Macro(..) => {
self.define(parent, ident, MacroNS, (def, vis, DUMMY_SP, expansion));
}
+ Def::Existential(..) => {
+ self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion));
+ }
_ => bug!("unexpected definition: {:?}", def)
}
}
The second ICE (existential type exported from crate A used as struct member in crate B) is already fixed.
The third ICE (existential type exported from crate A used in return type of a function in crate B) still exists.
And, while I'm at it, @andreytkachenko's ICE also still exists.
@Arnavion thanks so much for following up on this! Do you want to open a PR, since you've done all the work? 馃榿
The patch is just guesswork on my part, and the whole thing is still broken anyway, so there's no point to me making a PR. If you want to try it you can apply that patch locally.
Just encountered an ICE and searching led me here. Is this just another instance of the same bug or should I report it separately?
Run cargo test on rustin@a100f20 using nightly rustc and you get:
error: internal compiler error: src/librustc_metadata/decoder.rs:893: cannot get associated-item of `DefKey { parent: Some(DefIndex(0:47)), disambiguated_data: DisambiguatedDefPathData { data: AssocExistentialInImpl("Success"), disambiguator: 0 } }`
thread 'main' panicked at 'Box<Any>', src/librustc_errors/lib.rs:600:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error
I'm running into this with noria too. Curiously, I see this when I run tests, presumably because the crate-under-test essentially operates as an "external" crate?
ICE
error: internal compiler error: src/librustc_metadata/decoder.rs:893: cannot get associated-item of DefKey { parent: Some(DefIndex(0:231)), disambiguated_data: DisambiguatedDefPathData { data: AssocExistentialInImpl("Future"), disambiguator: 0 } }
thread 'main' panicked at 'Box
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:59
at src/libstd/panicking.rs:210
3: std::panicking::default_hook
at src/libstd/panicking.rs:224
4: rustc::util::common::panic_hook
5: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:491
6: std::panicking::begin_panic
7: rustc_errors::Handler::bug
8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
9: rustc::ty::context::tls::with_opt::{{closure}}
10: rustc::ty::context::tls::with_context_opt
11: rustc::ty::context::tls::with_opt
12: rustc::util::bug::opt_span_bug_fmt
13: rustc::util::bug::bug_fmt
14: rustc_metadata::decoder::
15: rustc_metadata::cstore_impl::provide_extern::associated_item
16: rustc::ty::query::__query_compute::associated_item
17: rustc::ty::query::
18: rustc::ty::context::tls::with_context
19: rustc::dep_graph::graph::DepGraph::with_task_impl
20:
21: rustc::ty::query::plumbing::
22: rustc::ty::query::plumbing::
23: rustc::traits::project::assoc_ty_def
24: rustc::infer::InferCtxt::commit_if_ok
25: rustc::traits::project::opt_normalize_projection_type
26: rustc::traits::project::normalize_projection_type
27:
28: rustc::traits::project::opt_normalize_projection_type
29: rustc::traits::project::normalize_projection_type
30: rustc::ty::context::tls::with_related_context
31: rustc::infer::canonical::query_response::
32: rustc_traits::normalize_projection_ty::normalize_projection_ty
33: rustc::ty::query::__query_compute::normalize_projection_ty
34: rustc::ty::query::
35: rustc::ty::context::tls::with_context
36: rustc::dep_graph::graph::DepGraph::with_task_impl
37:
38: rustc::ty::query::plumbing::
39: rustc::ty::query::plumbing::
40:
41:
42: rustc::ty::fold::TypeFoldable::fold_with
43: rustc::ty::structural_impls::
44:
45:
46: rustc::ty::fold::TypeFoldable::fold_with
47: rustc::ty::structural_impls::
48:
49:
50: rustc::ty::fold::TypeFoldable::fold_with
51: rustc::ty::structural_impls::
52:
53: rustc::traits::query::normalize::
54: rustc::ty::context::tls::with_related_context
55: rustc::infer::InferCtxtBuilder::enter
56: rustc_traits::normalize_erasing_regions::normalize_ty_after_erasing_regions
57: rustc::ty::query::__query_compute::normalize_ty_after_erasing_regions
58: rustc::ty::query::
59: rustc::ty::context::tls::with_context
60: rustc::dep_graph::graph::DepGraph::with_task_impl
61:
62: rustc::ty::query::plumbing::
63: rustc::ty::query::plumbing::
64:
65: rustc::traits::codegen::
66:
67: rustc_mir::monomorphize::collector::collect_items_rec
68: rustc_mir::monomorphize::collector::collect_items_rec
69: rustc_mir::monomorphize::collector::collect_items_rec
70: rustc_mir::monomorphize::collector::collect_items_rec
71: rustc_mir::monomorphize::collector::collect_items_rec
72: rustc_mir::monomorphize::collector::collect_items_rec
73: rustc_mir::monomorphize::collector::collect_items_rec
74: rustc_mir::monomorphize::collector::collect_items_rec
75: rustc_mir::monomorphize::collector::collect_items_rec
76: rustc_mir::monomorphize::collector::collect_items_rec
77: rustc_mir::monomorphize::collector::collect_items_rec
78: rustc_mir::monomorphize::collector::collect_items_rec
79: rustc_mir::monomorphize::collector::collect_items_rec
80: rustc_mir::monomorphize::collector::collect_items_rec
81: rustc_mir::monomorphize::collector::collect_items_rec
82: rustc_mir::monomorphize::collector::collect_items_rec
83: rustc_mir::monomorphize::collector::collect_items_rec
84: rustc_mir::monomorphize::collector::collect_items_rec
85: rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}
86: rustc::util::common::time
87: rustc_mir::monomorphize::collector::collect_crate_mono_items
88: rustc::util::common::time
89: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
90: rustc::ty::query::
91: rustc::ty::context::tls::with_context
92: rustc::dep_graph::graph::DepGraph::with_task_impl
93:
94: rustc::ty::query::plumbing::
95: rustc::ty::query::plumbing::
96: rustc_codegen_ssa::base::codegen_crate
97:
98: rustc::util::common::time
99: rustc_driver::driver::phase_4_codegen
query stack during panic:
<noria::table::Table as tower_service::Service<noria::table::Input>>::FutureCanonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: ProjectionTy { substs: [noria::table::Table, std::vec::Vec<noria::data::TableOperation>], item_def_id: DefId(97/0:10 ~ tower_service[c637]::Service[0]::Future[0]) } } }ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: fn(tower_util::ext::ready::Ready<noria::table::Table, std::vec::Vec<noria::data::TableOperation>>, [closure@DefId(91/1:105 ~ noria[413f]::table[0]::{{impl}}[7]::quick_n_dirty[0]::{{closure}}[0]) 0:std::vec::Vec<noria::data::TableOperation>]) -> futures::future::and_then::AndThen<tower_util::ext::ready::Ready<noria::table::Table, std::vec::Vec<noria::data::TableOperation>>, <noria::table::Table as tower_service::Service<std::vec::Vec<noria::data::TableOperation>>>::Future, [closure@DefId(91/1:105 ~ noria[413f]::table[0]::{{impl}}[7]::quick_n_dirty[0]::{{closure}}[0]) 0:std::vec::Vec<noria::data::TableOperation>]> {<tower_util::ext::ready::Ready<noria::table::Table, std::vec::Vec<noria::data::TableOperation>> as futures::future::Future>::and_then::<[closure@DefId(91/1:105 ~ noria[413f]::table[0]::{{impl}}[7]::quick_n_dirty[0]::{{closure}}[0]) 0:std::vec::Vec<noria::data::TableOperation>], <noria::table::Table as tower_service::Service<std::vec::Vec<noria::data::TableOperation>>>::Future>} }end of query stack
@jonhoo Yes. If you see the "Easy playground repro" link in the OP, that happens because the doctest is a separate crate.
@oli-obk any thoughts on the further ICEs that @Arnavion discovered when trying to fix this? This ICE sadly makes existential types pretty unusable in libraries.
Sorry about taking so long, it was just a few small fixes in the end. I think https://github.com/rust-lang/rust/pull/57836 fixes all the ICEs mentioned in this issue.
Thanks. I confirmed this fixed all the issues with my original project too.
@oli-obk could you also take a look at #53598, I suppose it is very close to that one. Thank you.
Most helpful comment
Thanks. I confirmed this fixed all the issues with my original project too.