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 associated existential type #60564

Open
ambiso opened this issue May 5, 2019 · 3 comments

Comments

Projects
None yet
4 participants
@ambiso
Copy link

commented May 5, 2019

Hi,

I'm guessing this error is known, but it appears to fail in a different way compared to #54899.

Code:

#![feature(existential_type)]


trait IterBits {
    type BitsIter: Iterator<Item = u8>;
    fn iter_bits(self, n: u8) -> Self::BitsIter;
}

existential type IterBitsIter<T, E, I>: std::iter::Iterator<Item = I>;

impl<T, E> IterBits for T where T: std::ops::Shr<Output = T> + std::ops::BitAnd<T, Output = T> + std::convert::From<u8> + std::convert::TryInto<u8, Error = E>,
                                E: std::fmt::Debug
{
    type BitsIter = IterBitsIter<T, E, u8>;
    fn iter_bits(self, n: u8) -> Self::BitsIter {
        (0u8..n)
            .rev()
            .map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap())
    }
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error: type parameter `E` is part of concrete type but not used in parameter list for existential type
  --> src/lib.rs:14:49
   |
14 |       fn iter_bits(self, n: u8) -> Self::BitsIter {
   |  _________________________________________________^
15 | |         (0u8..n)
16 | |             .rev()
17 | |             .map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap())
18 | |     }
   | |_____^

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:347:21
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   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:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:478
   6: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:381
   7: rust_begin_unwind
             at src/libstd/panicking.rs:308
   8: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   9: core::panicking::panic
             at src/libcore/panicking.rs:49
  10: rustc_typeck::check::writeback::WritebackCx::visit_opaque_types
  11: rustc_typeck::check::writeback::<impl rustc_typeck::check::FnCtxt>::resolve_type_vars_in_body
  12: rustc::ty::context::GlobalCtxt::enter_local
  13: rustc_typeck::check::typeck_tables_of
  14: rustc::ty::query::__query_compute::typeck_tables_of
  15: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  16: rustc::dep_graph::graph::DepGraph::with_task_impl
  17: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  18: rustc_typeck::collect::find_existential_constraints::ConstraintLocator::check
  19: rustc::hir::intravisit::Visitor::visit_nested_impl_item
  20: rustc::hir::intravisit::walk_item
  21: rustc_typeck::collect::find_existential_constraints
  22: rustc_typeck::collect::checked_type_of
  23: rustc_typeck::collect::type_of
  24: rustc::ty::query::__query_compute::type_of
  25: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::type_of>::compute
  26: rustc::dep_graph::graph::DepGraph::with_task_impl
  27: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  28: <rustc_typeck::collect::CollectItemTypesVisitor as rustc::hir::intravisit::Visitor>::visit_item
  29: rustc::hir::map::Map::visit_item_likes_in_module
  30: rustc_typeck::collect::collect_mod_item_types
  31: rustc::ty::query::__query_compute::collect_mod_item_types
  32: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_mod_item_types>::compute
  33: rustc::dep_graph::graph::DepGraph::with_task_impl
  34: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  35: rustc_typeck::check_crate::{{closure}}::{{closure}}
  36: rustc::util::common::time
  37: rustc_typeck::check_crate
  38: rustc_interface::passes::analysis
  39: rustc::ty::query::__query_compute::analysis
  40: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
  41: rustc::dep_graph::graph::DepGraph::with_task_impl
  42: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  43: rustc::ty::context::tls::enter_global
  44: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  45: rustc_interface::passes::create_global_ctxt::{{closure}}
  46: rustc_interface::passes::BoxedGlobalCtxt::enter
  47: rustc_interface::interface::run_compiler_in_existing_thread_pool
  48: std::thread::local::LocalKey<T>::with
  49: scoped_tls::ScopedKey<T>::set
  50: syntax::with_globals
query stack during panic:
#0 [typeck_tables_of] processing `<T as IterBits>::iter_bits`
#1 [type_of] processing `IterBitsIter`
#2 [collect_mod_item_types] collecting item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error


error: internal compiler error: unexpected panic

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.36.0-nightly (8dd4aae9a 2019-05-04) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib

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

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

Warnings

No main function was detected, so your code was compiled
but not run. If you'd like to execute your code, please
add a main function.
@Centril

This comment has been minimized.

Copy link
Member

commented May 5, 2019

Suggested P-Medium due to unstable buggy feature.

@cramertj

This comment has been minimized.

Copy link
Member

commented May 7, 2019

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

commented May 9, 2019

triage: P-medium

Marking as P-medium. I wanted to put this on a tracking issue as a blocker to investigate but it's not that we have a suitable one.

@nikomatsakis nikomatsakis added P-medium and removed I-nominated labels May 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.