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: Failed to get parent for DefId #119827

Closed
matthiaskrgr opened this issue Jan 10, 2024 · 0 comments · Fixed by #119868
Closed

ice: Failed to get parent for DefId #119827

matthiaskrgr opened this issue Jan 10, 2024 · 0 comments · Fixed by #119868
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

another #117449 regression cc @oli-obk

auto-reduced (treereduce-rust):

trait Foo {
    type Context<'register_something>
    where
        Self: 'c;
}

impl Foo for Box<Foo> {}

original:

trait Foo {
    type Context<'register_something> where Self: 'c;
    fn foo(self) -> Self::Bar;
}

impl Foo for Box<Foo> {
    type Bar = <Self as Foo>::Bar;
    fn foo(self) -> <Self as Foo>::Bar {
        (!0).foo()
    }
}

Version information

rustc 1.77.0-nightly (94807670a 2024-01-09)
binary: rustc
commit-hash: 94807670a6a3834cc9b71b0b803d49d307c9ba5d
commit-date: 2024-01-09
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

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

Program output

error[E0261]: use of undeclared lifetime name `'c`
 --> /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:4:15
  |
4 |         Self: 'c;
  |               ^^ undeclared lifetime
  |
  = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
help: consider making the bound lifetime-generic with a new `'c` lifetime
  |
4 |         for<'c> Self: 'c;
  |         +++++++
help: consider introducing lifetime `'c` here
  |
2 |     type Context<'c, 'register_something>
  |                  +++
help: consider introducing lifetime `'c` here
  |
1 | trait Foo<'c> {
  |          ++++

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:7:25
  |
7 | impl Foo for Box<Foo> {}
  |                         ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs`

warning: trait objects without an explicit `dyn` are deprecated
 --> /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:7:18
  |
7 | impl Foo for Box<Foo> {}
  |                  ^^^
  |
  = 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: use `dyn`
  |
7 | impl Foo for Box<dyn Foo> {}
  |                  +++

error[E0391]: cycle detected when computing type of `<impl at /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:7:1: 7:22>`
 --> /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:7:1
  |
7 | impl Foo for Box<Foo> {}
  | ^^^^^^^^^^^^^^^^^^^^^
  |
note: ...which requires finding trait impls of `Foo`...
 --> /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:1:1
  |
1 | trait Foo {
  | ^^^^^^^^^
  = note: ...which again requires computing type of `<impl at /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:7:1: 7:22>`, completing the cycle
note: cycle used when collecting item types in top-level module
 --> /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:1:1
  |
1 | / trait Foo {
2 | |     type Context<'register_something>
3 | |     where
4 | |         Self: 'c;
5 | | }
6 | |
7 | | impl Foo for Box<Foo> {}
  | |________________________^
  = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error[E0038]: the trait `Foo` cannot be made into an object
 --> /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:7:18
  |
7 | impl Foo for Box<Foo> {}
  |                  ^^^ `Foo` cannot be made into an object
  |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
 --> /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:2:10
  |
1 | trait Foo {
  |       --- this trait cannot be made into an object...
2 |     type Context<'register_something>
  |          ^^^^^^^ ...because it contains the generic associated type `Context`
  = help: consider moving `Context` to another trait

error[E0277]: the trait bound `Box<(dyn Foo + 'static)>: Foo` is not satisfied
 --> /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:7:14
  |
7 | impl Foo for Box<Foo> {}
  |              ^^^^^^^^ the trait `Foo` is not implemented for `Box<(dyn Foo + 'static)>`
  |
help: this trait has no implementations, consider adding one
 --> /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:1:1
  |
1 | trait Foo {
  | ^^^^^^^^^

error[E0038]: the trait `Foo` cannot be made into an object
 --> /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:7:14
  |
7 | impl Foo for Box<Foo> {}
  |              ^^^^^^^^ `Foo` cannot be made into an object
  |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
 --> /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:2:10
  |
1 | trait Foo {
  |       --- this trait cannot be made into an object...
2 |     type Context<'register_something>
  |          ^^^^^^^ ...because it contains the generic associated type `Context`
  = help: consider moving `Context` to another trait

thread 'rustc' panicked at compiler/rustc_middle/src/traits/specialization_graph.rs:46:52:
Failed to get parent for DefId(0:6 ~ mvce[441b]::{impl#0})
stack backtrace:
   0:     0x7fb7346087e6 - std::backtrace_rs::backtrace::libunwind::trace::h0c9ea26daee6c947
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fb7346087e6 - std::backtrace_rs::backtrace::trace_unsynchronized::hb1bc1aeb5f61b551
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb7346087e6 - std::sys_common::backtrace::_print_fmt::h094aad19be8ebe6d
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fb7346087e6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc6874234e7762746
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fb73465aec0 - core::fmt::rt::Argument::fmt::hdf2968bdc2925a9e
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/core/src/fmt/rt.rs:142:9
   5:     0x7fb73465aec0 - core::fmt::write::h8664bf9edaaf2694
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fb7345fc14f - std::io::Write::write_fmt::h0eaa39fdf46de86b
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/std/src/io/mod.rs:1810:15
   7:     0x7fb7346085c4 - std::sys_common::backtrace::_print::hbef740e19ca9f8df
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fb7346085c4 - std::sys_common::backtrace::print::h632ce963033ff6b9
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fb73460b357 - std::panicking::default_hook::{{closure}}::h60c33aff8a33c9d6
  10:     0x7fb73460b0b9 - std::panicking::default_hook::h5afa325d341c9143
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/std/src/panicking.rs:292:9
  11:     0x7fb731358d7c - std[999b1d78adc0d845]::panicking::update_hook::<alloc[69c273dd4ce48d0d]::boxed::Box<rustc_driver_impl[dbdcdc7d37d3e64f]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fb73460baa6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h16a7189283919a61
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/alloc/src/boxed.rs:2030:9
  13:     0x7fb73460baa6 - std::panicking::rust_panic_with_hook::hca001e421e65617b
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/std/src/panicking.rs:785:13
  14:     0x7fb73460b7f2 - std::panicking::begin_panic_handler::{{closure}}::h6406412da9b6ba9b
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/std/src/panicking.rs:659:13
  15:     0x7fb734608ce6 - std::sys_common::backtrace::__rust_end_short_backtrace::he19e0aee91c65d50
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7fb73460b550 - rust_begin_unwind
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/std/src/panicking.rs:647:5
  17:     0x7fb7346575c5 - core::panicking::panic_fmt::h94e85fe2ee4d3b09
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/core/src/panicking.rs:72:14
  18:     0x7fb732c680d0 - <rustc_middle[c0a27e9ee4b37138]::traits::specialization_graph::Ancestors>::leaf_def
  19:     0x7fb73313e090 - rustc_hir_analysis[f99769aaf9fbe3be]::check::check::check_item_type
  20:     0x7fb732d00119 - rustc_hir_analysis[f99769aaf9fbe3be]::check::wfcheck::check_well_formed
  21:     0x7fb732cfefb3 - rustc_query_impl[57fa99c9f9bc5eb5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[57fa99c9f9bc5eb5]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c0a27e9ee4b37138]::query::erase::Erased<[u8; 1usize]>>
  22:     0x7fb732cfe6b1 - rustc_query_system[a4bae605c4fc5fe8]::query::plumbing::try_execute_query::<rustc_query_impl[57fa99c9f9bc5eb5]::DynamicConfig<rustc_query_system[a4bae605c4fc5fe8]::query::caches::VecCache<rustc_hir[ec81b7385329ac7f]::hir_id::OwnerId, rustc_middle[c0a27e9ee4b37138]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[57fa99c9f9bc5eb5]::plumbing::QueryCtxt, false>
  23:     0x7fb732cfe41b - rustc_query_impl[57fa99c9f9bc5eb5]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7fb732cfbdb7 - rustc_hir_analysis[f99769aaf9fbe3be]::check::wfcheck::check_mod_type_wf
  25:     0x7fb732cfbcfb - rustc_query_impl[57fa99c9f9bc5eb5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[57fa99c9f9bc5eb5]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c0a27e9ee4b37138]::query::erase::Erased<[u8; 1usize]>>
  26:     0x7fb732cfaebb - rustc_query_system[a4bae605c4fc5fe8]::query::plumbing::try_execute_query::<rustc_query_impl[57fa99c9f9bc5eb5]::DynamicConfig<rustc_query_system[a4bae605c4fc5fe8]::query::caches::DefaultCache<rustc_span[1a57749618183ecc]::def_id::LocalModDefId, rustc_middle[c0a27e9ee4b37138]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[57fa99c9f9bc5eb5]::plumbing::QueryCtxt, false>
  27:     0x7fb732cfac53 - rustc_query_impl[57fa99c9f9bc5eb5]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7fb732ae331a - <rustc_middle[c0a27e9ee4b37138]::hir::map::Map>::try_par_for_each_module::<rustc_hir_analysis[f99769aaf9fbe3be]::check_crate::{closure#4}::{closure#0}>::{closure#0}
  29:     0x7fb732ae3b50 - rustc_hir_analysis[f99769aaf9fbe3be]::check_crate
  30:     0x7fb733015619 - rustc_interface[8630123b344ba534]::passes::analysis
  31:     0x7fb73301525f - rustc_query_impl[57fa99c9f9bc5eb5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[57fa99c9f9bc5eb5]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c0a27e9ee4b37138]::query::erase::Erased<[u8; 1usize]>>
  32:     0x7fb7335c9524 - rustc_query_system[a4bae605c4fc5fe8]::query::plumbing::try_execute_query::<rustc_query_impl[57fa99c9f9bc5eb5]::DynamicConfig<rustc_query_system[a4bae605c4fc5fe8]::query::caches::SingleCache<rustc_middle[c0a27e9ee4b37138]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[57fa99c9f9bc5eb5]::plumbing::QueryCtxt, false>
  33:     0x7fb7335c9315 - rustc_query_impl[57fa99c9f9bc5eb5]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7fb733350008 - rustc_interface[8630123b344ba534]::interface::run_compiler::<core[1ecfc9c7dbf148b3]::result::Result<(), rustc_span[1a57749618183ecc]::ErrorGuaranteed>, rustc_driver_impl[dbdcdc7d37d3e64f]::run_compiler::{closure#0}>::{closure#0}
  35:     0x7fb7335ee746 - std[999b1d78adc0d845]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[8630123b344ba534]::util::run_in_thread_with_globals<rustc_interface[8630123b344ba534]::util::run_in_thread_pool_with_globals<rustc_interface[8630123b344ba534]::interface::run_compiler<core[1ecfc9c7dbf148b3]::result::Result<(), rustc_span[1a57749618183ecc]::ErrorGuaranteed>, rustc_driver_impl[dbdcdc7d37d3e64f]::run_compiler::{closure#0}>::{closure#0}, core[1ecfc9c7dbf148b3]::result::Result<(), rustc_span[1a57749618183ecc]::ErrorGuaranteed>>::{closure#0}, core[1ecfc9c7dbf148b3]::result::Result<(), rustc_span[1a57749618183ecc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1ecfc9c7dbf148b3]::result::Result<(), rustc_span[1a57749618183ecc]::ErrorGuaranteed>>
  36:     0x7fb7335ee573 - <<std[999b1d78adc0d845]::thread::Builder>::spawn_unchecked_<rustc_interface[8630123b344ba534]::util::run_in_thread_with_globals<rustc_interface[8630123b344ba534]::util::run_in_thread_pool_with_globals<rustc_interface[8630123b344ba534]::interface::run_compiler<core[1ecfc9c7dbf148b3]::result::Result<(), rustc_span[1a57749618183ecc]::ErrorGuaranteed>, rustc_driver_impl[dbdcdc7d37d3e64f]::run_compiler::{closure#0}>::{closure#0}, core[1ecfc9c7dbf148b3]::result::Result<(), rustc_span[1a57749618183ecc]::ErrorGuaranteed>>::{closure#0}, core[1ecfc9c7dbf148b3]::result::Result<(), rustc_span[1a57749618183ecc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1ecfc9c7dbf148b3]::result::Result<(), rustc_span[1a57749618183ecc]::ErrorGuaranteed>>::{closure#1} as core[1ecfc9c7dbf148b3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7fb7346159d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h75905edabd5878b2
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/alloc/src/boxed.rs:2016:9
  38:     0x7fb7346159d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbed8035343ffa301
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/alloc/src/boxed.rs:2016:9
  39:     0x7fb7346159d5 - std::sys::unix::thread::Thread::new::thread_start::hde523d9576990e45
                               at /rustc/94807670a6a3834cc9b71b0b803d49d307c9ba5d/library/std/src/sys/unix/thread.rs:108:17
  40:     0x7fb72e4aa9eb - <unknown>
  41:     0x7fb72e52e7cc - <unknown>
  42:                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.77.0-nightly (94807670a 2024-01-09) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.nccf5q5EpktV/rustc_testrunner_tmpdir_reporting.J4FFYA0YFLJ5/mvce.rs:7:1: 7:22>` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors; 1 warning emitted

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

@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 Jan 10, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 10, 2024
@oli-obk oli-obk self-assigned this Jan 10, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 10, 2024
@bors bors closed this as completed in d7a720a Jan 12, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 12, 2024
Rollup merge of rust-lang#119868 - oli-obk:unknown_lifetime_ice, r=compiler-errors

Register even erroneous impls

Otherwise the specialization graph fails to pick it up, even though other code assumes that all impl blocks have an entry in the specialization graph.

also includes an unrelated cleanup of the specialization graph query

fixes  rust-lang#119827
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