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

Closed
ambiso opened this issue May 5, 2019 · 9 comments · Fixed by #63096
Closed

ICE with associated existential type #60564

ambiso opened this issue May 5, 2019 · 9 comments · Fixed by #63096
Labels
A-associated-items Area: Associated items (types, constants & functions) A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ambiso
Copy link

ambiso 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 Centril added A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 5, 2019
@Centril
Copy link
Contributor

Centril commented May 5, 2019

Suggested P-Medium due to unstable buggy feature.

@cramertj
Copy link
Member

cramertj commented May 7, 2019

cc @oli-obk

@nikomatsakis
Copy link
Contributor

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 Medium priority and removed I-nominated labels May 9, 2019
@Centril Centril added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` requires-nightly This issue requires a nightly compiler in some way. labels Jul 28, 2019
@Aaron1011
Copy link
Member

This no longer causes an ICE on the latest nightly.

@samuelpilz
Copy link

It does not fail indeed. However, I have no idea what the error message is trying to tell me. Can you verify that this is indeed the intended error message?

Centril added a commit to Centril/rust that referenced this issue Jul 29, 2019
@oli-obk
Copy link
Contributor

oli-obk commented Jul 29, 2019

That's curious indeed. The type parameter E is passed to the existential type, not sure what's going on. Can you try minimizing the test?

@samuelpilz
Copy link

Unfortunaltey, I was unable to get a smaller meaningful example. On the way, I found several error messages that were completely confusing as well. I suspect that some of them might be completely incorrect. I will open a new issue for them once I minified them a bit more.

@ambiso
Copy link
Author

ambiso commented Jul 29, 2019

There are several errors, that I believe to be incorrect.
However, since these don't produce an ICE, I'd suggest I close this issue and create new ones for them?

@Centril
Copy link
Contributor

Centril commented Jul 29, 2019

Before closing this issue we should add a reproducer test.

Centril added a commit to Centril/rust that referenced this issue Jul 29, 2019
… r=varkor

Add tests for some `existential_type` ICEs

Fix rust-lang#53678
Fix rust-lang#60407
Fix rust-lang#60564

rust-lang#54899 will need some minimization before it can be added.

r? @varkor
Centril added a commit to Centril/rust that referenced this issue Jul 30, 2019
… r=varkor

Add tests for some `existential_type` ICEs

Fix rust-lang#53678
Fix rust-lang#60407
Fix rust-lang#60564

rust-lang#54899 will need some minimization before it can be added.

r? @varkor
Centril added a commit to Centril/rust that referenced this issue Jul 30, 2019
… r=varkor

Add tests for some `existential_type` ICEs

Fix rust-lang#53678
Fix rust-lang#60407
Fix rust-lang#60564

rust-lang#54899 will need some minimization before it can be added.

r? @varkor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Development

Successfully merging a pull request may close this issue.

7 participants