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: infer: None #120786

Open
matthiaskrgr opened this issue Feb 8, 2024 · 0 comments
Open

ice: infer: None #120786

matthiaskrgr opened this issue Feb 8, 2024 · 0 comments
Labels
A-parallel-queries Area: Parallel query execution C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-compiler-parallel Working group: Parallelizing the compiler

Comments

@matthiaskrgr
Copy link
Member

Code

fn no_err() {
    |x: u32, y| x;
    let _ = String::from("x");
}

fn err() {
    String::from("x".as_ref()); //~ ERROR type annotations needed
    //~^ ERROR type annotations needed
}

fn arg_pat_closure_err() {
    |x| String::from("x".as_ref()); //~ ERROR type annotations needed
    //~| ERROR type annotations needed
}

fn local_pat_closure_err() {
    let _ = "x".as_ref(); //~ ERROR type annotations needed
}

fn err_first_arg_pat() {
    String::from("x".as_ref()); //~ ERROR type annotations needed
    //~^ ERROR type annotations needed
    |x: String| x;
}

fn err_second_arg_pat() {
    |x: String| x;
    String::from("x".as_ref()); //~ ERROR type annotations needed
    //~^ ERROR type annotations needed
}

fn err_mid_arg_pat() {
    |x: String| x;
    |x: String| x;
    |x: String| x;
    |x: String| x;
    String::from("x".as_ref()); //~ ERROR type annotations needed
    //~^ ERROR type annotations needed
    |x: String| x;
    |x: String| x;
    |x: String| x;
    |x: String| x;
}

fn err_first_local_pat() {
    String::from("x".as_ref()); //~ ERROR type annotations needed
    //~^ ERROR type annotations needed
    let _ = String::from("x");
}

fn err_second_local_pat() {
    let _ = String::from("x");
    String::from("x".as_ref()); //~ ERROR type annotations needed
    //~^ ERROR type annotations needed
}

fn err_mid_local_pat() {
    let _ = String::from("x");
    let _ = String::from("x");
    let _ = String::from("x");
    let _ = String::from("x");
    String::from("x".as_ref()); //~ ERROR type annotations needed
    //~^ ERROR type annotations needed
    let _ = String::from("x");
    let _ = String::from("x");
    let _ = String::from("x");
    let _ = String::from("x");
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.78.0-nightly (8ace7ea1f 2024-02-07)
binary: rustc
commit-hash: 8ace7ea1f7cbba7b4f031e66c54ca237a0d65de6
commit-date: 2024-02-07
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 17.0.6

Error output

rustc -Zthreads=50 file.rs

<output>
Backtrace

thread 'rustc' panicked at compiler/rustc_infer/src/infer/mod.rs:1278:45:
called `Option::unwrap()` on a `None` value
stack backtrace:
error[E0282]: type annotations needed
 --> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/inference/icemaker_omni/83A8D26775DFE61B5ACEB8F5BBBCC9118160C06359A9F9CE6876FB0542C02E8B.rs:2:14
  |
2 |     |x: u32, y| x;
  |              ^
  |
help: consider giving this closure parameter an explicit type
  |
2 |     |x: u32, y: /* Type */| x;
  |               ++++++++++++

   0:     0x7f366b78bdd6 - std::backtrace_rs::backtrace::libunwind::trace::h3831425a8c62a633
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f366b78bdd6 - std::backtrace_rs::backtrace::trace_unsynchronized::h2fc724c88ff08839
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f366b78bdd6 - std::sys_common::backtrace::_print_fmt::h95f916a0967460aa
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f366b78bdd6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6cd68701047c0caa
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f366b7de830 - core::fmt::rt::Argument::fmt::h22a3e18db30b5f5c
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/core/src/fmt/rt.rs:142:9
   5:     0x7f366b7de830 - core::fmt::write::h51c6cab738a5636e
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f366b77f64f - std::io::Write::write_fmt::h0e7b1c53ac5d599c
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/std/src/io/mod.rs:1854:15
   7:     0x7f366b78bbb4 - std::sys_common::backtrace::_print::he764b65827afec48
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f366b78bbb4 - std::sys_common::backtrace::print::h226a34223202b222
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f366b78e947 - std::panicking::default_hook::{{closure}}::h4c4a976f47b9412f
  10:     0x7f366b78e6a9 - std::panicking::default_hook::hc9a358e8ba986d56
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/std/src/panicking.rs:292:9
  11:     0x7f366e5461dc - std[73a469d20558648b]::panicking::update_hook::<alloc[2e68a68d8689d34a]::boxed::Box<rustc_driver_impl[f8352181a07c1cd]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f366b78f096 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h78b006c40953b959
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/alloc/src/boxed.rs:2029:9
  13:     0x7f366b78f096 - std::panicking::rust_panic_with_hook::h6afbbd1388602f36
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/std/src/panicking.rs:785:13
  14:     0x7f366b78eda9 - std::panicking::begin_panic_handler::{{closure}}::h7a0fdbd05ed23de2
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/std/src/panicking.rs:651:13
  15:     0x7f366b78c2d6 - std::sys_common::backtrace::__rust_end_short_backtrace::h746afb5c969401c8
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f366b78eb34 - rust_begin_unwind
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/std/src/panicking.rs:647:5
  17:     0x7f366b7daf35 - core::panicking::panic_fmt::h905601d0f533eda2
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/core/src/panicking.rs:72:14
  18:     0x7f366b7daff3 - core::panicking::panic::heeb173fb9d23c6e8
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/core/src/panicking.rs:144:5
  19:     0x7f366b7dac76 - core::option::unwrap_failed::h00f0c8f2574f719c
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/core/src/option.rs:1978:5
  20:     0x7f366e8116ab - <rustc_infer[7671e5ca5155ec05]::infer::InferCtxt>::tainted_by_errors
  21:     0x7f366f057dee - <rustc_infer[7671e5ca5155ec05]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[41b0846030f76e18]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::maybe_report_ambiguity
  22:     0x7f366f02755d - <rustc_infer[7671e5ca5155ec05]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[41b0846030f76e18]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
  23:     0x7f366f99f94e - rustc_hir_typeck[a4b0ebaebf994b96]::typeck
  24:     0x7f366f99b425 - rustc_query_impl[b5308dd618a6aaad]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b5308dd618a6aaad]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[23db07fc9493ca4d]::query::erase::Erased<[u8; 8usize]>>
  25:     0x7f366f99a43a - rustc_query_system[822ffd8c0bece46]::query::plumbing::try_execute_query::<rustc_query_impl[b5308dd618a6aaad]::DynamicConfig<rustc_query_system[822ffd8c0bece46]::query::caches::VecCache<rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId, rustc_middle[23db07fc9493ca4d]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[b5308dd618a6aaad]::plumbing::QueryCtxt, false>
  26:     0x7f366f99a010 - rustc_query_impl[b5308dd618a6aaad]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7f366f9997d6 - <rustc_middle[23db07fc9493ca4d]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[994101d8878d4c5e]::check_crate::{closure#5}>::{closure#0}
  28:     0x7f366e611a7a - rayon[33b8fa4f0eaed63f]::iter::plumbing::bridge_producer_consumer::helper::<rayon[33b8fa4f0eaed63f]::slice::IterProducer<rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId>, rayon[33b8fa4f0eaed63f]::iter::for_each::ForEachConsumer<rustc_data_structures[36259d92a3c67969]::sync::parallel::enabled::par_for_each_in<&rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId, &[rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId], <rustc_middle[23db07fc9493ca4d]::hir::map::Map>::par_body_owners<rustc_hir_analysis[994101d8878d4c5e]::check_crate::{closure#5}>::{closure#0}>::{closure#0}::{closure#0}>>
  29:     0x7f366e62176f - rayon_core[5ca6c2e1d288545f]::join::join_context::<rayon[33b8fa4f0eaed63f]::iter::plumbing::bridge_producer_consumer::helper<rayon[33b8fa4f0eaed63f]::slice::IterProducer<rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId>, rayon[33b8fa4f0eaed63f]::iter::for_each::ForEachConsumer<rustc_data_structures[36259d92a3c67969]::sync::parallel::enabled::par_for_each_in<&rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId, &[rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId], <rustc_middle[23db07fc9493ca4d]::hir::map::Map>::par_body_owners<rustc_hir_analysis[994101d8878d4c5e]::check_crate::{closure#5}>::{closure#0}>::{closure#0}::{closure#0}>>::{closure#0}, rayon[33b8fa4f0eaed63f]::iter::plumbing::bridge_producer_consumer::helper<rayon[33b8fa4f0eaed63f]::slice::IterProducer<rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId>, rayon[33b8fa4f0eaed63f]::iter::for_each::ForEachConsumer<rustc_data_structures[36259d92a3c67969]::sync::parallel::enabled::par_for_each_in<&rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId, &[rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId], <rustc_middle[23db07fc9493ca4d]::hir::map::Map>::par_body_owners<rustc_hir_analysis[994101d8878d4c5e]::check_crate::{closure#5}>::{closure#0}>::{closure#0}::{closure#0}>>::{closure#1}, (), ()>::{closure#0}
  30:     0x7f366e611c19 - rayon[33b8fa4f0eaed63f]::iter::plumbing::bridge_producer_consumer::helper::<rayon[33b8fa4f0eaed63f]::slice::IterProducer<rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId>, rayon[33b8fa4f0eaed63f]::iter::for_each::ForEachConsumer<rustc_data_structures[36259d92a3c67969]::sync::parallel::enabled::par_for_each_in<&rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId, &[rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId], <rustc_middle[23db07fc9493ca4d]::hir::map::Map>::par_body_owners<rustc_hir_analysis[994101d8878d4c5e]::check_crate::{closure#5}>::{closure#0}>::{closure#0}::{closure#0}>>
  31:     0x7f366e634222 - <rayon_core[5ca6c2e1d288545f]::job::StackJob<rayon_core[5ca6c2e1d288545f]::latch::SpinLatch, rayon_core[5ca6c2e1d288545f]::join::join_context::call_b<(), rayon[33b8fa4f0eaed63f]::iter::plumbing::bridge_producer_consumer::helper<rayon[33b8fa4f0eaed63f]::slice::IterProducer<rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId>, rayon[33b8fa4f0eaed63f]::iter::for_each::ForEachConsumer<rustc_data_structures[36259d92a3c67969]::sync::parallel::enabled::par_for_each_in<&rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId, &[rustc_span[e47623fb3a0ceb98]::def_id::LocalDefId], <rustc_middle[23db07fc9493ca4d]::hir::map::Map>::par_body_owners<rustc_hir_analysis[994101d8878d4c5e]::check_crate::{closure#5}>::{closure#0}>::{closure#0}::{closure#0}>>::{closure#1}>::{closure#0}, ()> as rayon_core[5ca6c2e1d288545f]::job::Job>::execute
  32:     0x7f366e14ffc5 - <rayon_core[5ca6c2e1d288545f]::registry::WorkerThread>::wait_until_cold
  33:     0x7f366e14cab3 - <rayon_core[5ca6c2e1d288545f]::registry::ThreadBuilder>::run
  34:     0x7f366e547fd7 - <<crossbeam_utils[3cdb94695fbaee98]::thread::ScopedThreadBuilder>::spawn<<rayon_core[5ca6c2e1d288545f]::ThreadPoolBuilder>::build_scoped<rustc_interface[293475760fb3c74a]::util::run_in_thread_pool_with_globals<rustc_interface[293475760fb3c74a]::interface::run_compiler<core[fe50002e4d8ebebd]::result::Result<(), rustc_span[e47623fb3a0ceb98]::ErrorGuaranteed>, rustc_driver_impl[f8352181a07c1cd]::run_compiler::{closure#0}>::{closure#0}, core[fe50002e4d8ebebd]::result::Result<(), rustc_span[e47623fb3a0ceb98]::ErrorGuaranteed>>::{closure#3}::{closure#0}::{closure#0}, rustc_interface[293475760fb3c74a]::util::run_in_thread_pool_with_globals<rustc_interface[293475760fb3c74a]::interface::run_compiler<core[fe50002e4d8ebebd]::result::Result<(), rustc_span[e47623fb3a0ceb98]::ErrorGuaranteed>, rustc_driver_impl[f8352181a07c1cd]::run_compiler::{closure#0}>::{closure#0}, core[fe50002e4d8ebebd]::result::Result<(), rustc_span[e47623fb3a0ceb98]::ErrorGuaranteed>>::{closure#3}::{closure#0}::{closure#1}, core[fe50002e4d8ebebd]::result::Result<(), rustc_span[e47623fb3a0ceb98]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, ()>::{closure#0} as core[fe50002e4d8ebebd]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7f366e53db8e - std[73a469d20558648b]::sys_common::backtrace::__rust_begin_short_backtrace::<alloc[2e68a68d8689d34a]::boxed::Box<dyn core[fe50002e4d8ebebd]::ops::function::FnOnce<(), Output = ()> + core[fe50002e4d8ebebd]::marker::Send>, ()>
  36:     0x7f366e547c73 - <<std[73a469d20558648b]::thread::Builder>::spawn_unchecked_<alloc[2e68a68d8689d34a]::boxed::Box<dyn core[fe50002e4d8ebebd]::ops::function::FnOnce<(), Output = ()> + core[fe50002e4d8ebebd]::marker::Send>, ()>::{closure#1} as core[fe50002e4d8ebebd]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7f366b798735 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd5f2878fbdddc1bc
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/alloc/src/boxed.rs:2015:9
  38:     0x7f366b798735 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h843757700f5b7304
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/alloc/src/boxed.rs:2015:9
  39:     0x7f366b798735 - std::sys::pal::unix::thread::Thread::new::thread_start::h7e00931ca7a3dfa0
                               at /rustc/870a01a30e45d73b8e922a91850919e03f772636/library/std/src/sys/pal/unix/thread.rs:108:17
  40:     0x7f366b5839eb - <unknown>
  41:     0x7f366b6077cc - <unknown>
  42:                0x0 - <unknown>

error[E0283]: type annotations needed for `&T`
  --> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/inference/icemaker_omni/83A8D26775DFE61B5ACEB8F5BBBCC9118160C06359A9F9CE6876FB0542C02E8B.rs:17:9
   |
17 |     let _ = "x".as_ref(); //~ ERROR type annotations needed
   |         ^       ------ type must be known at this point
   |
   = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
           - impl AsRef<OsStr> for str;
           - impl AsRef<Path> for str;
           - impl AsRef<[u8]> for str;
           - impl AsRef<str> for str;
help: consider giving this pattern a type, where the type for type parameter `T` is specified
   |
17 |     let _: &T = "x".as_ref(); //~ ERROR type annotations needed
   |          ++++

error[E0283]: type annotations needed
  --> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/inference/icemaker_omni/83A8D26775DFE61B5ACEB8F5BBBCC9118160C06359A9F9CE6876FB0542C02E8B.rs:12:26
   |
12 |     |x| String::from("x".as_ref()); //~ ERROR type annotations needed
   |                          ^^^^^^
   |
   = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
           - impl AsRef<OsStr> for str;
           - impl AsRef<Path> for str;
           - impl AsRef<[u8]> for str;
           - impl AsRef<str> for str;
help: try using a fully qualified path to specify the expected types
   |
12 |     |x| String::from(<str as AsRef<T>>::as_ref("x")); //~ ERROR type annotations needed
   |                      ++++++++++++++++++++++++++   ~

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 attach the file at `/tmp/rustc-ice-2024-02-08T12_24_12-2986714.txt` to your bug report

note: compiler flags: -Z threads=50

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

Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.

@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. A-parallel-queries Area: Parallel query execution WG-compiler-parallel Working group: Parallelizing the compiler labels Feb 8, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 8, 2024
@oli-obk oli-obk added requires-nightly This issue requires a nightly compiler in some way. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parallel-queries Area: Parallel query execution C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-compiler-parallel Working group: Parallelizing the compiler
Projects
None yet
Development

No branches or pull requests

3 participants