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 with HRTB and associated type: "leak-check would have us replace ReErased with BrNamed" #55731

Closed
alecmocatta opened this issue Nov 6, 2018 · 1 comment · Fixed by #58743
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@alecmocatta
Copy link
Contributor

Affects stable and nightly, with and without #![feature(nll)].

use std::marker::PhantomData;

trait DistributedIterator {
    fn reduce(self)
    where
        Self: Sized,
    {
        unreachable!()
    }
}

trait DistributedIteratorMulti<Source> {
    type Item;
}

struct Connect<I>(PhantomData<fn(I)>);
impl<I: for<'a> DistributedIteratorMulti<&'a ()>> DistributedIterator for Connect<I> where {}

struct Cloned<Source>(PhantomData<fn(Source)>);
impl<'a, Source> DistributedIteratorMulti<&'a Source> for Cloned<&'a Source> {
    type Item = ();
}

struct Map<I, F> {
    i: I,
    f: F,
}
impl<I: DistributedIteratorMulti<Source>, F, Source> DistributedIteratorMulti<Source> for Map<I, F>
where
    F: A<<I as DistributedIteratorMulti<Source>>::Item>,
{
    type Item = ();
}

trait A<B> {}

struct X;
impl A<()> for X {}

fn multi<I>(_reducer: I)
where
    I: for<'a> DistributedIteratorMulti<&'a ()>,
{
    DistributedIterator::reduce(Connect::<I>(PhantomData))
}

fn main() {
    multi(Map {
        i: Cloned(PhantomData),
        f: X,
    });
}

(Playground)

thread 'main' panicked at 'leak-check would have us replace ReErased with BrNamed(crate0:DefIndex(1:14), 'a)', librustc/infer/higher_ranked/mod.rs:507:21
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::continue_panic_fmt
             at libstd/panicking.rs:390
   7: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:345
   8: rustc::infer::higher_ranked::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::plug_leaks::{{closure}}
   9: rustc::ty::fold::TypeFolder::fold_ty
  10: <smallvec::SmallVec<A> as core::iter::traits::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  11: rustc::ty::fold::TypeFoldable::fold_with
  12: rustc::ty::fold::TypeFolder::fold_ty
  13: <smallvec::SmallVec<A> as core::iter::traits::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  14: rustc::ty::fold::TypeFoldable::fold_with
  15: rustc::ty::fold::TypeFoldable::fold_with
  16: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::fold
  17: rustc::ty::fold::TypeFoldable::fold_with
  18: rustc::infer::higher_ranked::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::plug_leaks
  19: rustc::traits::select::SelectionContext::impl_or_trait_obligations
  20: rustc::traits::select::SelectionContext::vtable_impl
  21: rustc::infer::InferCtxt::in_snapshot
  22: rustc::traits::select::SelectionContext::confirm_candidate
  23: rustc::infer::InferCtxt::probe
  24: rustc::traits::select::SelectionContext::evaluate_stack
  25: rustc::dep_graph::graph::DepGraph::with_anon_task
  26: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  27: rustc::traits::select::SelectionContext::evaluate_obligation_recursively
  28: rustc::ty::context::tls::with_related_context
  29: rustc::infer::InferCtxtBuilder::enter_with_canonical
  30: rustc_traits::evaluate_obligation::evaluate_obligation
  31: rustc::ty::query::__query_compute::evaluate_obligation
  32: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::evaluate_obligation<'tcx>>::compute
  33: rustc::dep_graph::graph::DepGraph::with_task_impl
  34: rustc::ty::context::tls::with_related_context
  35: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  36: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  37: rustc::traits::query::evaluate_obligation::<impl rustc::infer::InferCtxt<'cx, 'gcx, 'tcx>>::evaluate_obligation
  38: rustc::traits::query::evaluate_obligation::<impl rustc::infer::InferCtxt<'cx, 'gcx, 'tcx>>::evaluate_obligation_no_overflow
  39: <rustc_data_structures::obligation_forest::ObligationForest<O>>::process_obligations
  40: <rustc::traits::fulfill::FulfillmentContext<'tcx> as rustc::traits::engine::TraitEngine<'tcx>>::select_where_possible
  41: <rustc::traits::fulfill::FulfillmentContext<'tcx> as rustc::traits::engine::TraitEngine<'tcx>>::select_all_or_error
  42: rustc::traits::codegen::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::drain_fulfillment_cx_or_panic
  43: rustc::ty::context::tls::with_related_context
  44: rustc::infer::InferCtxtBuilder::enter
  45: rustc::traits::codegen::codegen_fulfill_obligation
  46: rustc::ty::query::__query_compute::codegen_fulfill_obligation
  47: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::codegen_fulfill_obligation<'tcx>>::compute
  48: rustc::dep_graph::graph::DepGraph::with_task_impl
  49: rustc::ty::context::tls::with_related_context
  50: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  51: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  52: rustc::ty::instance::Instance::resolve
  53: rustc_mir::monomorphize::collector::visit_fn_use
  54: <rustc_mir::monomorphize::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind
  55: rustc_mir::monomorphize::collector::collect_items_rec
  56: rustc_mir::monomorphize::collector::collect_items_rec
  57: rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}
  58: rustc::util::common::time
  59: rustc_mir::monomorphize::collector::collect_crate_mono_items
  60: rustc::util::common::time
  61: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
  62: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::collect_and_partition_mono_items<'tcx>>::compute
  63: rustc::dep_graph::graph::DepGraph::with_task_impl
  64: rustc::ty::context::tls::with_related_context
  65: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  66: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  67: rustc_codegen_llvm::base::codegen_crate
  68: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  69: rustc::util::common::time
  70: rustc_driver::driver::phase_4_codegen
  71: rustc_driver::driver::compile_input::{{closure}}
  72: rustc::ty::context::tls::enter_context
  73: <std::thread::local::LocalKey<T>>::with
  74: rustc::ty::context::TyCtxt::create_and_enter
  75: rustc_driver::driver::compile_input
  76: rustc_driver::run_compiler_with_pool
  77: rustc_driver::driver::spawn_thread_pool
  78: rustc_driver::run_compiler
  79: <scoped_tls::ScopedKey<T>>::set
  80: syntax::with_globals
  81: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  82: rustc_driver::run
  83: rustc_driver::main
  84: std::rt::lang_start::{{closure}}
  85: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  86: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  87: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:398
             at libstd/rt.rs:58
  88: main
  89: __libc_start_main
  90: <unknown>
query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `for<'a> Map<Cloned<&()>, X>: DistributedIteratorMulti<&'a ()>`
#1 [codegen_fulfill_obligation] checking if `DistributedIterator` fulfills its obligations
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack

error: internal compiler error: unexpected panic

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

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin
@estebank estebank added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. labels Jan 19, 2019
@estebank
Copy link
Contributor

estebank commented Jan 19, 2019

Fixed in beta:

error[E0308]: mismatched types
  --> src/main.rs:49:5
   |
49 |     multi(Map {
   |     ^^^^^ one type is more general than the other
   |
   = note: expected type `DistributedIteratorMulti<&'a ()>`
              found type `DistributedIteratorMulti<&()>`

varkor added a commit to varkor/rust that referenced this issue Feb 26, 2019
varkor added a commit to varkor/rust that referenced this issue Feb 26, 2019
Centril added a commit to Centril/rust that referenced this issue Feb 27, 2019
…hton

Add tests for several E-needstest issues

This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise.

Closes rust-lang#10876.
Closes rust-lang#22892.
Closes rust-lang#26448.
Closes rust-lang#26577.
Closes rust-lang#26619.
Closes rust-lang#27054.
Closes rust-lang#28587.
Closes rust-lang#44127.
Closes rust-lang#44255.
Closes rust-lang#55731.
Closes rust-lang#57781.
varkor added a commit to varkor/rust that referenced this issue Feb 27, 2019
varkor added a commit to varkor/rust that referenced this issue Feb 27, 2019
pietroalbini added a commit to pietroalbini/rust that referenced this issue Mar 1, 2019
…hton

Add tests for several E-needstest issues

This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise.

Closes rust-lang#10876.
Closes rust-lang#22892.
Closes rust-lang#26448.
Closes rust-lang#26577.
Closes rust-lang#26619.
Closes rust-lang#27054.
Closes rust-lang#28587.
Closes rust-lang#44127.
Closes rust-lang#44255.
Closes rust-lang#55731.
Closes rust-lang#57781.
Centril added a commit to Centril/rust that referenced this issue Mar 9, 2019
…hton

Add tests for several E-needstest issues

This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise.

Closes rust-lang#10876.
Closes rust-lang#22892.
Closes rust-lang#26448.
Closes rust-lang#26577.
Closes rust-lang#26619.
Closes rust-lang#27054.
Closes rust-lang#28587.
Closes rust-lang#44127.
Closes rust-lang#44255.
Closes rust-lang#55731.
Closes rust-lang#57781.
Centril added a commit to Centril/rust that referenced this issue Mar 9, 2019
…hton

Add tests for several E-needstest issues

This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise.

Closes rust-lang#10876.
Closes rust-lang#22892.
Closes rust-lang#26448.
Closes rust-lang#26577.
Closes rust-lang#26619.
Closes rust-lang#27054.
Closes rust-lang#28587.
Closes rust-lang#44127.
Closes rust-lang#44255.
Closes rust-lang#55731.
Closes rust-lang#57781.
varkor added a commit to varkor/rust that referenced this issue Mar 11, 2019
varkor added a commit to varkor/rust that referenced this issue Mar 11, 2019
bors added a commit that referenced this issue Mar 12, 2019
Add tests for several E-needstest issues

This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise.

Closes #10876.
Closes #26448.
Closes #26577.
Closes #26619.
Closes #27054.
Closes #44127.
Closes #44255.
Closes #55731.
Closes #57781.
varkor added a commit to varkor/rust that referenced this issue Mar 12, 2019
varkor added a commit to varkor/rust that referenced this issue Mar 12, 2019
pietroalbini added a commit to pietroalbini/rust that referenced this issue Mar 12, 2019
…hton

Add tests for several E-needstest issues

This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise.

Closes rust-lang#10876.
Closes rust-lang#26448.
Closes rust-lang#26577.
Closes rust-lang#26619.
Closes rust-lang#27054.
Closes rust-lang#44127.
Closes rust-lang#44255.
Closes rust-lang#55731.
Closes rust-lang#57781.
bors added a commit that referenced this issue Mar 12, 2019
Add tests for several E-needstest issues

This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise.

Closes #10876.
Closes #26448.
Closes #26577.
Closes #26619.
Closes #27054.
Closes #44127.
Closes #44255.
Closes #55731.
Closes #57781.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants