rust-lang / rust-lang/rust

ICE `explicit deref of non-derefable type`

Open
#149,225 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-pin_ergonomics I-ICE T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Summary
#![feature(pin_ergonomics)]
use std::pin::Pin;
fn patterns <'a>( &pin mut x : Pin< &mut i32 >, &pin const y : Pin < &'a i32>) {} fn main() {}
Version
rustc 1.93.0-nightly (3d461af2a 2025-11-18)
binary: rustc
commit-hash: 3d461af2a23456a2676aadb13b4253c87bdfe28d
commit-date: 2025-11-18
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5
Error output
Backtrace

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

warning: unused variable: `x`
--> code.rs:3:28
|
3 | fn patterns <'a>( &pin mut x : Pin< &mut i32 >, &pin const y : Pin < &'a i32>) {} fn main() {}
|                            ^ help: if this is intentional, prefix it with an underscore: `_x`
|
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

warning: unused variable: `y`
--> code.rs:3:60
|
3 | fn patterns <'a>( &pin mut x : Pin< &mut i32 >, &pin const y : Pin < &'a i32>) {} fn main() {}
|                                                            ^ help: if this is intentional, prefix it with an underscore: `_y`

warning: function `patterns` is never used
--> code.rs:3:4
|
3 | fn patterns <'a>( &pin mut x : Pin< &mut i32 >, &pin const y : Pin < &'a i32>) {} fn main() {}
|    ^^^^^^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: the following explicit lifetimes could be elided: 'a
--> code.rs:3:14
|
3 | fn patterns <'a>( &pin mut x : Pin< &mut i32 >, &pin const y : Pin < &'a i32>) {} fn main() {}
|              ^^                                                       ^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
= note: `#[warn(clippy::needless_lifetimes)]` on by default
help: elide the lifetimes
|
3 - fn patterns <'a>( &pin mut x : Pin< &mut i32 >, &pin const y : Pin < &'a i32>) {} fn main() {}
3 + fn patterns ( &pin mut x : Pin< &mut i32 >, &pin const y : Pin < &i32>) {} fn main() {}
|

error: internal compiler error: /rustc/3d461af2a23456a2676aadb13b4253c87bdfe28d/compiler/rustc_hir_typeck/src/expr_use_visitor.rs:250:9: explicit deref of non-derefable type
--> code.rs:3:19
|
3 | fn patterns <'a>( &pin mut x : Pin< &mut i32 >, &pin const y : Pin < &'a i32>) {} fn main() {}
|                   ^^^^^^^^^^


thread 'rustc' (579425) panicked at /rustc/3d461af2a23456a2676aadb13b4253c87bdfe28d/compiler/rustc_hir_typeck/src/expr_use_visitor.rs:250:9:
Box<dyn Any>
stack backtrace:
 0:     0x7f4551d25123 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hfb8348192fc43ebb
 1:     0x7f4552401a9c - core::fmt::write::h97437f5687cea27d
 2:     0x7f4551cda6b6 - std::io::Write::write_fmt::h3d69a328c4d5e4d7
 3:     0x7f4551cf192c - std::panicking::default_hook::{{closure}}::h6aede591faff46a7
 4:     0x7f4551cf1483 - std::panicking::default_hook::h7b4ecf50b930d151
 5:     0x7f4550d34907 - std[3c083641319d47af]::panicking::update_hook::<alloc[b775178a7c8507ec]::boxed::Box<rustc_driver_impl[e2b35ac28e24aea2]::install_ice_hook::{closure#1}>>::{closure#0}
 6:     0x7f4551cf1ce2 - std::panicking::panic_with_hook::hdbcd646c750dedf5
 7:     0x7f4550d6efb1 - std[3c083641319d47af]::panicking::begin_panic::<rustc_errors[f99eb3eef40c1bf3]::ExplicitBug>::{closure#0}
 8:     0x7f4550d61676 - std[3c083641319d47af]::sys::backtrace::__rust_end_short_backtrace::<std[3c083641319d47af]::panicking::begin_panic<rustc_errors[f99eb3eef40c1bf3]::ExplicitBug>::{closure#0}, !>
 9:     0x7f4550d6147f - std[3c083641319d47af]::panicking::begin_panic::<rustc_errors[f99eb3eef40c1bf3]::ExplicitBug>
10:     0x7f4550d8c671 - <rustc_errors[f99eb3eef40c1bf3]::diagnostic::BugAbort as rustc_errors[f99eb3eef40c1bf3]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11:     0x7f45512e0fec - <rustc_errors[f99eb3eef40c1bf3]::DiagCtxtHandle>::span_bug::<rustc_span[cdbd5621f0a550f6]::span_encoding::Span, alloc[b775178a7c8507ec]::string::String>
12:     0x7f4551303866 - rustc_middle[92ef52462bc1851d]::util::bug::opt_span_bug_fmt::<rustc_span[cdbd5621f0a550f6]::span_encoding::Span>::{closure#0}
13:     0x7f4551303b52 - rustc_middle[92ef52462bc1851d]::ty::context::tls::with_opt::<rustc_middle[92ef52462bc1851d]::util::bug::opt_span_bug_fmt<rustc_span[cdbd5621f0a550f6]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14:     0x7f45512f406b - rustc_middle[92ef52462bc1851d]::ty::context::tls::with_context_opt::<rustc_middle[92ef52462bc1851d]::ty::context::tls::with_opt<rustc_middle[92ef52462bc1851d]::util::bug::opt_span_bug_fmt<rustc_span[cdbd5621f0a550f6]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15:     0x7f454f501718 - rustc_middle[92ef52462bc1851d]::util::bug::span_bug_fmt::<rustc_span[cdbd5621f0a550f6]::span_encoding::Span>
16:     0x55656206ed4c - <(&rustc_lint[acdcb7f2f12aadef]::context::LateContext, rustc_span[cdbd5621f0a550f6]::def_id::LocalDefId) as rustc_hir_typeck[66a832bac098b42e]::expr_use_visitor::TypeInformationCtxt>::report_bug::<&str>
17:     0x556562163a19 - <rustc_hir_typeck[66a832bac098b42e]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[acdcb7f2f12aadef]::context::LateContext, rustc_span[cdbd5621f0a550f6]::def_id::LocalDefId), clippy_lints[3920a25f0125aee3]::replace_box::MovedVariablesCtxt>>::cat_deref
18:     0x556561f5f8cb - <rustc_hir_typeck[66a832bac098b42e]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[acdcb7f2f12aadef]::context::LateContext, rustc_span[cdbd5621f0a550f6]::def_id::LocalDefId), &mut clippy_lints[3920a25f0125aee3]::escape::EscapeDelegate>>::cat_pattern::<<rustc_hir_typeck[66a832bac098b42e]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[acdcb7f2f12aadef]::context::LateContext, rustc_span[cdbd5621f0a550f6]::def_id::LocalDefId), &mut clippy_lints[3920a25f0125aee3]::escape::EscapeDelegate>>::walk_pat::{closure#0}>
19:     0x55656232a7c5 - <clippy_lints[3920a25f0125aee3]::escape::BoxedLocal as rustc_lint[acdcb7f2f12aadef]::passes::LateLintPass>::check_fn
20:     0x7f455127cfd8 - <rustc_lint[acdcb7f2f12aadef]::late::LateContextAndPass<rustc_lint[acdcb7f2f12aadef]::late::RuntimeCombinedLateLintPass> as rustc_hir[b7c24ccb62dd1aaf]::intravisit::Visitor>::visit_fn
21:     0x7f455128d25a - <rustc_lint[acdcb7f2f12aadef]::late::LateContextAndPass<rustc_lint[acdcb7f2f12aadef]::late::RuntimeCombinedLateLintPass> as rustc_hir[b7c24ccb62dd1aaf]::intravisit::Visitor>::visit_nested_item
22:     0x7f4551216549 - <rustc_lint[acdcb7f2f12aadef]::late::LateContextAndPass<rustc_lint[acdcb7f2f12aadef]::late::RuntimeCombinedLateLintPass>>::process_mod
23:     0x7f455317cfad - rustc_lint[acdcb7f2f12aadef]::late::check_crate::{closure#0}
24:     0x7f455317d26d - rustc_lint[acdcb7f2f12aadef]::late::check_crate
25:     0x7f45525ea06a - rustc_interface[f4dc2643b08c82c2]::passes::analysis
26:     0x7f45525e97f5 - rustc_query_impl[189616ec442d20ff]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[189616ec442d20ff]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[92ef52462bc1851d]::query::erase::Erased<[u8; 0usize]>>
27:     0x7f455348979a - rustc_query_system[76ea79e72d8eff41]::query::plumbing::try_execute_query::<rustc_query_impl[189616ec442d20ff]::DynamicConfig<rustc_query_system[76ea79e72d8eff41]::query::caches::SingleCache<rustc_middle[92ef52462bc1851d]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[189616ec442d20ff]::plumbing::QueryCtxt, false>
28:     0x7f45534893d4 - rustc_query_impl[189616ec442d20ff]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
29:     0x7f455372cb90 - <rustc_interface[f4dc2643b08c82c2]::passes::create_and_enter_global_ctxt<core[161168e1bae70b66]::option::Option<rustc_interface[f4dc2643b08c82c2]::queries::Linker>, rustc_driver_impl[e2b35ac28e24aea2]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[161168e1bae70b66]::ops::function::FnOnce<(&rustc_session[90c76d851aa26706]::session::Session, rustc_middle[92ef52462bc1851d]::ty::context::CurrentGcx, alloc[b775178a7c8507ec]::sync::Arc<rustc_data_structures[289d2f4bcfffdd46]::jobserver::Proxy>, &std[3c083641319d47af]::sync::once_lock::OnceLock<rustc_middle[92ef52462bc1851d]::ty::context::GlobalCtxt>, &rustc_data_structures[289d2f4bcfffdd46]::sync::worker_local::WorkerLocal<rustc_middle[92ef52462bc1851d]::arena::Arena>, &rustc_data_structures[289d2f4bcfffdd46]::sync::worker_local::WorkerLocal<rustc_hir[b7c24ccb62dd1aaf]::Arena>, rustc_driver_impl[e2b35ac28e24aea2]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
30:     0x7f4553517005 - rustc_interface[f4dc2643b08c82c2]::interface::run_compiler::<(), rustc_driver_impl[e2b35ac28e24aea2]::run_compiler::{closure#0}>::{closure#1}
31:     0x7f45534f8ffa - std[3c083641319d47af]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f4dc2643b08c82c2]::util::run_in_thread_with_globals<rustc_interface[f4dc2643b08c82c2]::util::run_in_thread_pool_with_globals<rustc_interface[f4dc2643b08c82c2]::interface::run_compiler<(), rustc_driver_impl[e2b35ac28e24aea2]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
32:     0x7f45534f8ce8 - <<std[3c083641319d47af]::thread::Builder>::spawn_unchecked_<rustc_interface[f4dc2643b08c82c2]::util::run_in_thread_with_globals<rustc_interface[f4dc2643b08c82c2]::util::run_in_thread_pool_with_globals<rustc_interface[f4dc2643b08c82c2]::interface::run_compiler<(), rustc_driver_impl[e2b35ac28e24aea2]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[161168e1bae70b66]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
33:     0x7f45534fec2f - std::sys::thread::unix::Thread::new::thread_start::he2d9ab7043ddc2b3
34:     0x7f454ce969cb - <unknown>
35:     0x7f454cf1aa0c - <unknown>
36:                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 `/home/matthias/vcs/github/CRED/rustc-ice-2025-11-19T21_09_53-579408.txt` to your bug report

query stack during panic:
#0 [analysis] running analysis passes on crate `code`
end of query stack
note: Clippy version: clippy 0.1.93 (3d461af2a2 2025-11-18)

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the ICE with the supplied pin_ergonomics example and the reported nightly version, then inspect compiler/rustc_hir_typeck/src/expr_use_visitor.rs around line 250. Trace the cat_deref path shown in the backtrace and verify that this input no longer causes an internal compiler error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.