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

Existental type, const fn, and generator ICE #53678

Closed
DutchGhost opened this issue Aug 24, 2018 · 5 comments · Fixed by #63096
Closed

Existental type, const fn, and generator ICE #53678

DutchGhost opened this issue Aug 24, 2018 · 5 comments · Fixed by #63096
Assignees
Labels
A-const-eval Area: constant evaluation (mir interpretation) A-coroutines Area: Coroutines F-coroutines `#![feature(coroutines)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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

@DutchGhost
Copy link
Contributor

The following constant function that returns a Generator, ICE's:

#![feature(const_fn)]
#![feature(generators)]
#![feature(generator_trait)]
#![feature(existential_type)]

use std::ops::Generator;
 
existential type GenOnce<Y, R>: Generator<Yield = Y, Return = R>;

const fn const_generator<Y, R>(yielding: Y, returning: R) -> GenOnce<Y, R> {
    move || {
        yield yielding;
        
        return returning;
    }
}

const foo: GenOnce<usize, usize> = const_generator(10, 100);

fn main() {
    
}
Backtrace:
thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', /checkout/src/librustc_mir/interpret/eval_context.rs:1851:68
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
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             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:479
   6: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:390
   7: rust_begin_unwind
             at libstd/panicking.rs:325
   8: core::panicking::panic_fmt
             at libcore/panicking.rs:77
   9: core::panicking::panic_bounds_check
             at libcore/panicking.rs:59
  10: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::with_freevars
  11: <rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::write_field_name
  12: <rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::validate_ptr_target
  13: rustc_lint::builtin::check_const
  14: <rustc_lint::register_builtins::BuiltinCombinedLateLintPass as rustc::lint::LateLintPass<'a, 'tcx>>::check_item
  15: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  16: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  17: rustc::hir::intravisit::walk_crate
  18: rustc::lint::context::check_crate
  19: rustc::util::common::time
  20: rustc::ty::context::tls::enter_context
  21: <std::thread::local::LocalKey<T>>::with
  22: rustc::ty::context::TyCtxt::create_and_enter
  23: rustc_driver::driver::compile_input
  24: rustc_driver::run_compiler_with_pool
  25: syntax::with_globals
  26: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  27: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  28: rustc_driver::run
  29: rustc_driver::main
  30: std::rt::lang_start::{{closure}}
  31: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  32: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  33: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  34: main
  35: __libc_start_main
  36: <unknown>
query stack during panic:
end of query stack
@estebank estebank added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-coroutines Area: Coroutines A-const-eval Area: constant evaluation (mir interpretation) labels Aug 24, 2018
@DutchGhost
Copy link
Contributor Author

This no longer ICE's!

@oli-obk
Copy link
Contributor

oli-obk commented Jan 25, 2019

New ICE:

error: internal compiler error: broken MIR in DefId(0/0:6 ~ playground[d6cf]::foo[0]) (bb0[0]): equate_inputs_and_outputs: `GenOnce::<usize, usize>==GenOnce::<usize, usize>` failed with `NoSolution`
  --> src/main.rs:18:1
   |
18 | const foo: GenOnce<usize, usize> = const_generator(10, 100);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@Aaron1011
Copy link
Member

This no longer ICEs on the latest nightly.

@oli-obk
Copy link
Contributor

oli-obk commented Jul 28, 2019

I'm assuming this (and #54899, #60564, #60407) were fixed by #62423 ?

If so, we could close all four by adding their failing examples as regression tests (if there aren't already such tests).

@Centril
Copy link
Contributor

Centril commented Jul 28, 2019

If so, we could close all four by adding their failing examples as regression tests (if there aren't already such tests).

I would prefer to have redundant tests here rather than under-testing so some bit of duplication is fine imo.

Also cc @varkor @alexreg -- we should add these tests before we change the syntax ideally.

@Centril Centril added F-const_fn F-coroutines `#![feature(coroutines)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. requires-nightly This issue requires a nightly compiler in some way. labels Jul 28, 2019
@varkor varkor self-assigned this Jul 28, 2019
@Centril Centril self-assigned this Jul 28, 2019
Centril added a commit to Centril/rust that referenced this issue Jul 29, 2019
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-const-eval Area: constant evaluation (mir interpretation) A-coroutines Area: Coroutines F-coroutines `#![feature(coroutines)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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.

6 participants