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: Result::unwrap() on an Err value: NoMatch(…) #125876

Closed
matthiaskrgr opened this issue Jun 2, 2024 · 3 comments · Fixed by #126115
Closed

ICE: Result::unwrap() on an Err value: NoMatch(…) #125876

matthiaskrgr opened this issue Jun 2, 2024 · 3 comments · Fixed by #126115
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

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Jun 2, 2024

auto-reduced (treereduce-rust):

fn main() {
    let _result = &std::ptr::from_ref(num).cast_mut().as_deref();
}

original:

fn main() {
    let _result = &std::ptr::from_ref(num).cast_mut().as_deref();
//~^ ERROR the method
}

Version information

rustc 1.80.0-nightly (0038c0210 2024-06-01)
binary: rustc
commit-hash: 0038c021031ce9f1ec2329469c8d85d0e681ef8f
commit-date: 2024-06-01
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zincremental-verify-ich=yes -Cincremental=<dir> -Cdebuginfo=2

Program output

error[E0425]: cannot find value `num` in this scope
 --> /tmp/icemaker_global_tempdir.pGnnw8VLEFsg/rustc_testrunner_tmpdir_reporting.vEn6DdFkY3AO/mvce.rs:2:39
  |
2 |     let _result = &std::ptr::from_ref(num).cast_mut().as_deref();
  |                                       ^^^ not found in this scope

warning: type annotations needed
 --> /tmp/icemaker_global_tempdir.pGnnw8VLEFsg/rustc_testrunner_tmpdir_reporting.vEn6DdFkY3AO/mvce.rs:2:44
  |
2 |     let _result = &std::ptr::from_ref(num).cast_mut().as_deref();
  |                                            ^^^^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
  = note: for more information, see issue #46906 <https://github.com/rust-lang/rust/issues/46906>
  = note: `#[warn(tyvar_behind_raw_pointer)]` on by default

warning: type annotations needed
 --> /tmp/icemaker_global_tempdir.pGnnw8VLEFsg/rustc_testrunner_tmpdir_reporting.vEn6DdFkY3AO/mvce.rs:2:55
  |
2 |     let _result = &std::ptr::from_ref(num).cast_mut().as_deref();
  |                                                       ^^^^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
  = note: for more information, see issue #46906 <https://github.com/rust-lang/rust/issues/46906>

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/method/probe.rs:322:10:
called `Result::unwrap()` on an `Err` value: NoMatch(NoMatchData { static_candidates: [], unsatisfied_predicates: [], out_of_scope_traits: [], similar_candidate: None, mode: MethodCall })
stack backtrace:
   0:     0x714bd60ddcc5 - std::backtrace_rs::backtrace::libunwind::trace::he42dbd6b585695a2
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x714bd60ddcc5 - std::backtrace_rs::backtrace::trace_unsynchronized::he16000ea60a912d9
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x714bd60ddcc5 - std::sys_common::backtrace::_print_fmt::h66ed1913530aa332
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x714bd60ddcc5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4c845af9af61c9f6
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x714bd612e46b - core::fmt::rt::Argument::fmt::h76a6a089a8bf7b9e
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/core/src/fmt/rt.rs:165:63
   5:     0x714bd612e46b - core::fmt::write::h713abc82305939ad
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/core/src/fmt/mod.rs:1168:21
   6:     0x714bd60d2a4f - std::io::Write::write_fmt::hd65fb68dbcd2831c
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/io/mod.rs:1835:15
   7:     0x714bd60dda9e - std::sys_common::backtrace::_print::hd11b2dfc947c3c27
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x714bd60dda9e - std::sys_common::backtrace::print::h91e6f5059325feb3
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x714bd60e04d9 - std::panicking::default_hook::{{closure}}::hfdb9c1cec82aff8b
  10:     0x714bd60e027a - std::panicking::default_hook::hb086bae11ee046f4
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/panicking.rs:298:9
  11:     0x714bd2749fa0 - std[63b5957b5a953143]::panicking::update_hook::<alloc[cae7206fa00581b7]::boxed::Box<rustc_driver_impl[8353f43e004ca277]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x714bd60e0c0b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h9fe9d644c417a734
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/alloc/src/boxed.rs:2077:9
  13:     0x714bd60e0c0b - std::panicking::rust_panic_with_hook::h40c11300784b4c18
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/panicking.rs:799:13
  14:     0x714bd60e0984 - std::panicking::begin_panic_handler::{{closure}}::h5bab24fe1d95fd1a
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/panicking.rs:664:13
  15:     0x714bd60de189 - std::sys_common::backtrace::__rust_end_short_backtrace::h0b77baf02d4c787a
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x714bd60e06b7 - rust_begin_unwind
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/panicking.rs:652:5
  17:     0x714bd612aa03 - core::panicking::panic_fmt::h90145c2d43445af9
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/core/src/panicking.rs:72:14
  18:     0x714bd612b076 - core::result::unwrap_failed::h85dcb81186623b69
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/core/src/result.rs:1679:5
  19:     0x714bd29c1c7f - <rustc_hir_typeck[850ee040d7edf3c3]::fn_ctxt::FnCtxt>::probe_for_name_many
  20:     0x714bd299a1b2 - <rustc_hir_typeck[850ee040d7edf3c3]::fn_ctxt::FnCtxt>::report_no_match_method_error
  21:     0x714bd29c1f34 - <rustc_hir_typeck[850ee040d7edf3c3]::fn_ctxt::FnCtxt>::report_method_error
  22:     0x714bd445ff46 - <rustc_hir_typeck[850ee040d7edf3c3]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  23:     0x714bd4454607 - <rustc_hir_typeck[850ee040d7edf3c3]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24:     0x714bd444d091 - <rustc_hir_typeck[850ee040d7edf3c3]::fn_ctxt::FnCtxt>::check_decl
  25:     0x714bd444fd87 - <rustc_hir_typeck[850ee040d7edf3c3]::fn_ctxt::FnCtxt>::check_block_with_expected
  26:     0x714bd4453f75 - <rustc_hir_typeck[850ee040d7edf3c3]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  27:     0x714bd440fe58 - rustc_hir_typeck[850ee040d7edf3c3]::check::check_fn
  28:     0x714bd440556c - rustc_hir_typeck[850ee040d7edf3c3]::typeck
  29:     0x714bd4404fd1 - rustc_query_impl[cd510f8c05a0ea8a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cd510f8c05a0ea8a]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 8usize]>>
  30:     0x714bd42038c2 - rustc_query_system[93cd2bfd03b3866f]::query::plumbing::try_execute_query::<rustc_query_impl[cd510f8c05a0ea8a]::DynamicConfig<rustc_query_system[93cd2bfd03b3866f]::query::caches::VecCache<rustc_span[25512e2860c1584]::def_id::LocalDefId, rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[cd510f8c05a0ea8a]::plumbing::QueryCtxt, true>
  31:     0x714bd4172554 - rustc_query_impl[cd510f8c05a0ea8a]::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
  32:     0x714bd41feecb - <rustc_middle[6c616825b0bcdb80]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[d5af9a64c4217f61]::check_crate::{closure#4}>::{closure#0}
  33:     0x714bd41fd98b - rustc_hir_analysis[d5af9a64c4217f61]::check_crate
  34:     0x714bd415dbbe - rustc_interface[68582a38c0a5d471]::passes::analysis
  35:     0x714bd415d71b - rustc_query_impl[cd510f8c05a0ea8a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cd510f8c05a0ea8a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 1usize]>>
  36:     0x714bd49a004e - rustc_query_system[93cd2bfd03b3866f]::query::plumbing::try_execute_query::<rustc_query_impl[cd510f8c05a0ea8a]::DynamicConfig<rustc_query_system[93cd2bfd03b3866f]::query::caches::SingleCache<rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[cd510f8c05a0ea8a]::plumbing::QueryCtxt, true>
  37:     0x714bd499fc7a - rustc_query_impl[cd510f8c05a0ea8a]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  38:     0x714bd47df0e0 - rustc_interface[68582a38c0a5d471]::interface::run_compiler::<core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>, rustc_driver_impl[8353f43e004ca277]::run_compiler::{closure#0}>::{closure#1}
  39:     0x714bd47cab89 - std[63b5957b5a953143]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[68582a38c0a5d471]::util::run_in_thread_with_globals<rustc_interface[68582a38c0a5d471]::util::run_in_thread_pool_with_globals<rustc_interface[68582a38c0a5d471]::interface::run_compiler<core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>, rustc_driver_impl[8353f43e004ca277]::run_compiler::{closure#0}>::{closure#1}, core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>>::{closure#0}, core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>>
  40:     0x714bd47ca940 - <<std[63b5957b5a953143]::thread::Builder>::spawn_unchecked_<rustc_interface[68582a38c0a5d471]::util::run_in_thread_with_globals<rustc_interface[68582a38c0a5d471]::util::run_in_thread_pool_with_globals<rustc_interface[68582a38c0a5d471]::interface::run_compiler<core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>, rustc_driver_impl[8353f43e004ca277]::run_compiler::{closure#0}>::{closure#1}, core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>>::{closure#0}, core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>>::{closure#2} as core[b73d62a4aa8e98c4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x714bd60eabfb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd9dcc2087244c614
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/alloc/src/boxed.rs:2063:9
  42:     0x714bd60eabfb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1ce3b5bddc9a8858
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/alloc/src/boxed.rs:2063:9
  43:     0x714bd60eabfb - std::sys::pal::unix::thread::Thread::new::thread_start::h3072c5274e382bf5
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/sys/pal/unix/thread.rs:108:17
  44:     0x714bd5e871cf - <unknown>
  45:     0x714bd5f086ec - <unknown>
  46:                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: please make sure that you have updated to the latest nightly

note: rustc 1.80.0-nightly (0038c0210 2024-06-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2

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

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

@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 Jun 2, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 2, 2024
@matthiaskrgr
Copy link
Member Author

#125466 cc @compiler-errors ^^

@matthiaskrgr
Copy link
Member Author

fn main() {
    std::ptr::from_ref(NOPE).cast_mut().as_deref();
}

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 2, 2024
@fmease fmease changed the title ICE: Result::unwrap() on an Err value: NoMatch(NoMatchData .. ` ICE: Result::unwrap() on an Err value: NoMatch(…) Jun 2, 2024
@gurry
Copy link
Contributor

gurry commented Jun 7, 2024

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 10, 2024
…-result, r=compiler-errors

Fix ICE due to `unwrap` in `probe_for_name_many`

Fixes rust-lang#125876

Now `probe_for_name_many` bubbles up the error returned by `probe_op` instead of calling `unwrap` on it.
@bors bors closed this as completed in bcc6fda Jun 10, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 10, 2024
Rollup merge of rust-lang#126115 - gurry:125876-ice-unwrap-probe-many-result, r=compiler-errors

Fix ICE due to `unwrap` in `probe_for_name_many`

Fixes rust-lang#125876

Now `probe_for_name_many` bubbles up the error returned by `probe_op` instead of calling `unwrap` on it.
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.

4 participants