Repository navigation
ICE when existential type is exported from one crate and used in another #53443
Copy link
Copy link
Closed
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Description
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.life-white.uk-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
| _ => bug!("unexpected definition: {:?}", def) |
Resolver::build_reduced_graph_for_external_crate_def needs an arm for Def::Existential ? @oli-obk
Edit: Easy playground repro
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Activity
oli-obk commentedon Aug 17, 2018
Oops. Yea. I assumed this would work since
impl Traitworks.Arnavion commentedon Aug 17, 2018
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:rust/src/librustc/middle/resolve_lifetime.rs
Line 630 in b559042
where the
as_local_node_idreturnsNoneIf 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.oli-obk commentedon Aug 20, 2018
I think they are closely related. We should probably run
in case
as_local_node_idreturnsNone. A repro for that would be nice though. It should probably suffice to add some lifetimes to the existential type or its concrete type.Arnavion commentedon Aug 20, 2018
My real code's existential types do not have lifetimes, though they do have
'staticbounds.Adding
'staticbounds 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.
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-webcrate 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.oli-obk commentedon Aug 21, 2018
Rust + factorio? <3
the issue you are hitting is that a
delay_span_bugis hidden from you. I'm fixing that later todayArnavion commentedon Aug 22, 2018
@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_idreturnsNone. It happens when using the imported existential type in a struct or enum definition, like:b/src/main.rsICE
Arnavion commentedon Aug 23, 2018
Your suggestion did fix that error by the way.
Arnavion commentedon Aug 24, 2018
With the above patch, there is a new ICE when using the field inside an inherent method.
ICE
andreytkachenko commentedon Aug 30, 2018
For me another variant of this issues is blocker:
a/Cargo.tomlandb/Cargo.toml- is samea/src/lib.rs:and
b/src/main.rs:ICE
tikue commentedon Sep 19, 2018
Is there any progress on this?
tikue commentedon Oct 15, 2018
@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.
Arnavion commentedon Oct 16, 2018
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.
Arnavion commentedon Oct 16, 2018
@tikue
For the first ICE (function that returns existential type in crate A called from crate B), the patch (on top of 46880f4) is
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.
2 remaining items
jimmycuadra commentedon Dec 13, 2018
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 teston rustin@a100f20 using nightly rustc and you get:jonhoo commentedon Dec 14, 2018
I'm running into this with
noriatoo. Curiously, I see this when I run tests, presumably because the crate-under-test essentially operates as an "external" crate?ICE
Arnavion commentedon Dec 20, 2018
@jonhoo Yes. If you see the "Easy playground repro" link in the OP, that happens because the doctest is a separate crate.
ICE rust-lang/rust#53443
ICE rust-lang/rust#53443
And now work around rust-lang/rust#53443
jonhoo commentedon Jan 21, 2019
@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.
Steps needed to remove boxing from view/table ops
oli-obk commentedon Jan 22, 2019
Sorry about taking so long, it was just a few small fixes in the end. I think #57836 fixes all the ICEs mentioned in this issue.
Rollup merge of rust-lang#57836 - oli-obk:existential_crisis, r=estebank
Arnavion commentedon Jan 24, 2019
Thanks. I confirmed this fixed all the issues with my original project too.
Steps needed to remove boxing from view/table ops
andreytkachenko commentedon Jan 29, 2019
@oli-obk could you also take a look at #53598, I suppose it is very close to that one. Thank you.