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: expected usize, got N/#0: usize #123906

Closed
cushionbadak opened this issue Apr 14, 2024 · 1 comment · Fixed by #123924
Closed

ICE: expected usize, got N/#0: usize #123906

cushionbadak opened this issue Apr 14, 2024 · 1 comment · Fixed by #123924
Assignees
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cushionbadak
Copy link

cushionbadak commented Apr 14, 2024

Code

(reduced)

fn as_chunks<const N: usize>() -> [u8; N] {
    loop {
        break;
    }
}

fn main() {}
Original Code

//@ check-pass
//
// Instead of checking that an error occurs without the feature gate,

fn as_chunks<const N: usize>() -> [u8; N] {
    loop {
        let _r = &[D(log, 30),
                  D(log, 31),
                  { D(log, 32); break; },
                  D(log, 33)][..];
    }
}

fn main() {
    let [_, _] = as_chunks();
}

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (0bf471f33 2024-04-13)
binary: rustc
commit-hash: 0bf471f339837af930ec90ef5e1e9cb232e99f29
commit-date: 2024-04-13
host: aarch64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.3

Command

rustc

Error output

<output>
Backtrace

error: internal compiler error: /rustc/0bf471f339837af930ec90ef5e1e9cb232e99f29/compiler/rustc_middle/src/ty/consts.rs:437:32: expected usize, got N/#0: usize

thread 'rustc' panicked at /rustc/0bf471f339837af930ec90ef5e1e9cb232e99f29/compiler/rustc_middle/src/ty/consts.rs:437:32:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: rustc_hir_analysis::check::ty_kind_suggestion
   7: <rustc_hir_typeck::coercion::CoerceMany<&rustc_hir::hir::Expr>>::coerce_inner::<<rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_break::{closure#2}>
   8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
   9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_stmt
  11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
  12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
  15: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  16: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_expr
  17: rustc_hir_typeck::check::check_fn
  18: rustc_hir_typeck::typeck
      [... omitted 2 frames ...]
  19: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_hir_analysis::check_crate::{closure#4}>::{closure#0}
  20: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures::sync::parallel::enabled::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_hir_analysis::check_crate::{closure#4}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  21: rustc_hir_analysis::check_crate
  22: rustc_interface::passes::analysis
      [... omitted 2 frames ...]
  23: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#3}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  24: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
  25: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}::{closure#0}>
  26: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  27: rustc_span::create_session_globals_then::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/jisukbyun/workspace/placeholder/0413_rust/rustc-ice-2024-04-14T03_01_42-57049.txt` to your bug report

query stack during panic:
#0 [typeck] type-checking `as_chunks`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error

Note

@cushionbadak cushionbadak 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 Apr 14, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 14, 2024
@cushionbadak cushionbadak changed the title ICE: expected usize, got got N/#0: usize ICE: expected usize, got N/#0: usize Apr 14, 2024
@compiler-errors compiler-errors self-assigned this Apr 14, 2024
@jieyouxu jieyouxu added A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. A-const-generics Area: const generics (parameters and arguments) S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 15, 2024
@bors bors closed this as completed in 20a5fb3 Apr 15, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 15, 2024
Rollup merge of rust-lang#123924 - compiler-errors:tuple-sugg, r=estebank

Fix various bugs in `ty_kind_suggestion`

Consolidates two implementations of `ty_kind_suggestion`
Fixes some misuse of the empty param-env
Fixes a problem where we suggested `(42)` instead of `(42,)` for tuple suggestions
Suggest a value when `return;`, making it consistent with `break;`
Fixes rust-lang#123906
@cushionbadak
Copy link
Author

searched nightlies: from nightly-2024-01-01 to nightly-2024-04-14
regressed nightly: nightly-2024-04-12
searched commit range: aa067fb...a07f3eb
regressed commit: 241fc13

bisected with cargo-bisect-rustc v0.6.8

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start 2024-01-01 --end 2024-04-14 --preserve --regress ice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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