Skip to content

[ICE] with const_trait_impl and closure #79378

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
leonardo-m opened this issue Nov 24, 2020 · 3 comments
Closed

[ICE] with const_trait_impl and closure #79378

leonardo-m opened this issue Nov 24, 2020 · 3 comments
Labels
C-bug Category: This is a bug. F-const_trait_impl `#![feature(const_trait_impl)]` 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

@leonardo-m
Copy link

#![feature(const_trait_impl)]
#![allow(incomplete_features)]
fn main() {
    const fn foo() -> u32 {
        let bar = |x| x;
        bar(0_u32)
    }
}

Gives:

error: internal compiler error: compiler\rustc_typeck\src\collect.rs:1605:13: to get the signature of a closure, use `substs.as_closure().sig()` not `fn_sig()`

thread 'rustc' panicked at 'Box<Any>', compiler\rustc_errors\src\lib.rs:958:9
stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_errors::HandlerInner::bug
   2: rustc_errors::Handler::bug
   3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   4: rustc_middle::ty::context::tls::with_opt::{{closure}}
   5: rustc_middle::ty::context::tls::with_opt
   6: rustc_middle::util::bug::opt_span_bug_fmt
   7: rustc_middle::util::bug::bug_fmt
   8: rustc_typeck::collect::fn_sig
   9: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::fn_sig>::compute
  10: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
  11: rustc_query_system::query::plumbing::get_query_impl
  12: <rustc_mir::transform::check_consts::validation::Validator as rustc_middle::mir::visit::Visitor>::visit_terminator
  13: rustc_mir::transform::check_consts::validation::Validator::check_body
  14: rustc_mir::transform::mir_const_qualif
  15: core::ops::function::FnOnce::call_once
  16: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_const_qualif>::compute
  17: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
  18: rustc_query_system::query::plumbing::get_query_impl
  19: rustc_mir::transform::mir_promoted
  20: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_promoted>::compute
  21: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
  22: rustc_query_system::query::plumbing::get_query_impl
  23: rustc_mir::borrow_check::mir_borrowck
  24: core::ops::function::FnOnce::call_once
  25: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute
  26: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  27: rustc_data_structures::stack::ensure_sufficient_stack
  28: rustc_query_system::query::plumbing::get_query_impl
  29: rustc_query_system::query::plumbing::ensure_query_impl
  30: rustc_session::utils::<impl rustc_session::session::Session>::time
  31: rustc_interface::passes::analysis
  32: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  33: rustc_query_system::dep_graph::graph::DepGraph<K>::with_eval_always_task
  34: rustc_data_structures::stack::ensure_sufficient_stack
  35: rustc_query_system::query::plumbing::get_query_impl
  36: rustc_interface::passes::QueryContext::enter
  37: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  38: rustc_span::with_source_map
  39: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.50.0-nightly (d9a105fdd 2020-11-23) running on x86_64-pc-windows-gnu

query stack during panic:
#0 [fn_sig] computing function signature of `main::foo::{closure#0}`
#1 [mir_const_qualif] const checking `main::foo`
#2 [mir_promoted] processing `main::foo`
#3 [mir_borrowck] borrow-checking `main::foo`
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

Tool completed with exit code 101
@leonardo-m leonardo-m added the C-bug Category: This is a bug. label Nov 24, 2020
@jonas-schievink jonas-schievink added F-const_trait_impl `#![feature(const_trait_impl)]` 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. labels Nov 24, 2020
@xNxExOx
Copy link

xNxExOx commented Mar 20, 2021

I would like to add my issue here: play.rust-lang.org
if I write the impl manually it works, but when I add the const to the macro it panic, and I do not see the difference what is different. I am actually just trying to have impl const ::std::ops::... based on auto_ops

@fee1-dead
Copy link
Member

I cannot reproduce the issue here. It might have been fixed.

play

@jplatte
Copy link
Contributor

jplatte commented Sep 1, 2021

Shouldn't this issue be marked needs-test then instead of being closed?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. F-const_trait_impl `#![feature(const_trait_impl)]` 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.
Projects
None yet
Development

No branches or pull requests

5 participants