Skip to content

ICE: self.resolver.get_partial_res(*id) == None #138415

Open
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

extern "C" {
    fn r() {
        impl Terminator {
            #[define_opaque(Successors, Tait)]
            fn successors(&self) -> Successors<'_> {
                f = g;
            }
        }
    }
}

original:

extern {
    fn r() {
        impl Terminator {
    #[define_opaque(Successors, Tait)]
    fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> {
        f = g;
        //~^ ERROR mismatched types
    }
}
    }
}

pub fn main() {}

Version information

rustc 1.87.0-nightly (0998d4095 2025-03-12)
binary: rustc
commit-hash: 0998d4095b0f11061f78a3f9c77a87838a4c1cb7
commit-date: 2025-03-12
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Possibly related line of code:

assert_eq!(self.define_opaque, None);
assert!(hir_id.is_owner());
let Some(define_opaque) = define_opaque.as_ref() else {
return;
};
let define_opaque = define_opaque.iter().filter_map(|(id, path)| {
let res = self.resolver.get_partial_res(*id).unwrap();
let Some(did) = res.expect_full_res().opt_def_id() else {
self.dcx().span_delayed_bug(path.span, "should have errored in resolve");
return None;
};
let Some(did) = did.as_local() else {
self.dcx().span_err(

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

Program output

error[E0658]: use of unstable library feature `type_alias_impl_trait`: `type_alias_impl_trait` has open design concerns
 --> /tmp/icemaker_global_tempdir.UEyFCyjtM1oB/rustc_testrunner_tmpdir_reporting.AGp9gpnRTRbF/mvce.rs:4:15
  |
4 |             #[define_opaque(Successors, Tait)]
  |               ^^^^^^^^^^^^^
  |
  = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
  = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
  = note: this compiler was built on 2025-03-12; consider upgrading it if it is out of date

error: incorrect function inside `extern` block
 --> /tmp/icemaker_global_tempdir.UEyFCyjtM1oB/rustc_testrunner_tmpdir_reporting.AGp9gpnRTRbF/mvce.rs:2:8
  |
1 |   extern "C" {
  |   ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body
2 |       fn r() {
  |  ________^___-
  | |        |
  | |        cannot have a body
3 | |         impl Terminator {
4 | |             #[define_opaque(Successors, Tait)]
5 | |             fn successors(&self) -> Successors<'_> {
... |
9 | |     }
  | |_____- help: remove the invalid body: `;`
  |
  = help: you might have meant to write a function accessible through FFI, which can be done by writing `extern fn` outside of the `extern` block
  = note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html


thread 'rustc' panicked at compiler/rustc_ast_lowering/src/item.rs:1687:58:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x71372c029c43 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h8c0339b76e23c7c6
   1:     0x71372c8059d8 - core::fmt::write::hf17964c7d2e18bd0
   2:     0x71372d8de851 - std::io::Write::write_fmt::h7cfcd5f93f9dc567
   3:     0x71372c029aa2 - std::sys::backtrace::BacktraceLock::print::hd716d5039d269fbe
   4:     0x71372c02c3c8 - std::panicking::default_hook::{{closure}}::h96df64858d5cb010
   5:     0x71372c02bee7 - std::panicking::default_hook::ha39f1f5bbf927117
   6:     0x71372b0941cf - std[6f9921491eb9fe4a]::panicking::update_hook::<alloc[303c6c98e6c278b0]::boxed::Box<rustc_driver_impl[35e6f6d4a4e145a]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x71372c02cc33 - std::panicking::rust_panic_with_hook::hcc277abd3042fb25
   8:     0x71372c02c8f6 - std::panicking::begin_panic_handler::{{closure}}::h1b674a2aca508a35
   9:     0x71372c02a119 - std::sys::backtrace::__rust_end_short_backtrace::hec5520c4d6d8ef49
  10:     0x71372c02c5ed - rust_begin_unwind
  11:     0x713728a73ee0 - core::panicking::panic_fmt::hb6733266874462c8
  12:     0x7137296d1a1c - core::panicking::panic::h1b023ea0b391ac3c
  13:     0x713729ffb959 - core::option::unwrap_failed::h566a1e041658cf50
  14:     0x71372ac62771 - <core[84375964ba27b281]::iter::adapters::filter_map::FilterMap<core[84375964ba27b281]::slice::iter::Iter<(rustc_ast[e9ff90c955529bae]::node_id::NodeId, rustc_ast[e9ff90c955529bae]::ast::Path)>, <rustc_ast_lowering[26433d4c5baf590c]::LoweringContext>::lower_define_opaque::{closure#0}> as core[84375964ba27b281]::iter::traits::iterator::Iterator>::next
  15:     0x71372ac4a745 - rustc_arena[b786825a1a0b9400]::outline::<<rustc_arena[b786825a1a0b9400]::DroplessArena>::alloc_from_iter<(rustc_span[4eecbe2951797329]::span_encoding::Span, rustc_span[4eecbe2951797329]::def_id::LocalDefId), core[84375964ba27b281]::iter::adapters::filter_map::FilterMap<core[84375964ba27b281]::slice::iter::Iter<(rustc_ast[e9ff90c955529bae]::node_id::NodeId, rustc_ast[e9ff90c955529bae]::ast::Path)>, <rustc_ast_lowering[26433d4c5baf590c]::LoweringContext>::lower_define_opaque::{closure#0}>>::{closure#0}, &mut [(rustc_span[4eecbe2951797329]::span_encoding::Span, rustc_span[4eecbe2951797329]::def_id::LocalDefId)]>
  16:     0x71372cfc950e - <rustc_ast_lowering[26433d4c5baf590c]::LoweringContext>::lower_assoc_item
  17:     0x71372cc027d0 - <rustc_ast_lowering[26433d4c5baf590c]::item::ItemLowerer>::lower_node
  18:     0x71372cc00731 - rustc_ast_lowering[26433d4c5baf590c]::lower_to_hir
  19:     0x71372d92cba2 - rustc_query_impl[1036bb4ccce99203]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1036bb4ccce99203]::query_impl::hir_crate::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3cb3dc4375a289d]::query::erase::Erased<[u8; 8usize]>>
  20:     0x71372d92adc7 - rustc_query_system[3e09a18ca21cb4c7]::query::plumbing::try_execute_query::<rustc_query_impl[1036bb4ccce99203]::DynamicConfig<rustc_query_system[3e09a18ca21cb4c7]::query::caches::SingleCache<rustc_middle[3cb3dc4375a289d]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1036bb4ccce99203]::plumbing::QueryCtxt, false>
  21:     0x71372d92aa41 - rustc_query_impl[1036bb4ccce99203]::query_impl::hir_crate::get_query_non_incr::__rust_end_short_backtrace
  22:     0x71372cd3a91e - rustc_query_impl[1036bb4ccce99203]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1036bb4ccce99203]::query_impl::hir_attrs::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3cb3dc4375a289d]::query::erase::Erased<[u8; 8usize]>>
  23:     0x71372cd39f39 - rustc_query_system[3e09a18ca21cb4c7]::query::plumbing::try_execute_query::<rustc_query_impl[1036bb4ccce99203]::DynamicConfig<rustc_data_structures[1c4c6ada1d4735e1]::vec_cache::VecCache<rustc_hir[afe1948da6f5aa8d]::hir_id::OwnerId, rustc_middle[3cb3dc4375a289d]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[3e09a18ca21cb4c7]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[1036bb4ccce99203]::plumbing::QueryCtxt, false>
  24:     0x71372cd39c8d - rustc_query_impl[1036bb4ccce99203]::query_impl::hir_attrs::get_query_non_incr::__rust_end_short_backtrace
  25:     0x71372cd2b2f1 - <rustc_middle[3cb3dc4375a289d]::hir::map::Map>::attrs
  26:     0x71372d8d1180 - rustc_passes[219dc2dc61c8ebab]::entry::entry_fn
  27:     0x71372d8d1118 - rustc_query_impl[1036bb4ccce99203]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1036bb4ccce99203]::query_impl::entry_fn::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3cb3dc4375a289d]::query::erase::Erased<[u8; 12usize]>>
  28:     0x71372d8d10f9 - <rustc_query_impl[1036bb4ccce99203]::query_impl::entry_fn::dynamic_query::{closure#2} as core[84375964ba27b281]::ops::function::FnOnce<(rustc_middle[3cb3dc4375a289d]::ty::context::TyCtxt, ())>>::call_once
  29:     0x71372d8d0a6a - rustc_query_system[3e09a18ca21cb4c7]::query::plumbing::try_execute_query::<rustc_query_impl[1036bb4ccce99203]::DynamicConfig<rustc_query_system[3e09a18ca21cb4c7]::query::caches::SingleCache<rustc_middle[3cb3dc4375a289d]::query::erase::Erased<[u8; 12usize]>>, false, false, false>, rustc_query_impl[1036bb4ccce99203]::plumbing::QueryCtxt, false>
  30:     0x71372d8d0815 - rustc_query_impl[1036bb4ccce99203]::query_impl::entry_fn::get_query_non_incr::__rust_end_short_backtrace
  31:     0x71372cc98f29 - rustc_interface[f27fcde62d61cfcf]::passes::run_required_analyses
  32:     0x71372d8da7f8 - rustc_interface[f27fcde62d61cfcf]::passes::analysis
  33:     0x71372d8da7d7 - rustc_query_impl[1036bb4ccce99203]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1036bb4ccce99203]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3cb3dc4375a289d]::query::erase::Erased<[u8; 0usize]>>
  34:     0x71372d929b81 - rustc_query_system[3e09a18ca21cb4c7]::query::plumbing::try_execute_query::<rustc_query_impl[1036bb4ccce99203]::DynamicConfig<rustc_query_system[3e09a18ca21cb4c7]::query::caches::SingleCache<rustc_middle[3cb3dc4375a289d]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1036bb4ccce99203]::plumbing::QueryCtxt, false>
  35:     0x71372d929874 - rustc_query_impl[1036bb4ccce99203]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  36:     0x71372da5c3fc - rustc_interface[f27fcde62d61cfcf]::passes::create_and_enter_global_ctxt::<core[84375964ba27b281]::option::Option<rustc_interface[f27fcde62d61cfcf]::queries::Linker>, rustc_driver_impl[35e6f6d4a4e145a]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  37:     0x71372d96ff97 - rustc_interface[f27fcde62d61cfcf]::interface::run_compiler::<(), rustc_driver_impl[35e6f6d4a4e145a]::run_compiler::{closure#0}>::{closure#1}
  38:     0x71372d78ec92 - std[6f9921491eb9fe4a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f27fcde62d61cfcf]::util::run_in_thread_with_globals<rustc_interface[f27fcde62d61cfcf]::util::run_in_thread_pool_with_globals<rustc_interface[f27fcde62d61cfcf]::interface::run_compiler<(), rustc_driver_impl[35e6f6d4a4e145a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  39:     0x71372d78f574 - <<std[6f9921491eb9fe4a]::thread::Builder>::spawn_unchecked_<rustc_interface[f27fcde62d61cfcf]::util::run_in_thread_with_globals<rustc_interface[f27fcde62d61cfcf]::util::run_in_thread_pool_with_globals<rustc_interface[f27fcde62d61cfcf]::interface::run_compiler<(), rustc_driver_impl[35e6f6d4a4e145a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[84375964ba27b281]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x71372d79096b - std::sys::pal::unix::thread::Thread::new::thread_start::h3b9892e1ccd38041
  41:     0x7137276a370a - <unknown>
  42:     0x713727727aac - <unknown>
  43:                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 (0998d4095 2025-03-12) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [hir_crate] getting the crate HIR
#1 [hir_attrs] getting HIR owner attributes in ``
#2 [entry_fn] looking up the entry function of a crate
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions