Skip to content

thread 'rustc' panicked at 'expression with never type wound up being adjusted' #96335

Closed
@Badel2

Description

@Badel2

I'm seeing an internal compiler error on the following input, found by fuzz-rustc:

Code

fn main() {
    0.....{loop{}1}
}

Error output

error: unexpected token: `...`
 --> src/main.rs:2:6
  |
2 |     0.....{loop{}1}
  |      ^^^
  |
help: use `..` for an exclusive range
  |
2 |     0....{loop{}1}
  |      ~~
help: or `..=` for an inclusive range
  |
2 |     0..=..{loop{}1}
  |      ~~~

warning: unreachable expression
 --> src/main.rs:2:18
  |
2 |     0.....{loop{}1}
  |            ------^ unreachable expression
  |            |
  |            any code following this expression is unreachable
  |
  = note: `#[warn(unreachable_code)]` on by default
thread 'rustc' panicked at 'expression with never type wound up being adjusted', compiler/rustc_typeck/src/check/expr.rs:81:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The ICE happens after reporting some other errors, so I guess low priority. Affected versions: nightly 2022-04-22 does show the ICE, but beta 1.61.0-beta.3 does not show the ICE.

Backtrace

Compiling playground v0.0.1 (/playground)
error: unexpected token: `...`
 --> src/main.rs:2:6
  |
2 |     0.....{loop{}1}
  |      ^^^
  |
help: use `..` for an exclusive range
  |
2 |     0....{loop{}1}
  |      ~~
help: or `..=` for an inclusive range
  |
2 |     0..=..{loop{}1}
  |      ~~~

warning: unreachable expression
 --> src/main.rs:2:18
  |
2 |     0.....{loop{}1}
  |            ------^ unreachable expression
  |            |
  |            any code following this expression is unreachable
  |
  = note: `#[warn(unreachable_code)]` on by default

thread 'rustc' panicked at 'expression with never type wound up being adjusted', compiler/rustc_typeck/src/check/expr.rs:81:13
stack backtrace:
   0:     0x7f56b6c4ca1d - std::backtrace_rs::backtrace::libunwind::trace::hd6a59a52e7b1dd59
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f56b6c4ca1d - std::backtrace_rs::backtrace::trace_unsynchronized::hc6bcdfd472eaf870
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f56b6c4ca1d - std::sys_common::backtrace::_print_fmt::h36b5dc9a2ec57a70
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f56b6c4ca1d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4d029b4479317c06
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f56b6ca815c - core::fmt::write::h0c609830781888bc
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/core/src/fmt/mod.rs:1194:17
   5:     0x7f56b6c3e1b1 - std::io::Write::write_fmt::hbc89661190661b99
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/io/mod.rs:1655:15
   6:     0x7f56b6c4f735 - std::sys_common::backtrace::_print::he8c6f6d669996019
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f56b6c4f735 - std::sys_common::backtrace::print::h1592ad495df89a1b
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f56b6c4f735 - std::panicking::default_hook::{{closure}}::h5e12203b936882f8
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/panicking.rs:295:22
   9:     0x7f56b6c4f3a9 - std::panicking::default_hook::h9478b8b8f3ef11ae
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/panicking.rs:314:9
  10:     0x7f56b73edd01 - rustc_driver[15079dfc84a3112]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f56b6c4ff06 - std::panicking::rust_panic_with_hook::he5c0805237a49bfb
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/panicking.rs:702:17
  12:     0x7f56b6c4fcc9 - std::panicking::begin_panic_handler::{{closure}}::he9c58435c507a51a
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/panicking.rs:586:13
  13:     0x7f56b6c4ced4 - std::sys_common::backtrace::__rust_end_short_backtrace::had0581f0f7999998
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f56b6c4fa39 - rust_begin_unwind
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/panicking.rs:584:5
  15:     0x7f56b6c14d33 - core::panicking::panic_fmt::he1176ceec0d9f6c7
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/core/src/panicking.rs:142:14
  16:     0x7f56b889bcc5 - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_stmt
  17:     0x7f56b889c380 - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_block_with_expected
  18:     0x7f56b88adf13 - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_expr_kind
  19:     0x7f56b88acc20 - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  20:     0x7f56b967dcc0 - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_expr_struct_fields
  21:     0x7f56b88af5ea - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_expr_kind
  22:     0x7f56b77ce47d - <core[26ec97baa1f5afe1]::iter::adapters::map::Map<core[26ec97baa1f5afe1]::ops::range::Range<usize>, <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::ArgMatrix>::new<<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>::{closure#0}::{closure#0}> as core[26ec97baa1f5afe1]::iter::traits::iterator::Iterator>::fold::<(), core[26ec97baa1f5afe1]::iter::traits::iterator::Iterator::for_each::call<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::Compatibility, <alloc[6d9f8db8507809ec]::vec::Vec<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::Compatibility> as alloc[6d9f8db8507809ec]::vec::spec_extend::SpecExtend<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::Compatibility, core[26ec97baa1f5afe1]::iter::adapters::map::Map<core[26ec97baa1f5afe1]::ops::range::Range<usize>, <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::ArgMatrix>::new<<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>::{closure#0}::{closure#0}>>>::spec_extend::{closure#0}>::{closure#0}>
  23:     0x7f56b77bdf37 - <alloc[6d9f8db8507809ec]::vec::Vec<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::Compatibility> as alloc[6d9f8db8507809ec]::vec::spec_from_iter::SpecFromIter<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::Compatibility, core[26ec97baa1f5afe1]::iter::adapters::map::Map<core[26ec97baa1f5afe1]::ops::range::Range<usize>, <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::ArgMatrix>::new<<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>::{closure#0}::{closure#0}>>>::from_iter
  24:     0x7f56b77ce2a4 - <core[26ec97baa1f5afe1]::iter::adapters::map::Map<core[26ec97baa1f5afe1]::ops::range::Range<usize>, <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::ArgMatrix>::new<<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>::{closure#0}> as core[26ec97baa1f5afe1]::iter::traits::iterator::Iterator>::fold::<(), core[26ec97baa1f5afe1]::iter::traits::iterator::Iterator::for_each::call<alloc[6d9f8db8507809ec]::vec::Vec<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::Compatibility>, <alloc[6d9f8db8507809ec]::vec::Vec<alloc[6d9f8db8507809ec]::vec::Vec<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::Compatibility>> as alloc[6d9f8db8507809ec]::vec::spec_extend::SpecExtend<alloc[6d9f8db8507809ec]::vec::Vec<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::Compatibility>, core[26ec97baa1f5afe1]::iter::adapters::map::Map<core[26ec97baa1f5afe1]::ops::range::Range<usize>, <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::ArgMatrix>::new<<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>::{closure#0}>>>::spec_extend::{closure#0}>::{closure#0}>
  25:     0x7f56b77b7205 - <alloc[6d9f8db8507809ec]::vec::Vec<alloc[6d9f8db8507809ec]::vec::Vec<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::Compatibility>> as alloc[6d9f8db8507809ec]::vec::spec_from_iter::SpecFromIter<alloc[6d9f8db8507809ec]::vec::Vec<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::Compatibility>, core[26ec97baa1f5afe1]::iter::adapters::map::Map<core[26ec97baa1f5afe1]::ops::range::Range<usize>, <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::ArgMatrix>::new<<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>::{closure#0}>>>::from_iter
  26:     0x7f56b778cb65 - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::arg_matrix::ArgMatrix>::new::<<rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>
  27:     0x7f56b887821f - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_argument_types
  28:     0x7f56b885c17e - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::confirm_builtin_call
  29:     0x7f56b88585e8 - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_call
  30:     0x7f56b88added - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_expr_kind
  31:     0x7f56b88acc20 - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  32:     0x7f56b889c3bb - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_block_with_expected
  33:     0x7f56b88adf13 - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_expr_kind
  34:     0x7f56b88acc20 - <rustc_typeck[fa7863cc59fb737d]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  35:     0x7f56b88d6f7e - rustc_typeck[fa7863cc59fb737d]::check::check::check_fn
  36:     0x7f56b892ca6d - <rustc_infer[58c7ef1f7122eb2e]::infer::InferCtxtBuilder>::enter::<&rustc_middle[5eaaecf938a50c51]::ty::context::TypeckResults, <rustc_typeck[fa7863cc59fb737d]::check::inherited::InheritedBuilder>::enter<rustc_typeck[fa7863cc59fb737d]::check::typeck_with_fallback<rustc_typeck[fa7863cc59fb737d]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[5eaaecf938a50c51]::ty::context::TypeckResults>::{closure#0}>
  37:     0x7f56b88ff82a - rustc_typeck[fa7863cc59fb737d]::check::typeck
  38:     0x7f56b8dfd790 - rustc_query_system[5199b465427c9459]::query::plumbing::try_execute_query::<rustc_query_impl[542036c3062ad20]::plumbing::QueryCtxt, rustc_query_system[5199b465427c9459]::query::caches::DefaultCache<rustc_span[47366e988d88fc14]::def_id::LocalDefId, &rustc_middle[5eaaecf938a50c51]::ty::context::TypeckResults>>
  39:     0x7f56b8f06028 - <rustc_query_impl[542036c3062ad20]::Queries as rustc_middle[5eaaecf938a50c51]::ty::query::QueryEngine>::typeck
  40:     0x7f56b89af038 - <rustc_middle[5eaaecf938a50c51]::hir::map::Map>::par_body_owners::<rustc_typeck[fa7863cc59fb737d]::check::typeck_item_bodies::{closure#0}>
  41:     0x7f56b96b341c - rustc_typeck[fa7863cc59fb737d]::check::typeck_item_bodies
  42:     0x7f56b990da42 - rustc_query_system[5199b465427c9459]::query::plumbing::try_execute_query::<rustc_query_impl[542036c3062ad20]::plumbing::QueryCtxt, rustc_query_system[5199b465427c9459]::query::caches::DefaultCache<(), ()>>
  43:     0x7f56b9934b81 - rustc_query_system[5199b465427c9459]::query::plumbing::get_query::<rustc_query_impl[542036c3062ad20]::queries::typeck_item_bodies, rustc_query_impl[542036c3062ad20]::plumbing::QueryCtxt>
  44:     0x7f56b96c22f3 - <rustc_session[99383896a68e820c]::session::Session>::time::<(), rustc_typeck[fa7863cc59fb737d]::check_crate::{closure#7}>
  45:     0x7f56b96bfe63 - rustc_typeck[fa7863cc59fb737d]::check_crate
  46:     0x7f56b9442cd7 - rustc_interface[837f243751cb994f]::passes::analysis
  47:     0x7f56b9903b74 - rustc_query_system[5199b465427c9459]::query::plumbing::try_execute_query::<rustc_query_impl[542036c3062ad20]::plumbing::QueryCtxt, rustc_query_system[5199b465427c9459]::query::caches::DefaultCache<(), core[26ec97baa1f5afe1]::result::Result<(), rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>>>
  48:     0x7f56b994498e - rustc_query_system[5199b465427c9459]::query::plumbing::get_query::<rustc_query_impl[542036c3062ad20]::queries::analysis, rustc_query_impl[542036c3062ad20]::plumbing::QueryCtxt>
  49:     0x7f56b941e7f7 - <rustc_interface[837f243751cb994f]::passes::QueryContext>::enter::<rustc_driver[15079dfc84a3112]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[26ec97baa1f5afe1]::result::Result<(), rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>>
  50:     0x7f56b9409418 - <rustc_interface[837f243751cb994f]::interface::Compiler>::enter::<rustc_driver[15079dfc84a3112]::run_compiler::{closure#1}::{closure#2}, core[26ec97baa1f5afe1]::result::Result<core[26ec97baa1f5afe1]::option::Option<rustc_interface[837f243751cb994f]::queries::Linker>, rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>>
  51:     0x7f56b9432d9f - rustc_span[47366e988d88fc14]::with_source_map::<core[26ec97baa1f5afe1]::result::Result<(), rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>, rustc_interface[837f243751cb994f]::interface::create_compiler_and_run<core[26ec97baa1f5afe1]::result::Result<(), rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>, rustc_driver[15079dfc84a3112]::run_compiler::{closure#1}>::{closure#1}>
  52:     0x7f56b941d714 - rustc_interface[837f243751cb994f]::interface::create_compiler_and_run::<core[26ec97baa1f5afe1]::result::Result<(), rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>, rustc_driver[15079dfc84a3112]::run_compiler::{closure#1}>
  53:     0x7f56b9406921 - <scoped_tls[1a6277c61c1e4f26]::ScopedKey<rustc_span[47366e988d88fc14]::SessionGlobals>>::set::<rustc_interface[837f243751cb994f]::interface::run_compiler<core[26ec97baa1f5afe1]::result::Result<(), rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>, rustc_driver[15079dfc84a3112]::run_compiler::{closure#1}>::{closure#0}, core[26ec97baa1f5afe1]::result::Result<(), rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>>
  54:     0x7f56b941feef - std[b00d0cd10ed18eb]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[837f243751cb994f]::util::run_in_thread_pool_with_globals<rustc_interface[837f243751cb994f]::interface::run_compiler<core[26ec97baa1f5afe1]::result::Result<(), rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>, rustc_driver[15079dfc84a3112]::run_compiler::{closure#1}>::{closure#0}, core[26ec97baa1f5afe1]::result::Result<(), rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>>::{closure#0}, core[26ec97baa1f5afe1]::result::Result<(), rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>>
  55:     0x7f56b9420029 - <<std[b00d0cd10ed18eb]::thread::Builder>::spawn_unchecked_<rustc_interface[837f243751cb994f]::util::run_in_thread_pool_with_globals<rustc_interface[837f243751cb994f]::interface::run_compiler<core[26ec97baa1f5afe1]::result::Result<(), rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>, rustc_driver[15079dfc84a3112]::run_compiler::{closure#1}>::{closure#0}, core[26ec97baa1f5afe1]::result::Result<(), rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>>::{closure#0}, core[26ec97baa1f5afe1]::result::Result<(), rustc_errors[1cc09afc534cd467]::ErrorGuaranteed>>::{closure#1} as core[26ec97baa1f5afe1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  56:     0x7f56b6c59e53 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4eefbdc6e759aaf9
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/alloc/src/boxed.rs:1866:9
  57:     0x7f56b6c59e53 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h58e12ebf42bc0fa9
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/alloc/src/boxed.rs:1866:9
  58:     0x7f56b6c59e53 - std::sys::unix::thread::Thread::new::thread_start::h9bd57a8145f8d4d0
                               at /rustc/f4ec0e7cff545e932ce30e39087b16687f0affa1/library/std/src/sys/unix/thread.rs:108:17
  59:     0x7f56b6b8a609 - start_thread
  60:     0x7f56b6aa3163 - clone
  61:                0x0 - <unknown>

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.62.0-nightly (f4ec0e7cf 2022-04-22) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [typeck] type-checking `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
warning: `playground` (bin "playground") generated 1 warning
error: could not compile `playground` due to previous error; 1 warning emitted

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions