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: upvar_tys called before capture types are inferred with const fn trait bound #89290

Closed
nbdd0121 opened this issue Sep 27, 2021 · 2 comments
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. C-bug Category: This is a bug. F-const_trait_impl `#![feature(const_trait_impl)]` glacier ICE tracked in rust-lang/glacier. 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

@nbdd0121
Copy link
Contributor

Code

#![feature(const_fn_trait_bound)]
#![feature(const_trait_impl)]

const fn foo<T: ~const Drop>(_: T) {}

const fn bar() {
    foo(|| ());
}

Error output

error: internal compiler error: compiler/rustc_middle/src/ty/sty.rs:394:33: upvar_tys called before capture types are inferred
Backtrace

error: internal compiler error: /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/compiler/rustc_middle/src/ty/sty.rs:394:33: upvar_tys called before capture types are inferred

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1146:9
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_middle::ty::sty::ClosureSubsts::upvar_tys
   8: rustc_trait_selection::traits::select::candidate_assembly::<impl rustc_trait_selection::traits::select::SelectionContext>::assemble_candidates
   9: rustc_trait_selection::traits::select::candidate_assembly::<impl rustc_trait_selection::traits::select::SelectionContext>::candidate_from_obligation_no_cache
  10: rustc_trait_selection::traits::select::SelectionContext::select
  11: rustc_trait_selection::traits::fulfill::FulfillProcessor::progress_changed_obligations
  12: rustc_data_structures::obligation_forest::ObligationForest<O>::process_obligations
  13: <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_with_constness_where_possible
  14: rustc_typeck::check::fallback::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::type_inference_fallback
  15: rustc_infer::infer::InferCtxtBuilder::enter
  16: rustc_typeck::check::typeck
  17: rustc_query_system::query::plumbing::try_execute_query
  18: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  19: rustc_typeck::check::typeck
  20: rustc_query_system::query::plumbing::try_execute_query
  21: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  22: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  23: rustc_typeck::check::typeck_item_bodies
  24: rustc_query_system::query::plumbing::try_execute_query
  25: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
  26: rustc_session::utils::<impl rustc_session::session::Session>::time
  27: rustc_typeck::check_crate
  28: rustc_interface::passes::analysis
  29: rustc_query_system::query::plumbing::try_execute_query
  30: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  31: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  32: rustc_span::with_source_map
  33: rustc_interface::interface::create_compiler_and_run
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.57.0-nightly (addb4da68 2021-09-25) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [typeck] type-checking `bar`
#1 [typeck] type-checking `bar::{closure#0}`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack

@rustbot label: +requires-nightly +A-const-eval +A-const-fn

cc @fee1-dead

@nbdd0121 nbdd0121 added 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. labels Sep 27, 2021
@rustbot rustbot added A-const-eval Area: Constant evaluation (MIR interpretation) A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. requires-nightly This issue requires a nightly compiler in some way. labels Sep 27, 2021
@ghost
Copy link

ghost commented Sep 27, 2021

caused by #88558

@fee1-dead fee1-dead added the F-const_trait_impl `#![feature(const_trait_impl)]` label Sep 27, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 4, 2021
@fee1-dead
Copy link
Member

I fixed this in #89247, but I forgot to mention it in the commits and the description... Closing.

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-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. C-bug Category: This is a bug. F-const_trait_impl `#![feature(const_trait_impl)]` glacier ICE tracked in rust-lang/glacier. 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.
Projects
None yet
Development

No branches or pull requests

4 participants