Closed
Description
Code
#![feature(const_trait_impl)]
#![feature(const_deref)]
use std::ops::{Deref, DerefMut};
use std::pin::Pin;
pub struct Wrap<T>(T);
impl<T> const Deref for Wrap<T> {
type Target = T;
fn deref(&self) -> &T {
&self.0
}
}
impl<T> const DerefMut for Wrap<T> {
fn deref_mut(&mut self) -> &mut T {
&mut self.0
}
}
impl<T> Wrap<T> {
pub const fn get_pinned_mut(this: Pin<&mut Self>) -> Pin<&mut T> {
// SAFETY: this type follows structural pinning
unsafe { Pin::new_unchecked(this.get_unchecked_mut()) }
}
}
Meta
rustc --version --verbose
:
rustc 1.86.0-nightly (ae5de6c75 2025-01-29)
binary: rustc
commit-hash: ae5de6c759cd337ecdb2de4e94f47eaafb5d4606
commit-date: 2025-01-29
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7
Error output
note: no errors encountered even though delayed bugs were created
note: those delayed bugs will now be shown as internal compiler errors
error: internal compiler error[E0277]: the trait bound `T: ~const Deref` is not satisfied
--> src/lib.rs:26:37
|
26 | unsafe { Pin::new_unchecked(this.get_unchecked_mut()) }
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
note: delayed at compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs:771:24 - disabled backtrace
--> src/lib.rs:26:37
|
26 | unsafe { Pin::new_unchecked(this.get_unchecked_mut()) }
| ^^^^^^^^^^^^^^^^^^^^^^^^
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: please attach the file at `rustc-ice-2025-01-30T03_47_52-30101.txt` to your bug report
note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
Backtrace
delayed bug: the trait bound `T: ~const std::ops::Deref` is not satisfied
0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
3: <rustc_trait_selection::error_reporting::TypeErrCtxt>::report_selection_error
4: <rustc_trait_selection::error_reporting::TypeErrCtxt>::report_fulfillment_error
5: <rustc_trait_selection::error_reporting::TypeErrCtxt>::report_fulfillment_errors
6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::confirm_builtin_call
7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
12: rustc_hir_typeck::check::check_fn
13: rustc_hir_typeck::typeck_with_inspect::{closure#0}
14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
16: rustc_query_impl::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
17: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_hir_analysis::check_crate::{closure#4}>::{closure#0}
18: rustc_hir_analysis::check_crate
19: rustc_interface::passes::run_required_analyses
20: rustc_interface::passes::analysis
21: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
22: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
23: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
24: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
25: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
26: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
27: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
28: std::sys::pal::unix::thread::Thread::new::thread_start
29: start_thread
at ./nptl/pthread_create.c:442:8
30: __GI___clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81:0
rustc version: 1.86.0-nightly (ae5de6c75 2025-01-29)
platform: x86_64-unknown-linux-gnu