Skip to content

ice: called Result::unwrap() on an Err value: Unknown(<SeStr<S, E> as std::ptr::Pointee>::Metadata) #115628

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

trait Structure<E>: Sized {
    type RefTarget: ?Sized;
}

struct SeStr<S, E>
where
    S: Structure<E>,
{
    _data: S::RefTarget,
}

impl<S, E> SeStr<S, E>
where
    S: Structure<E>,
{
    pub extern "C" fn from_ptr<'a>() -> Option<&'a Self> {
        panic!()
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.74.0-nightly (a991861ec 2023-09-05)
binary: rustc
commit-hash: a991861ec9fd8aedffbe5744a8852c7c64dd40b2
commit-date: 2023-09-05
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0

Error output

warning: struct `SeStr` is never constructed
 --> 81AFF1B75E2344DCA73671B83CCF8326D9F0BD10E402451EC2DCC412A42E097A.rs:5:8
  |
5 | struct SeStr<S, E>
  |        ^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: associated function `from_ptr` is never used
  --> 81AFF1B75E2344DCA73671B83CCF8326D9F0BD10E402451EC2DCC412A42E097A.rs:16:23
   |
12 | impl<S, E> SeStr<S, E>
   | ---------------------- associated function in this implementation
...
16 |     pub extern "C" fn from_ptr<'a>() -> Option<&'a Self> {
   |                       ^^^^^^^^
Backtrace

called `Result::unwrap()` on an `Err` value: Unknown(<SeStr<S, E> as std::ptr::Pointee>::Metadata)
stack backtrace:
   0:     0x7fc73b4dcbec - std::backtrace_rs::backtrace::libunwind::trace::h1298100820b00e42
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fc73b4dcbec - std::backtrace_rs::backtrace::trace_unsynchronized::h25ae9be29b50d68d
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fc73b4dcbec - std::sys_common::backtrace::_print_fmt::hb0a122c02a9e329f
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fc73b4dcbec - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0785508acad78739
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fc73b542dfc - core::fmt::rt::Argument::fmt::h367a8235fd3b8ec9
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/fmt/rt.rs:138:9
   5:     0x7fc73b542dfc - core::fmt::write::haf0f122656cf716d
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/fmt/mod.rs:1094:21
   6:     0x7fc73b4cf71e - std::io::Write::write_fmt::h81969da61711600d
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/io/mod.rs:1714:15
   7:     0x7fc73b4dc9d4 - std::sys_common::backtrace::_print::h00e5c4a2e9966b17
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fc73b4dc9d4 - std::sys_common::backtrace::print::hbf7a0e8e19400072
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fc73b4dfaca - std::panicking::panic_hook_with_disk_dump::{{closure}}::h27904b15b8804b04
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/panicking.rs:280:22
  10:     0x7fc73b4df7c5 - std::panicking::panic_hook_with_disk_dump::h0a17a9fc902df4ec
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/panicking.rs:314:9
  11:     0x7fc73a31c6d9 - rustc_driver_impl[421f961c2abd6a6c]::install_ice_hook::{closure#0}
  12:     0x7fc73b4e0383 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::he211df56096a7722
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/alloc/src/boxed.rs:2021:9
  13:     0x7fc73b4e0383 - std::panicking::rust_panic_with_hook::h2ec7fb05ba41ff26
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/panicking.rs:757:13
  14:     0x7fc73b4e0101 - std::panicking::begin_panic_handler::{{closure}}::h2b92262374748ae8
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/panicking.rs:631:13
  15:     0x7fc73b4dd116 - std::sys_common::backtrace::__rust_end_short_backtrace::h0b659f8569fc6095
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x7fc73b4dfe42 - rust_begin_unwind
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/panicking.rs:619:5
  17:     0x7fc73b53f1a5 - core::panicking::panic_fmt::heae4b517db4316e6
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/panicking.rs:72:14
  18:     0x7fc73b53f833 - core::result::unwrap_failed::h769a8cbef1f880e8
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/result.rs:1652:5
  19:     0x7fc7394c7722 - rustc_lint[1fe2be5320867f18]::types::repr_nullable_ptr
  20:     0x7fc7394c64ac - <rustc_lint[1fe2be5320867f18]::types::ImproperCTypesVisitor>::check_type_for_ffi
  21:     0x7fc73904e7fa - <rustc_lint[1fe2be5320867f18]::types::ImproperCTypesVisitor>::check_type_for_ffi_and_report_errors
  22:     0x7fc73904e652 - <rustc_lint[1fe2be5320867f18]::types::ImproperCTypesVisitor>::check_foreign_fn
  23:     0x7fc73904af84 - rustc_hir[b0c722804e360960]::intravisit::walk_impl_item::<rustc_lint[1fe2be5320867f18]::late::LateContextAndPass<rustc_lint[1fe2be5320867f18]::BuiltinCombinedModuleLateLintPass>>
  24:     0x7fc7390488fc - rustc_hir[b0c722804e360960]::intravisit::walk_item::<rustc_lint[1fe2be5320867f18]::late::LateContextAndPass<rustc_lint[1fe2be5320867f18]::BuiltinCombinedModuleLateLintPass>>
  25:     0x7fc7390484c5 - <rustc_lint[1fe2be5320867f18]::late::LateContextAndPass<rustc_lint[1fe2be5320867f18]::BuiltinCombinedModuleLateLintPass> as rustc_hir[b0c722804e360960]::intravisit::Visitor>::visit_nested_item
  26:     0x7fc739047c9a - rustc_lint[1fe2be5320867f18]::late::late_lint_mod::<rustc_lint[1fe2be5320867f18]::BuiltinCombinedModuleLateLintPass>
  27:     0x7fc739047a4a - rustc_lint[1fe2be5320867f18]::lint_mod
  28:     0x7fc73903b88c - rustc_query_impl[e4e476eeb45651d1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4e476eeb45651d1]::query_impl::lint_mod::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7266ccbfd6f08af0]::query::erase::Erased<[u8; 0usize]>>
  29:     0x7fc73903b86e - <rustc_query_impl[e4e476eeb45651d1]::query_impl::lint_mod::dynamic_query::{closure#2} as core[91a7ba3c96b8fb6a]::ops::function::FnOnce<(rustc_middle[7266ccbfd6f08af0]::ty::context::TyCtxt, rustc_span[e182e80647a6f439]::def_id::LocalModDefId)>>::call_once
  30:     0x7fc7392f22a8 - rustc_query_system[44d60dfb7090b806]::query::plumbing::try_execute_query::<rustc_query_impl[e4e476eeb45651d1]::DynamicConfig<rustc_query_system[44d60dfb7090b806]::query::caches::DefaultCache<rustc_span[e182e80647a6f439]::def_id::LocalModDefId, rustc_middle[7266ccbfd6f08af0]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[e4e476eeb45651d1]::plumbing::QueryCtxt, false>
  31:     0x7fc739cb75e4 - rustc_query_impl[e4e476eeb45651d1]::query_impl::lint_mod::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7fc7399db62e - rustc_data_structures[4483c8f9b2693f2d]::sync::par_for_each_in::<&[rustc_hir[b0c722804e360960]::hir_id::OwnerId], <rustc_middle[7266ccbfd6f08af0]::hir::map::Map>::par_for_each_module<rustc_lint[1fe2be5320867f18]::late::check_crate::{closure#1}::{closure#0}::{closure#0}>::{closure#0}>
  33:     0x7fc7399db3bb - <rustc_session[a813519ed55dc798]::session::Session>::time::<(), rustc_lint[1fe2be5320867f18]::late::check_crate::{closure#1}::{closure#0}>
  34:     0x7fc739782fc1 - rustc_data_structures[4483c8f9b2693f2d]::sync::join::<rustc_lint[1fe2be5320867f18]::late::check_crate::{closure#0}, rustc_lint[1fe2be5320867f18]::late::check_crate::{closure#1}, (), ()>
  35:     0x7fc739782d59 - <core[91a7ba3c96b8fb6a]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[e402a4e95d47e40d]::passes::analysis::{closure#6}::{closure#1}::{closure#0}::{closure#0}::{closure#2}> as core[91a7ba3c96b8fb6a]::ops::function::FnOnce<()>>::call_once
  36:     0x7fc739782c79 - <rustc_data_structures[4483c8f9b2693f2d]::sync::ParallelGuard>::run::<(), rustc_interface[e402a4e95d47e40d]::passes::analysis::{closure#6}::{closure#1}::{closure#0}::{closure#0}::{closure#2}>
  37:     0x7fc739782a40 - <rustc_data_structures[4483c8f9b2693f2d]::sync::ParallelGuard>::run::<(), rustc_interface[e402a4e95d47e40d]::passes::analysis::{closure#6}::{closure#1}::{closure#0}>
  38:     0x7fc739782402 - <rustc_session[a813519ed55dc798]::session::Session>::time::<(), rustc_interface[e402a4e95d47e40d]::passes::analysis::{closure#6}>
  39:     0x7fc7397805bc - rustc_interface[e402a4e95d47e40d]::passes::analysis
  40:     0x7fc7397a45ea - rustc_query_impl[e4e476eeb45651d1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4e476eeb45651d1]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7266ccbfd6f08af0]::query::erase::Erased<[u8; 1usize]>>
  41:     0x7fc7397a45d9 - <rustc_query_impl[e4e476eeb45651d1]::query_impl::analysis::dynamic_query::{closure#2} as core[91a7ba3c96b8fb6a]::ops::function::FnOnce<(rustc_middle[7266ccbfd6f08af0]::ty::context::TyCtxt, ())>>::call_once
  42:     0x7fc739a62c64 - rustc_query_system[44d60dfb7090b806]::query::plumbing::try_execute_query::<rustc_query_impl[e4e476eeb45651d1]::DynamicConfig<rustc_query_system[44d60dfb7090b806]::query::caches::SingleCache<rustc_middle[7266ccbfd6f08af0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e4e476eeb45651d1]::plumbing::QueryCtxt, false>
  43:     0x7fc739a629d9 - rustc_query_impl[e4e476eeb45651d1]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  44:     0x7fc739834f33 - <rustc_middle[7266ccbfd6f08af0]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[421f961c2abd6a6c]::run_compiler::{closure#1}::{closure#2}::{closure#6}, core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>>
  45:     0x7fc73983403c - <rustc_interface[e402a4e95d47e40d]::interface::Compiler>::enter::<rustc_driver_impl[421f961c2abd6a6c]::run_compiler::{closure#1}::{closure#2}, core[91a7ba3c96b8fb6a]::result::Result<core[91a7ba3c96b8fb6a]::option::Option<rustc_interface[e402a4e95d47e40d]::queries::Linker>, rustc_span[e182e80647a6f439]::ErrorGuaranteed>>
  46:     0x7fc73982ba38 - std[2ba0c775535575e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e402a4e95d47e40d]::util::run_in_thread_with_globals<rustc_interface[e402a4e95d47e40d]::interface::run_compiler<core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>, rustc_driver_impl[421f961c2abd6a6c]::run_compiler::{closure#1}>::{closure#0}, core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>>
  47:     0x7fc73982b1ae - <<std[2ba0c775535575e]::thread::Builder>::spawn_unchecked_<rustc_interface[e402a4e95d47e40d]::util::run_in_thread_with_globals<rustc_interface[e402a4e95d47e40d]::interface::run_compiler<core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>, rustc_driver_impl[421f961c2abd6a6c]::run_compiler::{closure#1}>::{closure#0}, core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>>::{closure#1} as core[91a7ba3c96b8fb6a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  48:     0x7fc73b4ead35 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc5c2793cdb16fd0c
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/alloc/src/boxed.rs:2007:9
  49:     0x7fc73b4ead35 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd102196bf71bb167
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/alloc/src/boxed.rs:2007:9
  50:     0x7fc73b4ead35 - std::sys::unix::thread::Thread::new::thread_start::hd2018bce9981ca61
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/sys/unix/thread.rs:108:17
  51:     0x7fc736e8c9eb - <unknown>
  52:     0x7fc736f10dfc - <unknown>
  53:                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 attach the file at `/tmp/im/3/icemaker_reduced/rustc-ice-2023-09-07T04:45:00.434074666Z-1745259.txt` to your bug report

query stack during panic:
#0 [lint_mod] linting top-level module
#1 [analysis] running analysis passes on this crate
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions