Skip to content

ICE: explicit deref of non-derefable type #14778

Open
@matthiaskrgr

Description

@matthiaskrgr

Summary

//@ check-pass

#![feature(unsafe_binders)]
//~^ WARN the feature `unsafe_binders` is incomplete

use std::unsafe_binder::{unwrap_binder, wrap_binder};

fn main() {
    unsafe {
    let x = 1;
        let binder: unsafe<'a> &'a i32 = wrap_binder!(&x);
        let rx = *unwrap_binder!(binder);
    }
}

Version

rustc 1.89.0-nightly (dcecb9917 2025-05-09)
binary: rustc
commit-hash: dcecb99176edf2eec51613730937d21cdd5c8f6e
commit-date: 2025-05-09
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.4

Error output

Backtrace

warning: the feature `unsafe_binders` is incomplete and may not be safe to use and/or cause compiler crashes
--> a.rs:3:12
|
3 | #![feature(unsafe_binders)]
|            ^^^^^^^^^^^^^^
|
= note: see issue #130516 <https://github.com/rust-lang/rust/issues/130516> for more information
= note: `#[warn(incomplete_features)]` on by default

warning: unused variable: `rx`
--> a.rs:12:13
 |
12 |         let rx = *unwrap_binder!(binder);
 |             ^^ help: if this is intentional, prefix it with an underscore: `_rx`
 |
 = note: `#[warn(unused_variables)]` on by default

error: internal compiler error: /rustc/dcecb99176edf2eec51613730937d21cdd5c8f6e/compiler/rustc_hir_typeck/src/expr_use_visitor.rs:249:9: explicit deref of non-derefable type
--> a.rs:12:18
 |
12 |         let rx = *unwrap_binder!(binder);
 |                  ^^^^^^^^^^^^^^^^^^^^^^^


thread 'rustc' panicked at /rustc/dcecb99176edf2eec51613730937d21cdd5c8f6e/compiler/rustc_hir_typeck/src/expr_use_visitor.rs:249:9:
Box<dyn Any>
stack backtrace:
 0:     0x7f2c5e15d8b3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hc5cbdf8d27100af3
 1:     0x7f2c5e805c07 - core::fmt::write::h863d3bbf4c00e6b0
 2:     0x7f2c5f900ad1 - std::io::Write::write_fmt::h912feb91ff6a0610
 3:     0x7f2c5e15d712 - std::sys::backtrace::BacktraceLock::print::hd1d99a58bb496c4c
 4:     0x7f2c5e16130a - std::panicking::default_hook::{{closure}}::h0ae138d3e765f04d
 5:     0x7f2c5e160e8f - std::panicking::default_hook::h197fce4b22dcc9b4
 6:     0x7f2c5d190093 - std[7b29bb91ebdb57c9]::panicking::update_hook::<alloc[a0860bb7f030fe8a]::boxed::Box<rustc_driver_impl[b019fded3476e915]::install_ice_hook::{closure#1}>>::{closure#0}
 7:     0x7f2c5e161b83 - std::panicking::rust_panic_with_hook::hc11797ac2ff063c3
 8:     0x7f2c5d1cc441 - std[7b29bb91ebdb57c9]::panicking::begin_panic::<rustc_errors[1cd13ce2e937c1a0]::ExplicitBug>::{closure#0}
 9:     0x7f2c5d1c0476 - std[7b29bb91ebdb57c9]::sys::backtrace::__rust_end_short_backtrace::<std[7b29bb91ebdb57c9]::panicking::begin_panic<rustc_errors[1cd13ce2e937c1a0]::ExplicitBug>::{closure#0}, !>
10:     0x7f2c5d1bcb29 - std[7b29bb91ebdb57c9]::panicking::begin_panic::<rustc_errors[1cd13ce2e937c1a0]::ExplicitBug>
11:     0x7f2c5d1d6be1 - <rustc_errors[1cd13ce2e937c1a0]::diagnostic::BugAbort as rustc_errors[1cd13ce2e937c1a0]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12:     0x7f2c5d7a5aac - <rustc_errors[1cd13ce2e937c1a0]::DiagCtxtHandle>::span_bug::<rustc_span[38259b213a6a0c93]::span_encoding::Span, alloc[a0860bb7f030fe8a]::string::String>
13:     0x7f2c5d843be7 - rustc_middle[9f3ff6a4a17a20f0]::util::bug::opt_span_bug_fmt::<rustc_span[38259b213a6a0c93]::span_encoding::Span>::{closure#0}
14:     0x7f2c5d81c28a - rustc_middle[9f3ff6a4a17a20f0]::ty::context::tls::with_opt::<rustc_middle[9f3ff6a4a17a20f0]::util::bug::opt_span_bug_fmt<rustc_span[38259b213a6a0c93]::span_encoding::Span>::{closure#0}, !>::{closure#0}
15:     0x7f2c5d81c0fb - rustc_middle[9f3ff6a4a17a20f0]::ty::context::tls::with_context_opt::<rustc_middle[9f3ff6a4a17a20f0]::ty::context::tls::with_opt<rustc_middle[9f3ff6a4a17a20f0]::util::bug::opt_span_bug_fmt<rustc_span[38259b213a6a0c93]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
16:     0x7f2c5c155c27 - rustc_middle[9f3ff6a4a17a20f0]::util::bug::span_bug_fmt::<rustc_span[38259b213a6a0c93]::span_encoding::Span>
17:     0x5d133cbf4221 - <(&rustc_lint[42a0c927e47bc188]::context::LateContext, rustc_span[38259b213a6a0c93]::def_id::LocalDefId) as rustc_hir_typeck[1afe847bbefb240d]::expr_use_visitor::TypeInformationCtxt>::report_bug::<&str>
18:     0x5d133ccaa004 - <rustc_hir_typeck[1afe847bbefb240d]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[42a0c927e47bc188]::context::LateContext, rustc_span[38259b213a6a0c93]::def_id::LocalDefId), &mut clippy_lints[34b1a0ad034c89fd]::needless_pass_by_value::MovedVariablesCtxt>>::cat_deref
19:     0x5d133ccaa967 - <rustc_hir_typeck[1afe847bbefb240d]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[42a0c927e47bc188]::context::LateContext, rustc_span[38259b213a6a0c93]::def_id::LocalDefId), &mut clippy_lints[34b1a0ad034c89fd]::escape::EscapeDelegate>>::cat_expr_unadjusted
20:     0x5d133cc952e3 - <rustc_hir_typeck[1afe847bbefb240d]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[42a0c927e47bc188]::context::LateContext, rustc_span[38259b213a6a0c93]::def_id::LocalDefId), &mut clippy_lints[34b1a0ad034c89fd]::escape::EscapeDelegate>>::walk_expr
21:     0x5d133cad60d7 - <rustc_hir_typeck[1afe847bbefb240d]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[42a0c927e47bc188]::context::LateContext, rustc_span[38259b213a6a0c93]::def_id::LocalDefId), &mut clippy_lints[34b1a0ad034c89fd]::escape::EscapeDelegate>>::walk_local::<<rustc_hir_typeck[1afe847bbefb240d]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[42a0c927e47bc188]::context::LateContext, rustc_span[38259b213a6a0c93]::def_id::LocalDefId), &mut clippy_lints[34b1a0ad034c89fd]::escape::EscapeDelegate>>::walk_stmt::{closure#0}>
22:     0x5d133cc95a67 - <rustc_hir_typeck[1afe847bbefb240d]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[42a0c927e47bc188]::context::LateContext, rustc_span[38259b213a6a0c93]::def_id::LocalDefId), &mut clippy_lints[34b1a0ad034c89fd]::escape::EscapeDelegate>>::walk_expr
23:     0x5d133cc9517a - <rustc_hir_typeck[1afe847bbefb240d]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[42a0c927e47bc188]::context::LateContext, rustc_span[38259b213a6a0c93]::def_id::LocalDefId), &mut clippy_lints[34b1a0ad034c89fd]::escape::EscapeDelegate>>::consume_expr
24:     0x5d133cc953cb - <rustc_hir_typeck[1afe847bbefb240d]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[42a0c927e47bc188]::context::LateContext, rustc_span[38259b213a6a0c93]::def_id::LocalDefId), &mut clippy_lints[34b1a0ad034c89fd]::escape::EscapeDelegate>>::walk_expr
25:     0x5d133cc9517a - <rustc_hir_typeck[1afe847bbefb240d]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[42a0c927e47bc188]::context::LateContext, rustc_span[38259b213a6a0c93]::def_id::LocalDefId), &mut clippy_lints[34b1a0ad034c89fd]::escape::EscapeDelegate>>::consume_expr
26:     0x5d133cd8b3b2 - <clippy_lints[34b1a0ad034c89fd]::escape::BoxedLocal as rustc_lint[42a0c927e47bc188]::passes::LateLintPass>::check_fn
27:     0x7f2c5d70e9a8 - <rustc_lint[42a0c927e47bc188]::late::LateContextAndPass<rustc_lint[42a0c927e47bc188]::late::RuntimeCombinedLateLintPass> as rustc_hir[e76b1e7e4bb19825]::intravisit::Visitor>::visit_fn
28:     0x7f2c5d6f5674 - <rustc_lint[42a0c927e47bc188]::late::LateContextAndPass<rustc_lint[42a0c927e47bc188]::late::RuntimeCombinedLateLintPass> as rustc_hir[e76b1e7e4bb19825]::intravisit::Visitor>::visit_nested_item
29:     0x7f2c5f7fa6de - rustc_lint[42a0c927e47bc188]::late::check_crate::{closure#0}
30:     0x7f2c5f7fa989 - rustc_lint[42a0c927e47bc188]::late::check_crate
31:     0x7f2c5f7f8c9f - rustc_interface[e50761f90850a00f]::passes::analysis
32:     0x7f2c5f7f8a75 - rustc_query_impl[e2aea24a209ecfad]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e2aea24a209ecfad]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9f3ff6a4a17a20f0]::query::erase::Erased<[u8; 0usize]>>
33:     0x7f2c5f7888fa - rustc_query_system[bd0c30a71f71891a]::query::plumbing::try_execute_query::<rustc_query_impl[e2aea24a209ecfad]::DynamicConfig<rustc_query_system[bd0c30a71f71891a]::query::caches::SingleCache<rustc_middle[9f3ff6a4a17a20f0]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[e2aea24a209ecfad]::plumbing::QueryCtxt, false>
34:     0x7f2c5f7885cf - rustc_query_impl[e2aea24a209ecfad]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
35:     0x7f2c5fa71f87 - rustc_interface[e50761f90850a00f]::passes::create_and_enter_global_ctxt::<core[d6ce3f6d63d0f33a]::option::Option<rustc_interface[e50761f90850a00f]::queries::Linker>, rustc_driver_impl[b019fded3476e915]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
36:     0x7f2c5f93c5e6 - rustc_interface[e50761f90850a00f]::interface::run_compiler::<(), rustc_driver_impl[b019fded3476e915]::run_compiler::{closure#0}>::{closure#1}
37:     0x7f2c5f8f777e - std[7b29bb91ebdb57c9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e50761f90850a00f]::util::run_in_thread_with_globals<rustc_interface[e50761f90850a00f]::util::run_in_thread_pool_with_globals<rustc_interface[e50761f90850a00f]::interface::run_compiler<(), rustc_driver_impl[b019fded3476e915]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
38:     0x7f2c5f8f7bf4 - <<std[7b29bb91ebdb57c9]::thread::Builder>::spawn_unchecked_<rustc_interface[e50761f90850a00f]::util::run_in_thread_with_globals<rustc_interface[e50761f90850a00f]::util::run_in_thread_pool_with_globals<rustc_interface[e50761f90850a00f]::interface::run_compiler<(), rustc_driver_impl[b019fded3476e915]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[d6ce3f6d63d0f33a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
39:     0x7f2c5f8f8feb - std::sys::pal::unix::thread::Thread::new::thread_start::h0908bf6e72bc0de5
40:     0x7f2c596a370a - <unknown>
41:     0x7f2c59727aac - <unknown>
42:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/tmp/im/rustc-ice-2025-05-10T21_34_00-1225749.txt` to your bug report

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
note: Clippy version: clippy 0.1.88 (dcecb99176 2025-05-09)

error: aborting due to 1 previous error; 2 warnings emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions