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

Compiler sometimes does not have generic_const_exprs and await play nice together #92634

Closed
gregoryquick opened this issue Jan 7, 2022 · 1 comment · Fixed by #92636
Closed
Assignees
Labels
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.

Comments

@gregoryquick
Copy link

gregoryquick commented Jan 7, 2022

Code

#![allow(incomplete_features,)]
#![feature(generic_const_exprs)]

use futures::executor::block_on;

fn main() {
    //Logging
    use std::env;
    env::set_var("RUST_BACKTRACE", "1");
    env::set_var("RUST_LOG", "info");

    block_on(test());
}

fn concat<const A: usize, const B: usize>(a: [f32; A], b: [f32; B]) -> [f32; A + B] {
    let mut array = [0f32; A + B];
    for (loc, value) in array.iter_mut().zip(a.iter().chain(b.iter())) {
        *loc = *value;
    }
    array
}

async fn reverse<const A: usize>(x: [f32; A]) -> [f32; A] {
    let mut array = [0f32; A];
    for (loc, value) in array.iter_mut().rev().zip(x.iter()) {
        *loc = *value;
    }
    array
}

async fn test() {
    let a = [0.0];
    println!("{:?}", a);
    let b = [1.0, 2.0];
    println!("{:?}", b);
    let ab = concat(a,b);
    println!("{:?}", ab);
    //You need to use await
    let ba = reverse(ab).await;
    println!("{:?}", ba);
}

Meta

Error is with generic_const_exprs

rustc --version --verbose:

rustc 1.56.0 (09c42c458 2021-10-18)
binary: rustc
commit-hash: 09c42c45858d5f3aedfa670698275303a3d19afa
commit-date: 2021-10-18
host: x86_64-apple-darwin
release: 1.56.0
LLVM version: 13.0.0

Error output

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/547a6ffee0cf4da9929a9e3d49546dc87d607735/compiler/rustc_errors/src/lib.rs:1093:9

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

note: rustc 1.58.0-nightly (547a6ffee 2021-10-21) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
#0 [optimized_mir] optimizing MIR for `test::{closure#0}`
#1 [layout_of] computing layout of `[static generator@src/main.rs:31:17: 41:2]`
end of query stack

Backtrace

stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::span_bug
   3: rustc_errors::Handler::span_bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::span_bug_fmt
   7: <rustc_mir_transform::generator::StateTransform as rustc_middle::mir::MirPass>::run_pass
   8: rustc_mir_transform::run_passes
   9: rustc_mir_transform::optimized_mir
  10: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  11: rustc_data_structures::stack::ensure_sufficient_stack
  12: rustc_query_system::query::plumbing::try_execute_query
  13: rustc_query_system::query::plumbing::get_query
  14: rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>::layout_of_uncached
  15: rustc_middle::ty::layout::layout_of
  16: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  17: rustc_data_structures::stack::ensure_sufficient_stack
  18: rustc_query_system::query::plumbing::try_execute_query
  19: rustc_query_system::query::plumbing::get_query
  20: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::layout_of
  21: rustc_middle::ty::layout::LayoutOf::layout_of
  22: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  23: <core::iter::adapters::ResultShunt<I,E> as core::iter::traits::iterator::Iterator>::next
  24: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  25: rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>::layout_of_uncached
  26: rustc_middle::ty::layout::layout_of
  27: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  28: rustc_data_structures::stack::ensure_sufficient_stack
  29: rustc_query_system::query::plumbing::try_execute_query
  30: rustc_query_system::query::plumbing::get_query
  31: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::layout_of
  32: rustc_middle::ty::layout::layout_of
  33: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  34: rustc_data_structures::stack::ensure_sufficient_stack
  35: rustc_query_system::query::plumbing::try_execute_query
  36: rustc_query_system::query::plumbing::get_query
  37: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::layout_of
  38: <rustc_mir_transform::const_prop::ConstProp as rustc_middle::mir::MirPass>::run_pass
  39: rustc_mir_transform::run_passes
  40: rustc_mir_transform::optimized_mir
  41: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  42: rustc_data_structures::stack::ensure_sufficient_stack
  43: rustc_query_system::query::plumbing::try_execute_query
  44: rustc_query_system::query::plumbing::get_query
  45: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::instance_mir
  46: rustc_monomorphize::collector::collect_neighbours
  47: rustc_monomorphize::collector::collect_items_rec
  48: rustc_session::utils::<impl rustc_session::session::Session>::time
  49: rustc_monomorphize::collector::collect_crate_mono_items
  50: rustc_monomorphize::partitioning::collect_and_partition_mono_items
  51: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  52: rustc_data_structures::stack::ensure_sufficient_stack
  53: rustc_query_system::query::plumbing::try_execute_query
  54: rustc_query_system::query::plumbing::get_query
  55: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_and_partition_mono_items
  56: rustc_codegen_ssa::base::codegen_crate
  57: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  58: rustc_session::utils::<impl rustc_session::session::Session>::time
  59: rustc_interface::queries::Queries::ongoing_codegen
  60: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  61: rustc_span::with_source_map
  62: scoped_tls::ScopedKey<T>::set

@gregoryquick gregoryquick 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 Jan 7, 2022
@compiler-errors
Copy link
Member

I actually hit this same issue with capturing un-normalized types in generator interiors when playing around with #92449.

I think I know a fix.

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 9, 2022
…-const-expr, r=oli-obk

Normalize generator-local types with unevaluated constants

Normalize generator-interior types in addition to (i.e. instead of just) erasing regions, since sometimes we collect types with unevaluated const exprs.

Fixes rust-lang#84737
Fixes rust-lang#88171
Fixes rust-lang#92091
Fixes rust-lang#92634
Probably also fixes rust-lang#73114, but that one has no code I could test. It looks like it's the same issue, though.
@bors bors closed this as completed in ca9fc28 Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants