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: None compiler/rustc_lint/src/array_into_iter.rs #121532

Closed
matthiaskrgr opened this issue Feb 24, 2024 · 3 comments · Fixed by #121586
Closed

ICE: None compiler/rustc_lint/src/array_into_iter.rs #121532

matthiaskrgr opened this issue Feb 24, 2024 · 3 comments · Fixed by #121586
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints 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

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Feb 24, 2024

auto-reduced (treereduce-rust):

fn get(c: Self::ItemsIterator) {
    c.into_iter();
}

original:

//@ run-pass

// https://github.com/rust-lang/rust/issues/27918

fn get(c: Self::ItemsIterator) {
        c.into_iter();
    }

Version information

rustc 1.78.0-nightly (21033f637 2024-02-23)
binary: rustc
commit-hash: 21033f637e60af61ead04cc296e7214f89c16a95
commit-date: 2024-02-23
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --crate-type=lib

Program output

warning: function `get` is never used
 --> /tmp/icemaker_global_tempdir.vhaPtHdb1FeA/rustc_testrunner_tmpdir_reporting.F8OB7kO3mXxn/mvce.rs:1:4
  |
1 | fn get(c: Self::ItemsIterator) {
  |    ^^^
  |
  = note: `#[warn(dead_code)]` on by default

thread 'rustc' panicked at compiler/rustc_lint/src/array_into_iter.rs:73:81:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7f2a7a38caf6 - std::backtrace_rs::backtrace::libunwind::trace::h60f23a8e58351682
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f2a7a38caf6 - std::backtrace_rs::backtrace::trace_unsynchronized::h671424485388f22e
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f2a7a38caf6 - std::sys_common::backtrace::_print_fmt::h31f7ee25ad0ff49b
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f2a7a38caf6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0e77fc93e0d457cf
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f2a7a3dda7c - core::fmt::rt::Argument::fmt::h8216f090320db7ad
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/core/src/fmt/rt.rs:142:9
   5:     0x7f2a7a3dda7c - core::fmt::write::h1d8b18e3b267ed00
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f2a7a38142f - std::io::Write::write_fmt::h1ed04430cc1e2dac
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/std/src/io/mod.rs:1846:15
   7:     0x7f2a7a38c8a4 - std::sys_common::backtrace::_print::h1ef5a88c19d88b2a
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f2a7a38c8a4 - std::sys_common::backtrace::print::h12cc4d72a0d4779f
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f2a7a38f5eb - std::panicking::default_hook::{{closure}}::hc148c602f99e7293
  10:     0x7f2a7a38f339 - std::panicking::default_hook::ha46c3294b51887c8
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/std/src/panicking.rs:292:9
  11:     0x7f2a7d284f0c - std[20f0fad640e3d674]::panicking::update_hook::<alloc[3412762e68fb4927]::boxed::Box<rustc_driver_impl[19440ca52c60811e]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f2a7a38fd50 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h7282ed154eb4643b
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/alloc/src/boxed.rs:2030:9
  13:     0x7f2a7a38fd50 - std::panicking::rust_panic_with_hook::h8c9157629cfdb90a
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/std/src/panicking.rs:786:13
  14:     0x7f2a7a38fa59 - std::panicking::begin_panic_handler::{{closure}}::h29c17d84617d8410
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/std/src/panicking.rs:652:13
  15:     0x7f2a7a38cfd6 - std::sys_common::backtrace::__rust_end_short_backtrace::h060d631f407f1eb0
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f2a7a38f7c4 - rust_begin_unwind
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/std/src/panicking.rs:648:5
  17:     0x7f2a7a3d9f95 - core::panicking::panic_fmt::h77781cf8a5959a4c
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/core/src/panicking.rs:72:14
  18:     0x7f2a7a3da053 - core::panicking::panic::h0157b3d9e1a77c4c
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/core/src/panicking.rs:144:5
  19:     0x7f2a7a3d9d26 - core::option::unwrap_failed::h14aef3d216c7ab4d
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/core/src/option.rs:1985:5
  20:     0x7f2a7e8857ca - <rustc_lint[8330924c420f60f8]::BuiltinCombinedModuleLateLintPass as rustc_lint[8330924c420f60f8]::passes::LateLintPass>::check_expr
  21:     0x7f2a7e87aa85 - <rustc_lint[8330924c420f60f8]::late::LateContextAndPass<rustc_lint[8330924c420f60f8]::BuiltinCombinedModuleLateLintPass> as rustc_hir[40a16d3090892c1]::intravisit::Visitor>::visit_expr
  22:     0x7f2a7e879560 - <rustc_lint[8330924c420f60f8]::late::LateContextAndPass<rustc_lint[8330924c420f60f8]::BuiltinCombinedModuleLateLintPass> as rustc_hir[40a16d3090892c1]::intravisit::Visitor>::visit_block
  23:     0x7f2a7e87a433 - <rustc_lint[8330924c420f60f8]::late::LateContextAndPass<rustc_lint[8330924c420f60f8]::BuiltinCombinedModuleLateLintPass> as rustc_hir[40a16d3090892c1]::intravisit::Visitor>::visit_expr::{closure#0}
  24:     0x7f2a7e9df291 - <rustc_lint[8330924c420f60f8]::late::LateContextAndPass<rustc_lint[8330924c420f60f8]::BuiltinCombinedModuleLateLintPass> as rustc_hir[40a16d3090892c1]::intravisit::Visitor>::visit_nested_body
  25:     0x7f2a7e936ee5 - <rustc_lint[8330924c420f60f8]::late::LateContextAndPass<rustc_lint[8330924c420f60f8]::BuiltinCombinedModuleLateLintPass> as rustc_hir[40a16d3090892c1]::intravisit::Visitor>::visit_nested_item
  26:     0x7f2a7e9352cb - rustc_lint[8330924c420f60f8]::lint_mod
  27:     0x7f2a7e9350c9 - rustc_query_impl[9020f783ef910edf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9020f783ef910edf]::query_impl::lint_mod::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2cc311d42f6fbb53]::query::erase::Erased<[u8; 0usize]>>
  28:     0x7f2a7f1dc52d - rustc_query_system[5b12415689825661]::query::plumbing::try_execute_query::<rustc_query_impl[9020f783ef910edf]::DynamicConfig<rustc_query_system[5b12415689825661]::query::caches::DefaultCache<rustc_span[28fcb2c35e4f80e4]::def_id::LocalModDefId, rustc_middle[2cc311d42f6fbb53]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[9020f783ef910edf]::plumbing::QueryCtxt, false>
  29:     0x7f2a7f1dae3f - rustc_query_impl[9020f783ef910edf]::query_impl::lint_mod::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f2a7f1da9df - rustc_lint[8330924c420f60f8]::late::check_crate::{closure#1}
  31:     0x7f2a7f1da3de - rustc_lint[8330924c420f60f8]::late::check_crate
  32:     0x7f2a7f1d42e5 - rustc_interface[379ca6a066e5a6d0]::passes::analysis
  33:     0x7f2a7f1d2fd9 - rustc_query_impl[9020f783ef910edf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9020f783ef910edf]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2cc311d42f6fbb53]::query::erase::Erased<[u8; 1usize]>>
  34:     0x7f2a7f322be5 - rustc_query_system[5b12415689825661]::query::plumbing::try_execute_query::<rustc_query_impl[9020f783ef910edf]::DynamicConfig<rustc_query_system[5b12415689825661]::query::caches::SingleCache<rustc_middle[2cc311d42f6fbb53]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[9020f783ef910edf]::plumbing::QueryCtxt, false>
  35:     0x7f2a7f322949 - rustc_query_impl[9020f783ef910edf]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f2a7f331e16 - rustc_interface[379ca6a066e5a6d0]::interface::run_compiler::<core[d2fcf87132106612]::result::Result<(), rustc_span[28fcb2c35e4f80e4]::ErrorGuaranteed>, rustc_driver_impl[19440ca52c60811e]::run_compiler::{closure#0}>::{closure#0}
  37:     0x7f2a7f5c5fc5 - std[20f0fad640e3d674]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[379ca6a066e5a6d0]::util::run_in_thread_with_globals<rustc_interface[379ca6a066e5a6d0]::util::run_in_thread_pool_with_globals<rustc_interface[379ca6a066e5a6d0]::interface::run_compiler<core[d2fcf87132106612]::result::Result<(), rustc_span[28fcb2c35e4f80e4]::ErrorGuaranteed>, rustc_driver_impl[19440ca52c60811e]::run_compiler::{closure#0}>::{closure#0}, core[d2fcf87132106612]::result::Result<(), rustc_span[28fcb2c35e4f80e4]::ErrorGuaranteed>>::{closure#0}, core[d2fcf87132106612]::result::Result<(), rustc_span[28fcb2c35e4f80e4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d2fcf87132106612]::result::Result<(), rustc_span[28fcb2c35e4f80e4]::ErrorGuaranteed>>
  38:     0x7f2a7f5c5df2 - <<std[20f0fad640e3d674]::thread::Builder>::spawn_unchecked_<rustc_interface[379ca6a066e5a6d0]::util::run_in_thread_with_globals<rustc_interface[379ca6a066e5a6d0]::util::run_in_thread_pool_with_globals<rustc_interface[379ca6a066e5a6d0]::interface::run_compiler<core[d2fcf87132106612]::result::Result<(), rustc_span[28fcb2c35e4f80e4]::ErrorGuaranteed>, rustc_driver_impl[19440ca52c60811e]::run_compiler::{closure#0}>::{closure#0}, core[d2fcf87132106612]::result::Result<(), rustc_span[28fcb2c35e4f80e4]::ErrorGuaranteed>>::{closure#0}, core[d2fcf87132106612]::result::Result<(), rustc_span[28fcb2c35e4f80e4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d2fcf87132106612]::result::Result<(), rustc_span[28fcb2c35e4f80e4]::ErrorGuaranteed>>::{closure#1} as core[d2fcf87132106612]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7f2a7a399725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h371a32ff78509abd
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/alloc/src/boxed.rs:2016:9
  40:     0x7f2a7a399725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h07b273703e10642f
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/alloc/src/boxed.rs:2016:9
  41:     0x7f2a7a399725 - std::sys::pal::unix::thread::Thread::new::thread_start::hfbd20cf5ee647cad
                               at /rustc/21033f637e60af61ead04cc296e7214f89c16a95/library/std/src/sys/pal/unix/thread.rs:108:17
  42:     0x7f2a7a18055a - <unknown>
  43:     0x7f2a7a1fda3c - <unknown>
  44:                0x0 - <unknown>

error: 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.78.0-nightly (21033f637 2024-02-23) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
#0 [lint_mod] linting top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
 --> /tmp/icemaker_global_tempdir.vhaPtHdb1FeA/rustc_testrunner_tmpdir_reporting.F8OB7kO3mXxn/mvce.rs:1:11
  |
1 | fn get(c: Self::ItemsIterator) {
  |           ^^^^ `Self` is only available in impls, traits, and type definitions

error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0433`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Feb 24, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 24, 2024
@matthiaskrgr
Copy link
Member Author

#121206 cc @nnethercote

@saethlin saethlin added A-diagnostics Area: Messages for errors, warnings, and lints and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 25, 2024
@gurry
Copy link
Contributor

gurry commented Feb 25, 2024

@rustbot claim

@gurry
Copy link
Contributor

gurry commented Feb 25, 2024

The ICE occurs due to the unwrap() on this line:

let def_id = cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap();

The underlying reason is that typeck result is tainted due to the bad arg type Self::ItemsIterator in the user's code and type_dependent_def_id() therefore returns None.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 25, 2024
…=cjgillot

Don't use `unwrap()` in `ArrayIntoIter` lint when typeck fails

Fixes rust-lang#121532
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 25, 2024
Rollup merge of rust-lang#121586 - gurry:121532-ice-unwrap-on-none, r=cjgillot

Don't use `unwrap()` in `ArrayIntoIter` lint when typeck fails

Fixes rust-lang#121532
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints 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.

4 participants