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: still mutable #122518

Closed
matthiaskrgr opened this issue Mar 14, 2024 · 4 comments · Fixed by #122523
Closed

ICE: still mutable #122518

matthiaskrgr opened this issue Mar 14, 2024 · 4 comments · Fixed by #122523
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

auto-reduced (treereduce-rust):

trait Iterable {
    type Item<'a>: 'a;
    fn iter(&self) -> impl '_;
}
impl<'a> Iterable for &'a I {
    fn iter(&self) -> '_ + Iterator<Item = Self::Item<'_>> {}
}

original:

trait Iterable {
    type Item<'a>: 'a;
    fn iter(&self) -> impl '_;
}
impl<'a> Iterable for &'a I {
    type Item<'b> = I::Item<'a>
    where
        a: 'b;
    fn iter(&self) -> '_ + Iterator<Item = Self::Item<'_>> {
        (*self).iter()
    }
}

Version information

rustc 1.78.0-nightly (fe6157522 2024-03-14)
binary: rustc
commit-hash: fe6157522848604562f83084154274c545fe3a27
commit-date: 2024-03-14
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: at least one trait must be specified
 --> /tmp/icemaker_global_tempdir.cleJ7oDYlVeq/rustc_testrunner_tmpdir_reporting.k1qdlKURuLE2/mvce.rs:3:23
  |
3 |     fn iter(&self) -> impl '_;
  |                       ^^^^^^^

error[E0412]: cannot find type `I` in this scope
 --> /tmp/icemaker_global_tempdir.cleJ7oDYlVeq/rustc_testrunner_tmpdir_reporting.k1qdlKURuLE2/mvce.rs:5:27
  |
5 | impl<'a> Iterable for &'a I {
  |                           ^ not found in this scope

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.cleJ7oDYlVeq/rustc_testrunner_tmpdir_reporting.k1qdlKURuLE2/mvce.rs:7:2
  |
7 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.cleJ7oDYlVeq/rustc_testrunner_tmpdir_reporting.k1qdlKURuLE2/mvce.rs`

warning: trait objects without an explicit `dyn` are deprecated
 --> /tmp/icemaker_global_tempdir.cleJ7oDYlVeq/rustc_testrunner_tmpdir_reporting.k1qdlKURuLE2/mvce.rs:6:23
  |
6 |     fn iter(&self) -> '_ + Iterator<Item = Self::Item<'_>> {}
  |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` on by default
help: if this is an object-safe trait, use `dyn`
  |
6 |     fn iter(&self) -> dyn '_ + Iterator<Item = Self::Item<'_>> {}
  |                       +++

thread 'rustc' panicked at compiler/rustc_middle/src/ty/context.rs:1126:49:
still mutable
stack backtrace:
   0:     0x7f7be16bb902 - std::backtrace_rs::backtrace::libunwind::trace::h04d3f68962db70a2
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7f7be16bb902 - std::backtrace_rs::backtrace::trace_unsynchronized::h8622c2bf3f1d5ffd
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7be16bb902 - std::sys_common::backtrace::_print_fmt::h8d75f4d5405ad14b
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f7be16bb902 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2c6bd99000dd0bf9
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7be170cc5c - core::fmt::rt::Argument::fmt::h517cf1f14c25baae
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/core/src/fmt/rt.rs:142:9
   5:     0x7f7be170cc5c - core::fmt::write::h99fe5948aa1aba14
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/core/src/fmt/mod.rs:1153:17
   6:     0x7f7be16b07ff - std::io::Write::write_fmt::h01412846dad28bf6
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/std/src/io/mod.rs:1843:15
   7:     0x7f7be16bb6d4 - std::sys_common::backtrace::_print::h3470b0baf687e467
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f7be16bb6d4 - std::sys_common::backtrace::print::h05286ca51f8e1745
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f7be16be3db - std::panicking::default_hook::{{closure}}::hd6705566bb345b29
  10:     0x7f7be16be133 - std::panicking::default_hook::hd1de05b1a0fb6145
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/std/src/panicking.rs:292:9
  11:     0x7f7bde308b4f - std[da7e6d9d2d140271]::panicking::update_hook::<alloc[8351d74e211dacf4]::boxed::Box<rustc_driver_impl[17e7e644b21a572c]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f7be16beb40 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::he02eef82f40e4d18
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/alloc/src/boxed.rs:2034:9
  13:     0x7f7be16beb40 - std::panicking::rust_panic_with_hook::h294f7b939906ee86
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/std/src/panicking.rs:783:13
  14:     0x7f7be16be882 - std::panicking::begin_panic_handler::{{closure}}::hc6bf729e15cf864d
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/std/src/panicking.rs:657:13
  15:     0x7f7be16bbdd6 - std::sys_common::backtrace::__rust_end_short_backtrace::h003548bc9ef0065f
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f7be16be5b4 - rust_begin_unwind
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/std/src/panicking.rs:645:5
  17:     0x7f7be1709175 - core::panicking::panic_fmt::hdbbe1ed9f6bec1af
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/core/src/panicking.rs:72:14
  18:     0x7f7be1709341 - core::panicking::panic_display::h6f4cef99f92f9f7e
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/core/src/panicking.rs:197:5
  19:     0x7f7be1708f2b - core::panicking::panic_str::hdd89a9bfdc4e9312
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/core/src/panicking.rs:172:5
  20:     0x7f7be1708f2b - core::option::expect_failed::hba89e5bd0ed2e87d
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/core/src/option.rs:1995:5
  21:     0x7f7bdd12b5dc - <rustc_middle[adb49fe0971a482e]::ty::context::TyCtxt>::create_def
  22:     0x7f7bdffd64dd - <rustc_middle[adb49fe0971a482e]::query::plumbing::TyCtxtAt>::create_def
  23:     0x7f7bdee9cde1 - rustc_ty_utils[c6744ff33f9121ef]::assoc::associated_type_for_impl_trait_in_impl
  24:     0x7f7bdfe7bafa - rustc_ty_utils[c6744ff33f9121ef]::assoc::associated_types_for_impl_traits_in_associated_fn
  25:     0x7f7bdfe7b7b4 - rustc_query_impl[20a0b58a2f23eb28]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[20a0b58a2f23eb28]::query_impl::associated_types_for_impl_traits_in_associated_fn::dynamic_query::{closure#2}::{closure#0}, rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 16usize]>>
  26:     0x7f7bdfe7b789 - <rustc_query_impl[20a0b58a2f23eb28]::query_impl::associated_types_for_impl_traits_in_associated_fn::dynamic_query::{closure#2} as core[7bc0e81c83c7b2c5]::ops::function::FnOnce<(rustc_middle[adb49fe0971a482e]::ty::context::TyCtxt, rustc_span[64111255fd428194]::def_id::DefId)>>::call_once
  27:     0x7f7bdf9059c1 - rustc_query_system[25477918277334a0]::query::plumbing::try_execute_query::<rustc_query_impl[20a0b58a2f23eb28]::DynamicConfig<rustc_query_system[25477918277334a0]::query::caches::DefIdCache<rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[20a0b58a2f23eb28]::plumbing::QueryCtxt, false>
  28:     0x7f7bdfe7bfa1 - rustc_query_impl[20a0b58a2f23eb28]::query_impl::associated_types_for_impl_traits_in_associated_fn::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7f7bdfe7bd90 - rustc_middle[adb49fe0971a482e]::query::plumbing::query_get_at::<rustc_query_system[25477918277334a0]::query::caches::DefIdCache<rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 16usize]>>>
  30:     0x7f7bdfe7b1e0 - rustc_arena[a1eb1bb71a24e11a]::outline::<<rustc_arena[a1eb1bb71a24e11a]::DroplessArena>::alloc_from_iter<rustc_span[64111255fd428194]::def_id::DefId, core[7bc0e81c83c7b2c5]::iter::adapters::chain::Chain<core[7bc0e81c83c7b2c5]::iter::adapters::map::Map<core[7bc0e81c83c7b2c5]::slice::iter::Iter<rustc_hir[c53db5b3a21d46be]::hir::ImplItemRef>, rustc_ty_utils[c6744ff33f9121ef]::assoc::associated_item_def_ids::{closure#3}>, core[7bc0e81c83c7b2c5]::iter::adapters::flatten::FlatMap<core[7bc0e81c83c7b2c5]::option::Iter<rustc_hir[c53db5b3a21d46be]::hir::TraitRef>, core[7bc0e81c83c7b2c5]::iter::adapters::copied::Copied<core[7bc0e81c83c7b2c5]::iter::adapters::flatten::FlatMap<core[7bc0e81c83c7b2c5]::iter::adapters::filter::Filter<core[7bc0e81c83c7b2c5]::slice::iter::Iter<rustc_hir[c53db5b3a21d46be]::hir::ImplItemRef>, rustc_ty_utils[c6744ff33f9121ef]::assoc::associated_item_def_ids::{closure#4}::{closure#0}>, &[rustc_span[64111255fd428194]::def_id::DefId], rustc_ty_utils[c6744ff33f9121ef]::assoc::associated_item_def_ids::{closure#4}::{closure#1}>>, rustc_ty_utils[c6744ff33f9121ef]::assoc::associated_item_def_ids::{closure#4}>>>::{closure#0}, &mut [rustc_span[64111255fd428194]::def_id::DefId]>
  31:     0x7f7bdf9f4487 - rustc_ty_utils[c6744ff33f9121ef]::assoc::associated_item_def_ids
  32:     0x7f7bdf905541 - rustc_query_impl[20a0b58a2f23eb28]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[20a0b58a2f23eb28]::query_impl::associated_item_def_ids::dynamic_query::{closure#2}::{closure#0}, rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 16usize]>>
  33:     0x7f7bdf905515 - <rustc_query_impl[20a0b58a2f23eb28]::query_impl::associated_item_def_ids::dynamic_query::{closure#2} as core[7bc0e81c83c7b2c5]::ops::function::FnOnce<(rustc_middle[adb49fe0971a482e]::ty::context::TyCtxt, rustc_span[64111255fd428194]::def_id::DefId)>>::call_once
  34:     0x7f7bdf9059c1 - rustc_query_system[25477918277334a0]::query::plumbing::try_execute_query::<rustc_query_impl[20a0b58a2f23eb28]::DynamicConfig<rustc_query_system[25477918277334a0]::query::caches::DefIdCache<rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[20a0b58a2f23eb28]::plumbing::QueryCtxt, false>
  35:     0x7f7bdf90532d - rustc_query_impl[20a0b58a2f23eb28]::query_impl::associated_item_def_ids::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f7bdfe6b8dd - rustc_ty_utils[c6744ff33f9121ef]::assoc::associated_items
  37:     0x7f7bdfe6b636 - rustc_query_impl[20a0b58a2f23eb28]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[20a0b58a2f23eb28]::query_impl::associated_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 8usize]>>
  38:     0x7f7bdf6b989c - rustc_query_system[25477918277334a0]::query::plumbing::try_execute_query::<rustc_query_impl[20a0b58a2f23eb28]::DynamicConfig<rustc_query_system[25477918277334a0]::query::caches::DefIdCache<rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[20a0b58a2f23eb28]::plumbing::QueryCtxt, false>
  39:     0x7f7bdfb262de - rustc_query_impl[20a0b58a2f23eb28]::query_impl::associated_items::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7f7bdfb263b8 - rustc_middle[adb49fe0971a482e]::query::plumbing::query_get_at::<rustc_query_system[25477918277334a0]::query::caches::DefIdCache<rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 8usize]>>>
  41:     0x7f7bdcc8f2ec - <rustc_ty_utils[c6744ff33f9121ef]::opaque_types::OpaqueTypeCollector as rustc_type_ir[41b2f37588789981]::visit::TypeVisitor<rustc_middle[adb49fe0971a482e]::ty::context::TyCtxt>>::visit_ty
  42:     0x7f7bdcc90693 - <rustc_ty_utils[c6744ff33f9121ef]::opaque_types::OpaqueTypeCollector as rustc_type_ir[41b2f37588789981]::visit::TypeVisitor<rustc_middle[adb49fe0971a482e]::ty::context::TyCtxt>>::visit_ty
  43:     0x7f7bdf8fca84 - rustc_ty_utils[c6744ff33f9121ef]::opaque_types::opaque_types_defined_by
  44:     0x7f7bdf8fc60b - rustc_query_impl[20a0b58a2f23eb28]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[20a0b58a2f23eb28]::query_impl::opaque_types_defined_by::dynamic_query::{closure#2}::{closure#0}, rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 8usize]>>
  45:     0x7f7bdf8b99ee - rustc_query_system[25477918277334a0]::query::plumbing::try_execute_query::<rustc_query_impl[20a0b58a2f23eb28]::DynamicConfig<rustc_query_system[25477918277334a0]::query::caches::VecCache<rustc_span[64111255fd428194]::def_id::LocalDefId, rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[20a0b58a2f23eb28]::plumbing::QueryCtxt, false>
  46:     0x7f7be03d7b8c - rustc_query_impl[20a0b58a2f23eb28]::query_impl::opaque_types_defined_by::get_query_non_incr::__rust_end_short_backtrace
  47:     0x7f7be03d7c61 - <rustc_middle[adb49fe0971a482e]::traits::DefiningAnchor>::bind
  48:     0x7f7bdf8bb807 - rustc_hir_typeck[4ea0691e477c40c1]::typeck
  49:     0x7f7bdf8bb525 - rustc_query_impl[20a0b58a2f23eb28]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[20a0b58a2f23eb28]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 8usize]>>
  50:     0x7f7bdf8b99ee - rustc_query_system[25477918277334a0]::query::plumbing::try_execute_query::<rustc_query_impl[20a0b58a2f23eb28]::DynamicConfig<rustc_query_system[25477918277334a0]::query::caches::VecCache<rustc_span[64111255fd428194]::def_id::LocalDefId, rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[20a0b58a2f23eb28]::plumbing::QueryCtxt, false>
  51:     0x7f7bdf8b944c - rustc_query_impl[20a0b58a2f23eb28]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  52:     0x7f7bdfb69cd3 - <rustc_middle[adb49fe0971a482e]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[f25c3b69d0967229]::check_crate::{closure#4}>::{closure#0}
  53:     0x7f7bdfb6895f - rustc_hir_analysis[f25c3b69d0967229]::check_crate
  54:     0x7f7bdfd8742a - rustc_interface[2a44aa61faca3666]::passes::analysis
  55:     0x7f7bdfd87065 - rustc_query_impl[20a0b58a2f23eb28]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[20a0b58a2f23eb28]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 1usize]>>
  56:     0x7f7be0437be5 - rustc_query_system[25477918277334a0]::query::plumbing::try_execute_query::<rustc_query_impl[20a0b58a2f23eb28]::DynamicConfig<rustc_query_system[25477918277334a0]::query::caches::SingleCache<rustc_middle[adb49fe0971a482e]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[20a0b58a2f23eb28]::plumbing::QueryCtxt, false>
  57:     0x7f7be0437949 - rustc_query_impl[20a0b58a2f23eb28]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  58:     0x7f7be00c40c4 - rustc_interface[2a44aa61faca3666]::interface::run_compiler::<core[7bc0e81c83c7b2c5]::result::Result<(), rustc_span[64111255fd428194]::ErrorGuaranteed>, rustc_driver_impl[17e7e644b21a572c]::run_compiler::{closure#0}>::{closure#0}
  59:     0x7f7be0672545 - std[da7e6d9d2d140271]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[2a44aa61faca3666]::util::run_in_thread_with_globals<rustc_interface[2a44aa61faca3666]::util::run_in_thread_pool_with_globals<rustc_interface[2a44aa61faca3666]::interface::run_compiler<core[7bc0e81c83c7b2c5]::result::Result<(), rustc_span[64111255fd428194]::ErrorGuaranteed>, rustc_driver_impl[17e7e644b21a572c]::run_compiler::{closure#0}>::{closure#0}, core[7bc0e81c83c7b2c5]::result::Result<(), rustc_span[64111255fd428194]::ErrorGuaranteed>>::{closure#0}, core[7bc0e81c83c7b2c5]::result::Result<(), rustc_span[64111255fd428194]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7bc0e81c83c7b2c5]::result::Result<(), rustc_span[64111255fd428194]::ErrorGuaranteed>>
  60:     0x7f7be0672372 - <<std[da7e6d9d2d140271]::thread::Builder>::spawn_unchecked_<rustc_interface[2a44aa61faca3666]::util::run_in_thread_with_globals<rustc_interface[2a44aa61faca3666]::util::run_in_thread_pool_with_globals<rustc_interface[2a44aa61faca3666]::interface::run_compiler<core[7bc0e81c83c7b2c5]::result::Result<(), rustc_span[64111255fd428194]::ErrorGuaranteed>, rustc_driver_impl[17e7e644b21a572c]::run_compiler::{closure#0}>::{closure#0}, core[7bc0e81c83c7b2c5]::result::Result<(), rustc_span[64111255fd428194]::ErrorGuaranteed>>::{closure#0}, core[7bc0e81c83c7b2c5]::result::Result<(), rustc_span[64111255fd428194]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7bc0e81c83c7b2c5]::result::Result<(), rustc_span[64111255fd428194]::ErrorGuaranteed>>::{closure#1} as core[7bc0e81c83c7b2c5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  61:     0x7f7be16c81d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb91162b0b688133b
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/alloc/src/boxed.rs:2020:9
  62:     0x7f7be16c81d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfe6e861eab2d00fa
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/alloc/src/boxed.rs:2020:9
  63:     0x7f7be16c81d5 - std::sys::pal::unix::thread::Thread::new::thread_start::heab36b33e6209afa
                               at /rustc/fe6157522848604562f83084154274c545fe3a27/library/std/src/sys/pal/unix/thread.rs:108:17
  64:     0x7f7bdb2a955a - <unknown>
  65:     0x7f7bdb326a3c - <unknown>
  66:                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 (fe6157522 2024-03-14) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [associated_types_for_impl_traits_in_associated_fn] creating associated items for opaque types returned by `<impl at /tmp/icemaker_global_tempdir.cleJ7oDYlVeq/rustc_testrunner_tmpdir_reporting.k1qdlKURuLE2/mvce.rs:5:1: 5:28>::iter`
#1 [associated_item_def_ids] collecting associated items or fields of `<impl at /tmp/icemaker_global_tempdir.cleJ7oDYlVeq/rustc_testrunner_tmpdir_reporting.k1qdlKURuLE2/mvce.rs:5:1: 5:28>`
#2 [associated_items] collecting associated items of `<impl at /tmp/icemaker_global_tempdir.cleJ7oDYlVeq/rustc_testrunner_tmpdir_reporting.k1qdlKURuLE2/mvce.rs:5:1: 5:28>`
#3 [opaque_types_defined_by] computing the opaque types defined by `<impl at /tmp/icemaker_global_tempdir.cleJ7oDYlVeq/rustc_testrunner_tmpdir_reporting.k1qdlKURuLE2/mvce.rs:5:1: 5:28>::iter`
#4 [typeck] type-checking `<impl at /tmp/icemaker_global_tempdir.cleJ7oDYlVeq/rustc_testrunner_tmpdir_reporting.k1qdlKURuLE2/mvce.rs:5:1: 5:28>::iter`
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

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

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

#121796 cc @oli-obk , also see #121504 for a similar regression fixed by nn

@oli-obk
Copy link
Contributor

oli-obk commented Mar 14, 2024

Not sure that was actually fixed. The PR seems entirely unrelated

@matthiaskrgr
Copy link
Member Author

on a nighty before 121796, this errored with

error: at least one trait must be specified
 --> crash.rs:3:23
  |
3 |     fn iter(&self) -> impl '_;
  |                       ^^^^^^^

error[E0412]: cannot find type `I` in this scope
 --> crash.rs:5:27
  |
5 | impl<'a> Iterable for &'a I {
  |                           ^ not found in this scope

error[E0601]: `main` function not found in crate `crash`
 --> crash.rs:7:2
  |
7 | }
  |  ^ consider adding a `main` function to `crash.rs`

warning: trait objects without an explicit `dyn` are deprecated
 --> crash.rs:6:23
  |
6 |     fn iter(&self) -> '_ + Iterator<Item = Self::Item<'_>> {}
  |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` on by default
help: if this is an object-safe trait, use `dyn`
  |
6 |     fn iter(&self) -> dyn '_ + Iterator<Item = Self::Item<'_>> {}
  |                       +++

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

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

@oli-obk
Copy link
Contributor

oli-obk commented Mar 14, 2024

Oh I think I see how that got "fixed". It bailed out of compilation early enough not to hit the ICE anymore by emitting stashed errors earlier.

So it got hidden again, and now it's back againbecause of some subtle change in query ordering. We probably need to run this query explicitly for all traits and impls before the big def id freeze.

@compiler-errors compiler-errors self-assigned this Mar 15, 2024
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 15, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 15, 2024
…types, r=oli-obk

Ensure RPITITs are created before def-id freezing

From the test:

```rust
// `ty::Error` in a trait ref will silence any missing item errors, but will also
// prevent the `associated_items` query from being called before def ids are frozen.
```

Essentially, the code that checks that `impl`s have all their items (`check_impl_items_against_trait`) is also (implicitly) responsible for fetching the `associated_items` query before, but since we early return here:
https://github.com/rust-lang/rust/blob/c2901f543577af99b9cb708f5c0d28525eb7f08f/compiler/rustc_hir_analysis/src/check/check.rs#L732-L737
...that means that this never happens for trait refs that reference errors.

Fixes rust-lang#122518
r? oli-obk
@bors bors closed this as completed in ee940f8 Mar 15, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 15, 2024
Rollup merge of rust-lang#122523 - compiler-errors:ensure-associated-types, r=oli-obk

Ensure RPITITs are created before def-id freezing

From the test:

```rust
// `ty::Error` in a trait ref will silence any missing item errors, but will also
// prevent the `associated_items` query from being called before def ids are frozen.
```

Essentially, the code that checks that `impl`s have all their items (`check_impl_items_against_trait`) is also (implicitly) responsible for fetching the `associated_items` query before, but since we early return here:
https://github.com/rust-lang/rust/blob/c2901f543577af99b9cb708f5c0d28525eb7f08f/compiler/rustc_hir_analysis/src/check/check.rs#L732-L737
...that means that this never happens for trait refs that reference errors.

Fixes rust-lang#122518
r? oli-obk
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.

5 participants