Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: "unexpected predicate" when using multiple lifetime parameters in existential type #55903

Closed
allen-marshall opened this issue Nov 12, 2018 · 1 comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@allen-marshall
Copy link

I have encountered an internal compiler error using Rust 1.32.0 nightly. It seems to occur when using multiple lifetime parameters in an existential type.

I can reproduce the error by using the following code in lib.rs. I am not sure if this code should compile or not (I am new to Rust and trying to learn how existential types work), but I know it shouldn't cause an ICE. (The Clone trait bound here is just a placeholder to keep the example simple. The ICE seems to still happen if Clone is replaced by any other trait bound.)

#![feature(existential_type)]

existential type ExType<'a, 'b: 'a>: Clone;

fn new_ex_type<'a, 'b: 'a>() -> ExType<'a, 'b> {
    0usize
}

The output of cargo build --verbose is as follows:

   Compiling rusttest v0.1.0 (/home/allen/IdeaProjects/rusttest)
     Running `rustc --edition=2018 --crate-name rusttest src/lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=0e629ce91b3e30a4 -C extra-filename=-0e629ce91b3e30a4 --out-dir /home/allen/IdeaProjects/rusttest/target/debug/deps -C incremental=/home/allen/IdeaProjects/rusttest/target/debug/incremental -L dependency=/home/allen/IdeaProjects/rusttest/target/debug/deps`
error: internal compiler error: librustc_privacy/lib.rs:971: unexpected predicate: Binder(OutlivesPredicate(ReEarlyBound(1, 'b), ReEarlyBound(0, 'a)))

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:600: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
   2: std::panicking::default_hook::{{closure}}
             at libstd/sys_common/backtrace.rs:59
             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:480
   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_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::ty::fold::TypeVisitor<'tcx>>::visit_ty
  15: <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::ty::fold::TypeVisitor<'tcx>>::visit_ty
  16: <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_ty
  17: rustc::hir::intravisit::walk_item
  18: <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  19: rustc_privacy::privacy_access_levels
  20: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::privacy_access_levels<'tcx>>::compute
  21: rustc::ty::context::tls::with_context
  22: rustc::dep_graph::graph::DepGraph::with_task_impl
  23: rustc::ty::context::tls::with_related_context
  24: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  25: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  26: rustc::util::common::time
  27: rustc::ty::context::tls::enter_context
  28: <std::thread::local::LocalKey<T>>::with
  29: rustc::ty::context::TyCtxt::create_and_enter
  30: rustc_driver::driver::compile_input
  31: rustc_driver::run_compiler_with_pool
  32: <scoped_tls::ScopedKey<T>>::set
  33: rustc_driver::run_compiler
  34: syntax::with_globals
  35: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  36: rustc_driver::run
  37: rustc_driver::main
  38: std::rt::lang_start::{{closure}}
  39: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  40: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  41: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:398
             at libstd/rt.rs:58
  42: main
  43: __libc_start_main
  44: <unknown>
query stack during panic:
#0 [privacy_access_levels] privacy access levels
end of query stack
error: aborting due to previous error


note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.32.0-nightly (ca79ecd69 2018-11-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `rusttest`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name rusttest src/lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=0e629ce91b3e30a4 -C extra-filename=-0e629ce91b3e30a4 --out-dir /home/allen/IdeaProjects/rusttest/target/debug/deps -C incremental=/home/allen/IdeaProjects/rusttest/target/debug/incremental -L dependency=/home/allen/IdeaProjects/rusttest/target/debug/deps` (exit code: 101)

If I change the code to only use one lifetime parameter as follows, the ICE doesn't happen and the code compiles successfully:

#![feature(existential_type)]

existential type ExType<'a>: Clone;

fn new_ex_type<'a>() -> ExType<'a> {
    0usize
}

rustc --version --verbose on my system yields:

rustc 1.32.0-nightly (ca79ecd69 2018-11-11)
binary: rustc
commit-hash: ca79ecd6940e30d4b2466bf378632efcdf5745c7
commit-date: 2018-11-11
host: x86_64-unknown-linux-gnu
release: 1.32.0-nightly
LLVM version: 8.0
@cramertj cramertj assigned oli-obk and unassigned oli-obk Nov 13, 2018
@cramertj cramertj added the A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. label Nov 13, 2018
@zackmdavis zackmdavis added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 13, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Nov 13, 2018

Whoops. I couldn't produce this variant back when I wrote the impl. seems it was as easy as that. I believe we can just make this a nop as privacy is irrelevant for lifetime bounds

kennytm added a commit to kennytm/rust that referenced this issue Nov 30, 2018
Fix panic with outlives in existential type

Don't panic in determining the privacy of a type if a lifetime outlives
generic exists in an existential type.

r? @oli-obk

Fixes: rust-lang#55903
kennytm added a commit to kennytm/rust that referenced this issue Nov 30, 2018
Fix panic with outlives in existential type

Don't panic in determining the privacy of a type if a lifetime outlives
generic exists in an existential type.

r? @oli-obk

Fixes: rust-lang#55903
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants