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 when specifiyng invalid {} as the associated type for impl Iterator as a return type #99828

Closed
rmurrells opened this issue Jul 27, 2022 · 3 comments · Fixed by #99890
Closed
Assignees
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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

@rmurrells
Copy link

Code

fn get_iter(vec: &[i32]) -> impl Iterator<Item = {}> + '_ {
    vec.iter()
}

fn main() {
    let vec = Vec::new();
    let mut iter = get_iter(&vec);
    iter.next();
}

Meta

rustc --version --verbose:

rustc 1.62.1 (e092d0b6b 2022-07-16)
binary: rustc
commit-hash: e092d0b6b43f2de967af0887873151bb1c0b18d3
commit-date: 2022-07-16
host: x86_64-apple-darwin
release: 1.62.1
LLVM version: 14.0.5

Error output

error[E0658]: associated const equality is incomplete
 --> src/main.rs:1:43
  |
1 | fn get_iter(vec: &[i32]) -> impl Iterator<Item = {}> + '_ {
  |                                           ^^^^^^^^^
  |
  = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information

error: mismatch in bind of associated type, got const
  --> src/main.rs:1:43
   |
1  | fn get_iter(vec: &[i32]) -> impl Iterator<Item = {}> + '_ {
   |                                           ^^^^^^^^^
   |
note: associated type defined here does not match const

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_trait_selection/src/traits/project.rs:565:36
Backtrace

stack backtrace:
   0:        0x1111434e4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h33d4544161da9cd0
   1:        0x11119df5b - core::fmt::write::h22b56d6d417c492d
   2:        0x111135a38 - std::io::Write::write_fmt::h515a8855c6a84843
   3:        0x11114689d - std::panicking::default_hook::{{closure}}::hedda119dcd298b7b
   4:        0x111146581 - std::panicking::default_hook::hc602c1312aa18d98
   5:        0x10870fddd - rustc_driver[7138d63f5c135eca]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:        0x111147006 - std::panicking::rust_panic_with_hook::h3147bfce63989ccb
   7:        0x111146e0a - std::panicking::begin_panic_handler::{{closure}}::h354f8ce5af2f2ce8
   8:        0x111143967 - std::sys_common::backtrace::__rust_end_short_backtrace::h63e1494bcfb6c060
   9:        0x111146b1a - _rust_begin_unwind
  10:        0x1111c7633 - core::panicking::panic_fmt::h6e7523bddca0f9b8
  11:        0x1111c7517 - core::panicking::panic::h9ad5b84e0d6bc108
  12:        0x10c827def - <rustc_trait_selection[a6f455bbcb9cbb54]::traits::project::AssocTypeNormalizer as rustc_middle[82d07da5c7c19032]::ty::fold::TypeFolder>::fold_ty
  13:        0x10c8a4653 - <&rustc_middle[82d07da5c7c19032]::ty::list::List<rustc_middle[82d07da5c7c19032]::ty::subst::GenericArg> as rustc_middle[82d07da5c7c19032]::ty::fold::TypeFoldable>::try_super_fold_with::<rustc_trait_selection[a6f455bbcb9cbb54]::traits::project::AssocTypeNormalizer>
  14:        0x10c8db83a - <rustc_middle[82d07da5c7c19032]::ty::Ty as rustc_middle[82d07da5c7c19032]::ty::fold::TypeFoldable>::super_fold_with::<rustc_trait_selection[a6f455bbcb9cbb54]::traits::project::AssocTypeNormalizer>
  15:        0x10c827752 - <rustc_trait_selection[a6f455bbcb9cbb54]::traits::project::AssocTypeNormalizer as rustc_middle[82d07da5c7c19032]::ty::fold::TypeFolder>::fold_ty
  16:        0x10b1a80ff - <&rustc_middle[82d07da5c7c19032]::ty::list::List<rustc_middle[82d07da5c7c19032]::ty::Ty> as rustc_middle[82d07da5c7c19032]::ty::fold::TypeFoldable>::try_fold_with::<rustc_trait_selection[a6f455bbcb9cbb54]::traits::project::AssocTypeNormalizer>
  17:        0x10b2d9315 - <rustc_trait_selection[a6f455bbcb9cbb54]::traits::project::AssocTypeNormalizer>::fold::<(rustc_middle[82d07da5c7c19032]::ty::sty::FnSig, rustc_middle[82d07da5c7c19032]::ty::InstantiatedPredicates)>
  18:        0x10b2df9fe - rustc_trait_selection[a6f455bbcb9cbb54]::traits::project::normalize::<(rustc_middle[82d07da5c7c19032]::ty::sty::FnSig, rustc_middle[82d07da5c7c19032]::ty::InstantiatedPredicates)>
  19:        0x10b256eb1 - <rustc_infer[dfa359709b99501c]::infer::InferCtxt as rustc_trait_selection[a6f455bbcb9cbb54]::infer::InferCtxtExt>::partially_normalize_associated_types_in::<(rustc_middle[82d07da5c7c19032]::ty::sty::FnSig, rustc_middle[82d07da5c7c19032]::ty::InstantiatedPredicates)>
  20:        0x10b354c66 - <rustc_typeck[aefb7a72b7b1d0e8]::check::inherited::Inherited>::normalize_associated_types_in::<(rustc_middle[82d07da5c7c19032]::ty::sty::FnSig, rustc_middle[82d07da5c7c19032]::ty::InstantiatedPredicates)>
  21:        0x10b282d63 - <rustc_typeck[aefb7a72b7b1d0e8]::check::method::confirm::ConfirmContext>::confirm
  22:        0x10b156577 - <rustc_typeck[aefb7a72b7b1d0e8]::check::fn_ctxt::FnCtxt>::lookup_method
  23:        0x10b14a4f8 - <rustc_typeck[aefb7a72b7b1d0e8]::check::fn_ctxt::FnCtxt>::check_expr_kind
  24:        0x10b101d47 - <rustc_typeck[aefb7a72b7b1d0e8]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25:        0x10b1159bb - <rustc_typeck[aefb7a72b7b1d0e8]::check::fn_ctxt::FnCtxt>::check_stmt
  26:        0x10b1161ef - <rustc_typeck[aefb7a72b7b1d0e8]::check::fn_ctxt::FnCtxt>::check_block_with_expected
  27:        0x10b14af0d - <rustc_typeck[aefb7a72b7b1d0e8]::check::fn_ctxt::FnCtxt>::check_expr_kind
  28:        0x10b101d47 - <rustc_typeck[aefb7a72b7b1d0e8]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  29:        0x10b1028c5 - <rustc_typeck[aefb7a72b7b1d0e8]::check::fn_ctxt::FnCtxt>::check_return_expr
  30:        0x10b366052 - rustc_typeck[aefb7a72b7b1d0e8]::check::check::check_fn
  31:        0x10b23cc27 - <rustc_infer[dfa359709b99501c]::infer::InferCtxtBuilder>::enter::<&rustc_middle[82d07da5c7c19032]::ty::context::TypeckResults, <rustc_typeck[aefb7a72b7b1d0e8]::check::inherited::InheritedBuilder>::enter<rustc_typeck[aefb7a72b7b1d0e8]::check::typeck_with_fallback<rustc_typeck[aefb7a72b7b1d0e8]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[82d07da5c7c19032]::ty::context::TypeckResults>::{closure#0}>
  32:        0x10b1b5a61 - rustc_typeck[aefb7a72b7b1d0e8]::check::typeck
  33:        0x10bf096eb - <rustc_query_system[4126f90d2148db6f]::dep_graph::graph::DepGraph<rustc_middle[82d07da5c7c19032]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[82d07da5c7c19032]::ty::context::TyCtxt, rustc_span[5a76e2efa0e4796c]::def_id::LocalDefId, &rustc_middle[82d07da5c7c19032]::ty::context::TypeckResults>
  34:        0x10bca7c05 - rustc_query_system[4126f90d2148db6f]::query::plumbing::try_execute_query::<rustc_query_impl[16d321854c18bb84]::plumbing::QueryCtxt, rustc_query_system[4126f90d2148db6f]::query::caches::DefaultCache<rustc_span[5a76e2efa0e4796c]::def_id::LocalDefId, &rustc_middle[82d07da5c7c19032]::ty::context::TypeckResults>>
  35:        0x10bda1c0e - rustc_query_system[4126f90d2148db6f]::query::plumbing::get_query::<rustc_query_impl[16d321854c18bb84]::queries::typeck, rustc_query_impl[16d321854c18bb84]::plumbing::QueryCtxt>
  36:        0x10b2d7b23 - <rustc_middle[82d07da5c7c19032]::hir::map::Map>::par_body_owners::<rustc_typeck[aefb7a72b7b1d0e8]::check::typeck_item_bodies::{closure#0}>
  37:        0x10b1bae15 - rustc_typeck[aefb7a72b7b1d0e8]::check::typeck_item_bodies
  38:        0x10bf3e8e4 - <rustc_query_system[4126f90d2148db6f]::dep_graph::graph::DepGraph<rustc_middle[82d07da5c7c19032]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[82d07da5c7c19032]::ty::context::TyCtxt, (), ()>
  39:        0x10bd0f4b7 - rustc_query_system[4126f90d2148db6f]::query::plumbing::try_execute_query::<rustc_query_impl[16d321854c18bb84]::plumbing::QueryCtxt, rustc_query_system[4126f90d2148db6f]::query::caches::DefaultCache<(), ()>>
  40:        0x10bd7bf82 - rustc_query_system[4126f90d2148db6f]::query::plumbing::get_query::<rustc_query_impl[16d321854c18bb84]::queries::typeck_item_bodies, rustc_query_impl[16d321854c18bb84]::plumbing::QueryCtxt>
  41:        0x10b22e8b2 - <rustc_session[a4ff899d744b243a]::session::Session>::time::<(), rustc_typeck[aefb7a72b7b1d0e8]::check_crate::{closure#7}>
  42:        0x10b20bf7d - rustc_typeck[aefb7a72b7b1d0e8]::check_crate
  43:        0x1087f698a - rustc_interface[221574002a4ca70c]::passes::analysis
  44:        0x10bf33ec7 - <rustc_query_system[4126f90d2148db6f]::dep_graph::graph::DepGraph<rustc_middle[82d07da5c7c19032]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[82d07da5c7c19032]::ty::context::TyCtxt, (), core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>>
  45:        0x10bd026a6 - rustc_query_system[4126f90d2148db6f]::query::plumbing::try_execute_query::<rustc_query_impl[16d321854c18bb84]::plumbing::QueryCtxt, rustc_query_system[4126f90d2148db6f]::query::caches::DefaultCache<(), core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>>>
  46:        0x10bda1fef - rustc_query_system[4126f90d2148db6f]::query::plumbing::get_query::<rustc_query_impl[16d321854c18bb84]::queries::analysis, rustc_query_impl[16d321854c18bb84]::plumbing::QueryCtxt>
  47:        0x1086d02c2 - <rustc_interface[221574002a4ca70c]::passes::QueryContext>::enter::<rustc_driver[7138d63f5c135eca]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>>
  48:        0x1086b214a - <rustc_interface[221574002a4ca70c]::interface::Compiler>::enter::<rustc_driver[7138d63f5c135eca]::run_compiler::{closure#1}::{closure#2}, core[8afb26d279e869ce]::result::Result<core[8afb26d279e869ce]::option::Option<rustc_interface[221574002a4ca70c]::queries::Linker>, rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>>
  49:        0x108716018 - rustc_span[5a76e2efa0e4796c]::with_source_map::<core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>, rustc_interface[221574002a4ca70c]::interface::create_compiler_and_run<core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>, rustc_driver[7138d63f5c135eca]::run_compiler::{closure#1}>::{closure#1}>
  50:        0x1086b2d4a - rustc_interface[221574002a4ca70c]::interface::create_compiler_and_run::<core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>, rustc_driver[7138d63f5c135eca]::run_compiler::{closure#1}>
  51:        0x1086acdc5 - <scoped_tls[39d586c33eb6f7eb]::ScopedKey<rustc_span[5a76e2efa0e4796c]::SessionGlobals>>::set::<rustc_interface[221574002a4ca70c]::interface::run_compiler<core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>, rustc_driver[7138d63f5c135eca]::run_compiler::{closure#1}>::{closure#0}, core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>>
  52:        0x1086d3499 - std[8b12c7306df28d12]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[221574002a4ca70c]::util::run_in_thread_pool_with_globals<rustc_interface[221574002a4ca70c]::interface::run_compiler<core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>, rustc_driver[7138d63f5c135eca]::run_compiler::{closure#1}>::{closure#0}, core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>>::{closure#0}, core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>>
  53:        0x1086d42f1 - <<std[8b12c7306df28d12]::thread::Builder>::spawn_unchecked_<rustc_interface[221574002a4ca70c]::util::run_in_thread_pool_with_globals<rustc_interface[221574002a4ca70c]::interface::run_compiler<core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>, rustc_driver[7138d63f5c135eca]::run_compiler::{closure#1}>::{closure#0}, core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>>::{closure#0}, core[8afb26d279e869ce]::result::Result<(), rustc_errors[9b765dd3664f2226]::ErrorGuaranteed>>::{closure#1} as core[8afb26d279e869ce]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  54:        0x1111502b7 - std::sys::unix::thread::Thread::new::thread_start::h5be690079b7ad7fa
  55:     0x7fff204558fc - __pthread_start

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.1 (e092d0b6b 2022-07-16) running on x86_64-apple-darwin

note: compiler flags: --crate-type bin -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental

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

@rmurrells rmurrells 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 Jul 27, 2022
@TaKO8Ki TaKO8Ki self-assigned this Jul 28, 2022
@compiler-errors
Copy link
Member

compiler-errors commented Jul 28, 2022

@TaKO8Ki are you working on this? I started working on a solution but didn't claim it, and I saw you claimed a few other issues recently too so I didn't know if it was planned or started yet 😆

If you've already gotten started on it, then that's ok, but if you just claimed so that you can work on it later, I'd like to finish up my solution.

@TaKO8Ki
Copy link
Member

TaKO8Ki commented Jul 29, 2022

@compiler-errors I've already started working on this, but I spent only a little time on it, so I have no problem with you taking it over!

@compiler-errors
Copy link
Member

Thanks. I will try my best to claim issues I am working on earlier in the process so I don't have to bother you like this.

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. glacier ICE tracked in rust-lang/glacier. 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