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: assertion failed: storage.data.is_empty() #137288

Closed
matthiaskrgr opened this issue Feb 19, 2025 · 1 comment · Fixed by #137302
Closed

ICE: assertion failed: storage.data.is_empty() #137288

matthiaskrgr opened this issue Feb 19, 2025 · 1 comment · Fixed by #137302
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 Feb 19, 2025

trait b {
    type c;
}
impl<d> b for &a {
    type c;
}
struct e<f: b> {
    g: f::c,
}
fn h(i: Box<e<&()>>) {}

Version information

rustc 1.87.0-nightly (ed49386d3 2025-02-19)
binary: rustc
commit-hash: ed49386d3aa3a445a9889707fd405df01723eced
commit-date: 2025-02-19
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Possibly related line of code:

/// Clone the list of variable regions. This is used only during NLL processing
/// to put the set of region variables into the NLL region context.
pub fn get_region_var_infos(&self) -> VarInfos {
let inner = self.inner.borrow();
assert!(!UndoLogs::<UndoLog<'_>>::in_snapshot(&inner.undo_log));
let storage = inner.region_constraint_storage.as_ref().expect("regions already resolved");
assert!(storage.data.is_empty());
// We clone instead of taking because borrowck still wants to use the
// inference context after calling this for diagnostics and the new
// trait solver.
storage.var_infos.clone()
}

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

Program output

error: expected unsuffixed literal, found `,`
 --> /tmp/icemaker_global_tempdir.bnN1TH0mO5US/rustc_testrunner_tmpdir_reporting.eanazHCQiRTn/mvce.rs:2:5
  |
2 |     ,
  |     ^

error[E0261]: use of undeclared lifetime name `'a`
  --> /tmp/icemaker_global_tempdir.bnN1TH0mO5US/rustc_testrunner_tmpdir_reporting.eanazHCQiRTn/mvce.rs:57:25
   |
57 | impl<FN, F, T> Foo for &'a () {
   |      -                  ^^ undeclared lifetime
   |      |
   |      help: consider introducing lifetime `'a` here: `'a,`

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

error[E0599]: no method named `foo` found for struct `Box<A>` in the current scope
  --> /tmp/icemaker_global_tempdir.bnN1TH0mO5US/rustc_testrunner_tmpdir_reporting.eanazHCQiRTn/mvce.rs:98:7
   |
98 |     x.foo();
   |       ^^^ method not found in `Box<A>`


thread 'rustc' panicked at compiler/rustc_infer/src/infer/mod.rs:953:9:
assertion failed: storage.data.is_empty()
stack backtrace:
   0:     0x70fac9b9a8e4 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h8474fc63c522d8ef
   1:     0x70faca41a2ac - core::fmt::write::h807495cdc673c9ad
   2:     0x70facb38d291 - std::io::Write::write_fmt::ha095d9f81ce0ab0f
   3:     0x70fac9b9a742 - std::sys::backtrace::BacktraceLock::print::h6697e7571ddb1a7a
   4:     0x70fac9b9cf4e - std::panicking::default_hook::{{closure}}::h809b6cc791b58376
   5:     0x70fac9b9cb24 - std::panicking::default_hook::h552e31dd2ff71c94
   6:     0x70fac8ce8d17 - std[751aac3a1d4a21ec]::panicking::update_hook::<alloc[e70108a9cb6abf43]::boxed::Box<rustc_driver_impl[2db46e11a3788224]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x70fac9b9d7c3 - std::panicking::rust_panic_with_hook::h31b9a9fc06967d1a
   8:     0x70fac9b9d486 - std::panicking::begin_panic_handler::{{closure}}::he085f2b5958febbd
   9:     0x70fac9b9ada9 - std::sys::backtrace::__rust_end_short_backtrace::h3acec7353f287c7e
  10:     0x70fac9b9d17d - rust_begin_unwind
  11:     0x70fac6847050 - core::panicking::panic_fmt::h088f650de8922fae
  12:     0x70fac73a233c - core::panicking::panic::h0c2dbbe9c00f16f5
  13:     0x70fac6b9f498 - rustc_borrowck[8d8027f8fded1919]::nll::compute_regions
  14:     0x70facb536ffe - rustc_borrowck[8d8027f8fded1919]::do_mir_borrowck
  15:     0x70facb52a4ee - rustc_query_impl[db8619f7f72bce84]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db8619f7f72bce84]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cad254c74eefe1b7]::query::erase::Erased<[u8; 8usize]>>
  16:     0x70faca7c42cc - rustc_query_system[61afea02fdc7dc5c]::query::plumbing::try_execute_query::<rustc_query_impl[db8619f7f72bce84]::DynamicConfig<rustc_data_structures[7f723801f239d808]::vec_cache::VecCache<rustc_span[3242d24a3aa68a91]::def_id::LocalDefId, rustc_middle[cad254c74eefe1b7]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[61afea02fdc7dc5c]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[db8619f7f72bce84]::plumbing::QueryCtxt, false>
  17:     0x70faca7c3dcc - rustc_query_impl[db8619f7f72bce84]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  18:     0x70faca7cc47a - rustc_interface[8d7befe99ce7adde]::passes::run_required_analyses
  19:     0x70facb38923a - rustc_interface[8d7befe99ce7adde]::passes::analysis
  20:     0x70facb389219 - rustc_query_impl[db8619f7f72bce84]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db8619f7f72bce84]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cad254c74eefe1b7]::query::erase::Erased<[u8; 0usize]>>
  21:     0x70facb416883 - rustc_query_system[61afea02fdc7dc5c]::query::plumbing::try_execute_query::<rustc_query_impl[db8619f7f72bce84]::DynamicConfig<rustc_query_system[61afea02fdc7dc5c]::query::caches::SingleCache<rustc_middle[cad254c74eefe1b7]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[db8619f7f72bce84]::plumbing::QueryCtxt, false>
  22:     0x70facb416553 - rustc_query_impl[db8619f7f72bce84]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  23:     0x70facb448f3c - rustc_interface[8d7befe99ce7adde]::passes::create_and_enter_global_ctxt::<core[5038f2ec8886dbab]::option::Option<rustc_interface[8d7befe99ce7adde]::queries::Linker>, rustc_driver_impl[2db46e11a3788224]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  24:     0x70facb43c8ab - rustc_interface[8d7befe99ce7adde]::interface::run_compiler::<(), rustc_driver_impl[2db46e11a3788224]::run_compiler::{closure#0}>::{closure#1}
  25:     0x70facb302dc8 - std[751aac3a1d4a21ec]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[8d7befe99ce7adde]::util::run_in_thread_with_globals<rustc_interface[8d7befe99ce7adde]::util::run_in_thread_pool_with_globals<rustc_interface[8d7befe99ce7adde]::interface::run_compiler<(), rustc_driver_impl[2db46e11a3788224]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  26:     0x70facb3031f4 - <<std[751aac3a1d4a21ec]::thread::Builder>::spawn_unchecked_<rustc_interface[8d7befe99ce7adde]::util::run_in_thread_with_globals<rustc_interface[8d7befe99ce7adde]::util::run_in_thread_pool_with_globals<rustc_interface[8d7befe99ce7adde]::interface::run_compiler<(), rustc_driver_impl[2db46e11a3788224]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[5038f2ec8886dbab]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x70facb303baf - std::sys::pal::unix::thread::Thread::new::thread_start::ha52e702df20ec6b5
  28:     0x70fac54a370a - <unknown>
  29:     0x70fac5527aac - <unknown>
  30:                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.87.0-nightly (ed49386d3 2025-02-19) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_borrowck] borrow-checking `new`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors

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

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

smaller

trait b {
    type c;
}
impl<d> b for &a {
    type c;
}
struct e<f: b> {
    g: f::c,
}
fn h(i: Box<e<&()>>) {}

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 20, 2025
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Feb 20, 2025
…, r=matthewjasper

Use a probe to avoid registering stray region obligations when re-checking drops in MIR typeck

Fixes rust-lang#137288.

See the comment I left on the probe. I'm not totally sure why this depends on *both* an unconstrained type parameter in the impl and a type error for the self type, but I think the fix is at least theoretically well motivated.

r? `@matthewjasper`
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Feb 20, 2025
…, r=matthewjasper

Use a probe to avoid registering stray region obligations when re-checking drops in MIR typeck

Fixes rust-lang#137288.

See the comment I left on the probe. I'm not totally sure why this depends on *both* an unconstrained type parameter in the impl and a type error for the self type, but I think the fix is at least theoretically well motivated.

r? ``@matthewjasper``
@bors bors closed this as completed in 3a04ec8 Feb 21, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 21, 2025
Rollup merge of rust-lang#137302 - compiler-errors:stray-drop-regions, r=matthewjasper

Use a probe to avoid registering stray region obligations when re-checking drops in MIR typeck

Fixes rust-lang#137288.

See the comment I left on the probe. I'm not totally sure why this depends on *both* an unconstrained type parameter in the impl and a type error for the self type, but I think the fix is at least theoretically well motivated.

r? ```@matthewjasper```
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
3 participants