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

Existential type ICE without feature specified #60371

Closed
DutchGhost opened this issue Apr 29, 2019 · 6 comments · Fixed by #60714
Closed

Existential type ICE without feature specified #60371

DutchGhost opened this issue Apr 29, 2019 · 6 comments · Fixed by #60714
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@DutchGhost
Copy link
Contributor

DutchGhost commented Apr 29, 2019

Another ICE that uses a nightly only feature, but still crashes on stable, beta and nightly without the #![feature(existential_type)] flag.

trait Bug {
    type Item: Bug;
    
    const FUN: fn() -> Self::Item;
}

impl Bug for &() {
    existential type Item: Bug;
    
    const FUN: fn() -> Self::Item = || ();
}

According to godbolt, this sneaked in with 1.34. 1.33 and lower are not affected.

Backtrace:
 Compiling playground v0.0.1 (/playground)
error[E0658]: existential types are unstable (see issue #34511)
  --> src/lib.rs:10:5
   |
10 |     existential type Item: Bug;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0277]: the trait bound `(): Bug` is not satisfied
  --> src/lib.rs:10:5
   |
10 |     existential type Item: Bug;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bug` is not implemented for `()`
   |
   = help: the following implementations were found:
             <&() as Bug>
   = note: the return type of a function must have a statically known size

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:345:21
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:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:482
   6: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:385
   7: rust_begin_unwind
             at src/libstd/panicking.rs:312
   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<'a, 'gcx, 'tcx>>::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<'tcx> for rustc::ty::query::queries::typeck_tables_of<'tcx>>::compute
  16: rustc::dep_graph::graph::DepGraph::with_task_impl
  17: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  18: rustc_typeck::collect::find_existential_constraints::ConstraintLocator::check
  19: <rustc_typeck::collect::find_existential_constraints::ConstraintLocator<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_impl_item
  20: rustc::hir::intravisit::walk_item
  21: rustc_typeck::collect::find_existential_constraints
  22: rustc_typeck::collect::type_of
  23: rustc::ty::query::__query_compute::type_of
  24: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::type_of<'tcx>>::compute
  25: rustc::dep_graph::graph::DepGraph::with_task_impl
  26: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  27: <rustc_typeck::collect::CollectItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_impl_item
  28: rustc::hir::map::Map::visit_item_likes_in_module
  29: rustc_typeck::collect::collect_mod_item_types
  30: rustc::ty::query::__query_compute::collect_mod_item_types
  31: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::collect_mod_item_types<'tcx>>::compute
  32: rustc::dep_graph::graph::DepGraph::with_task_impl
  33: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  34: rustc_typeck::collect::collect_item_types
  35: rustc::util::common::time
  36: rustc_typeck::check_crate
  37: <std::thread::local::LocalKey<T>>::with
  38: rustc::ty::context::TyCtxt::create_and_enter
  39: rustc_driver::driver::compile_input
  40: rustc_driver::run_compiler_with_pool
  41: <scoped_tls::ScopedKey<T>>::set
  42: rustc_driver::run_compiler
  43: syntax::with_globals
  44: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:87
  45: <F as alloc::boxed::FnBox<A>>::call_box
  46: std::sys::unix::thread::Thread::new::thread_start
             at /rustc/fc50f328b0353b285421b8ff5d4100966387a997/src/liballoc/boxed.rs:759
             at src/libstd/sys_common/thread.rs:14
             at src/libstd/sys/unix/thread.rs:81
  47: start_thread
  48: __clone
query stack during panic:
#0 [typeck_tables_of] processing `<&() as Bug>::FUN`
#1 [type_of] processing `<&() as Bug>::Item`
#2 [collect_mod_item_types] collecting item types in top-level module
end of query stack
error: aborting due to 2 previous errors

Some errors occurred: E0277, E0658.
For more information about an error, try `rustc --explain E0277`.

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.34.1 (fc50f328b 2019-04-24) 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.
@jonas-schievink jonas-schievink added A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-nominated labels Apr 29, 2019
@jonas-schievink
Copy link
Contributor

jonas-schievink commented Apr 29, 2019

Pretty sure this is a duplicate, but I can't find the original right now nevermind I was thinking of #60263, which you also filed

@DutchGhost
Copy link
Contributor Author

DutchGhost commented Apr 29, 2019

Perhaps you mean #57272 ? Being able to ICE a feature, without the feature gate turned on?

I found this verry related:
#58887

@DutchGhost
Copy link
Contributor Author

DutchGhost commented Apr 29, 2019

Again this is kinda 2 issue's in 1, so I dont know if this should have it's own issue...

After some more trying, I found this also panics, but only on nightly:

#![feature(existential_type)]

trait Bug {
    type Item: Bug;
    
    const FUN: fn() -> Self::Item;
}

impl Bug for () {
    existential type Item: Bug;
    
    const FUN: fn() -> Self::Item = || {};
}

Notice I removed the & on the impl Bug for () line

Backtrace:
error: internal compiler error: broken MIR in DefId(0/0:8 ~ playground[2d7c]::{{impl}}[0]::FUN[0]) (bb0[0]): equate_inputs_and_outputs: `fn() -> Item==fn() -> Item` failed with `NoSolution`
  --> src/lib.rs:12:5
   |
12 |     const FUN: fn() -> Self::Item = || {};
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:355:17
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::begin_panic
   7: <rustc_errors::Handler as core::ops::drop::Drop>::drop
   8: core::ptr::real_drop_in_place
   9: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
  10: core::ptr::real_drop_in_place
  11: rustc_interface::interface::run_compiler_in_existing_thread_pool
  12: std::thread::local::LocalKey<T>::with
  13: scoped_tls::ScopedKey<T>::set
  14: syntax::with_globals
query stack during panic:
end of query stack

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 (938d4ffe1 2019-04-27) 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.

@DutchGhost
Copy link
Contributor Author

DutchGhost commented Apr 29, 2019

Another one, stable, beta & nightly:

trait Bug {
    type Item;
    
    const FUN: Self::Item;
}

impl Bug for () {
    existential type Item: Fn() -> Self::Item;
    
    const FUN: fn() -> Self::Item = || { || {} }; // <---- double closure!
}
Backtrace:
  Compiling playground v0.0.1 (/playground)
error[E0658]: existential types are unstable
 --> src/lib.rs:8:5
  |
8 |     existential type Item: Fn() -> Self::Item;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: for more information, see https://github.com/rust-lang/rust/issues/34511
  = help: add #![feature(existential_type)] to the crate attributes to enable

thread 'rustc' panicked at 'instantiated twice: DefId(0/0:7 ~ playground[2d7c]::{{impl}}[0]::Item[0])/OpaqueTypeDecl { substs: [], concrete_ty: _, has_required_region_bounds: false, origin: ExistentialType }', src/librustc_typeck/check/mod.rs:2354:13
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: std::panicking::begin_panic_fmt
             at src/libstd/panicking.rs:336
   8: rustc_typeck::check::FnCtxt::instantiate_opaque_types_from_value
   9: rustc_typeck::check::check_fn
  10: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt>::check_expr_closure
  11: rustc_typeck::check::FnCtxt::check_expr_kind
  12: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
  13: rustc_typeck::check::FnCtxt::check_block_with_expected
  14: rustc_typeck::check::FnCtxt::check_expr_kind
  15: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
  16: rustc_typeck::check::FnCtxt::check_return_expr
  17: rustc_typeck::check::check_fn
  18: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt>::check_expr_closure
  19: rustc_typeck::check::FnCtxt::check_expr_kind
  20: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
  21: rustc::ty::context::GlobalCtxt::enter_local
  22: rustc_typeck::check::typeck_tables_of
  23: rustc::ty::query::__query_compute::typeck_tables_of
  24: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  25: rustc::dep_graph::graph::DepGraph::with_task_impl
  26: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  27: rustc_typeck::collect::find_existential_constraints::ConstraintLocator::check
  28: rustc::hir::intravisit::Visitor::visit_nested_impl_item
  29: rustc::hir::intravisit::walk_item
  30: rustc_typeck::collect::find_existential_constraints
  31: rustc_typeck::collect::checked_type_of
  32: rustc_typeck::collect::type_of
  33: rustc::ty::query::__query_compute::type_of
  34: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::type_of>::compute
  35: rustc::dep_graph::graph::DepGraph::with_task_impl
  36: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  37: <rustc_typeck::collect::CollectItemTypesVisitor as rustc::hir::intravisit::Visitor>::visit_impl_item
  38: rustc::hir::map::Map::visit_item_likes_in_module
  39: rustc_typeck::collect::collect_mod_item_types
  40: rustc::ty::query::__query_compute::collect_mod_item_types
  41: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_mod_item_types>::compute
  42: rustc::dep_graph::graph::DepGraph::with_task_impl
  43: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  44: rustc_typeck::check_crate::{{closure}}::{{closure}}
  45: rustc::util::common::time
  46: rustc_typeck::check_crate
  47: rustc_interface::passes::analysis
  48: rustc::ty::query::__query_compute::analysis
  49: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
  50: rustc::dep_graph::graph::DepGraph::with_task_impl
  51: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  52: rustc::ty::context::tls::enter_global
  53: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  54: rustc_interface::passes::create_global_ctxt::{{closure}}
  55: rustc_interface::interface::run_compiler_in_existing_thread_pool
  56: std::thread::local::LocalKey<T>::with
  57: scoped_tls::ScopedKey<T>::set
  58: syntax::with_globals
query stack during panic:
#0 [typeck_tables_of] processing `<() as Bug>::FUN`
#1 [type_of] processing `<() as Bug>::Item`
#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

For more information about this error, try `rustc --explain E0658`.

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 (938d4ffe1 2019-04-27) 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.

@pnkfelix
Copy link
Member

pnkfelix commented May 2, 2019

triage: P-high due to ICE; removing nomination.

@nikomatsakis
Copy link
Contributor

Likely duplicate from #60473

#![feature(impl_trait_in_bindings)]

struct A<'a>(&'a ());

trait Trait<T> {
}

impl<T> Trait<T> for () {
}

fn main() {
    let x: impl Trait<A> = ();
}

bors added a commit that referenced this issue May 11, 2019
Fix ICE with un-feature-gated existential type

Fixes #60371.

r? @oli-obk
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. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants