Change:
<ins> error: `derive` attribute cannot be used at crate level --> $DIR/issue-121108.rs:1:1 | LL | #![derive(Clone, Copy)] | ^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | use std::ptr::addr_of; |               ------- the inner attribute doesn't annotate this `use` import | help: perhaps you meant to use an outer attribute | LL - #![derive(Clone, Copy)] LL + #[derive(Clone, Copy)] | error: cannot determine resolution for the macro `addr_of` --> $DIR/issue-121108.rs:6:14 | LL |     let v = *addr_of!(data).cast(); |              ^^^^^^^ | = note: import resolution is stuck, try simplifying macro imports error: aborting due to 2 previous errors </ins>

Discussion:
<!-- [31mICE[0m: Rustc '' 'thread 'rustc' panicked at 'called on a value'', 'thread 'rustc' panicked at 'called on a value'' File: --auto-reduced (treereduce-rust): original: Version information ` Command: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongProgram output</strong</summary<p</p</details<!-- query stack: [hircrate] getting the crate HIR [hirattrs] getting HIR owner attributes in `` [entry_fn] looking up the entry function of a crate [analysis] running analysis passes on this crate --
cc
label +D-diagnostic-infra +S-has-mcve -needs-triage

<!-- [31mICE[0m: Rustc '--crate-type=lib -ooutputfile -Zdump-mir-dir=dir' 'thread 'rustc' panicked at 'mirconstqualif: MIR had errors'', 'thread 'rustc' panicked at 'mirconstqualif: MIR had errors'' File: --auto-reduced (treereduce-rust): use std::mem; macrorules! definereifyfunctions { ($( fn (<param:ident),)? for abi:tt)? fn(arg:ident: retty:ty; )+) ={ name< ($param,))? F: Fn(argty),) -$retty + Copy (f: F) -abi)? fn(argty),) -$retty { assert!(mem::sizeof::<F() == 0, ); abi)? fn wrapper< ($param,))? F: Fn(argty),) -$retty + Copy (arg: retty { let f = unsafe { mem::MaybeUninit::<F::uninit().assumeinit() }; f(arg),) } let fproof = f; wrapper::< ($param,))? F } } definereifyfunctions! { fn reifytoexterncfnunary<A, Rfor extern "C" fn(arg: A) -R; fn reifytoexterncfnhrtbridge<Rfor extern "C" fn(bridge: super::BridgeConfig<') -R; } rust //! Abstraction for creating pointers from any callable that effectively //! has the equivalent of implementing , even if the compiler neither //! provides nor allows reifying closures (i.e. creating pointers) //! other than those with absolutely no captures. //! //! More specifically, for a closure-like type to be "effectively ": //! it must be a ZST (zero-sized type): no information contained within, so //! that 's return value (if it were implemented) is unambiguous //! it must be : no captured "unique ZST tokens" or any other similar //! types that would make duplicating values at will unsound //! combined with the ZST requirement, this confers a kind of "telecopy" //! ability: similar to , but without keeping the value around, and //! instead "reconstructing" it (a noop given it's a ZST) when needed //!

it must be provably inhabited: no captured uninhabited types or any //! other types that cannot be constructed by the user of this abstraction //! the proof is a value of the closure-like type itself, in a sense the //! "seed" for the "telecopy" process made possible by ZST + //! this requirement is the only reason an abstraction limited to a specific //! usecase is required: ZST + can be checked with at worst a panic //! at the "attempted call" time, but that doesn't guarantee //! that the value can be soundly created, and attempting to use the typical //! "proof ZST token" approach leads yet again to having a ZST + type //! that is not proof of anything without a value (i.e. isomorphic to a //! newtype of the type it's trying to prove the inhabitation of) //! //! A more flexible (and safer) solution to the general problem could exist once //! -generic parameters can have type parameters in their types: //! //! use std::mem; // FIXME(eddyb) this could be impls except for the requirement. macrorules! definereifyfunctions { ($( fn (&lt;param:ident),)? for abi:tt)? fn(arg:ident: retty:ty; )+) ={ name&lt; ($param,))? F: Fn(argty),) -$retty + Copy (f: F) -abi)? fn(argty),) -$retty { // FIXME(eddyb) describe the type (e.g. via ) once panic // formatting becomes possible in . assert!(mem::sizeof::&lt;F() == 0, "selflessreify: closure must be zero-sized"); abi)? fn wrapper&lt; ($param,))? F: Fn(argty),) -$retty + Copy (arg: retty { let f = unsafe { // SAFETY: satisfies all criteria for "out of thin air" // reconstructability (see module-level doc comment). mem::MaybeUninit::&lt;F::uninit().assumeinit() }; f(arg),) } let fproof = f; wrapper::&lt; ($param,))? F } } definereifyfunctions!

{ fn reifytoexterncfnunary&lt;A, Rfor extern "C" fn(arg: A) -R; // HACK(eddyb) this abstraction is used withfor<'afn(BridgeConfig<'a) // -Treifytoexterncfnunary// because of the pointer type being "higher-ranked" (i.e. the // binder). // FIXME(eddyb) try to remove the lifetime from , that'd help. fn reifytoexterncfnhrtbridge&lt;Rfor extern "C" fn(bridge: super::BridgeConfig&lt;') -R; } rustc 1.78.0-nightly ( 2024-02-14) binary: rustc commit-hash: commit-date: 2024-02-14 host: x8664-unknown-linux-gnu release: 1.78.0-nightly LLVM version: 18.1.

0 thread 'rustc' panicked at mirconstqualif: MIR had errors stack backtrace: 0: 0x7f406118ce46 - std::backtracers::backtrace::libunwind::trace::h741b35e6ebf0ea82 at 1: 0x7f406118ce46 - std::backtracers::backtrace::traceunsynchronized::hf3b09a36cbdb818e at 2: 0x7f406118ce46 - std::syscommon::backtrace::printfmt::hd9ddcb56e855ae1f at 3: 0x7f406118ce46 - <std::syscommon::backtrace::print::DisplayBacktrace as core::fmt::Display::fmt::h1d659f3f1b376713 at 4: 0x7f40611dd46c - core::fmt::rt::Argument::fmt::h268aa39b6fb00372 at 5: 0x7f40611dd46c - core::fmt::write::h3ca4c8a121ee4a21 at 6: 0x7f406118087f - std::io::Write::writefmt::hbae5643614f30ef5 at 7: 0x7f406118cbf4 - std::syscommon::backtrace::print::h46251963e880a6db at 8: 0x7f406118cbf4 - std::syscommon::backtrace::print::hf7d8eafd5758e700 at 9: 0x7f406118f93b - std::panicking::defaulthook::{{closure}}::h762f7d01310422ff 10: 0x7f406118f689 - std::panicking::defaulthook::h6bf045830ee7f539 at 11: 0x7f4063ff2bac - std[]::panicking::updatehook::<alloc[]::boxed::Box<rustcdriverimpl[]::installicehook::{closure}::{closure} 12: 0x7f40611900a0 - <alloc::boxed::Box<F,

Aas core::ops::function::Fn<Args::call::h183d4d6c4a9f8452 at 13: 0x7f40611900a0 - std::panicking::rustpanicwithhook::hf47919d70d1ff480 at 14: 0x7f406118fda9 - std::panicking::beginpanichandler::{{closure}}::h5fbc7433175e9186 at 15: 0x7f406118d326 - std::syscommon::backtrace::rustendshortbacktrace::h2b0c01029bb6a245 at 16: 0x7f406118fb14 - rustbeginunwind at 17: 0x7f40611d9975 - core::panicking::panicfmt::h213e6f8381440dd9 at 18: 0x7f4065528ff1 - rustcmirtransform[]::mirconstqualif 19: 0x7f4065528d21 - rustcqueryimpl[]::plumbing::rustbeginshortbacktrace::<rustcqueryimpl[]::queryimpl::mirconstqualif::dynamicquery::{closure}::{closure}, rustcmiddle[]::query::erase::Erased<[u8; 4usize]20: 0x7f406552804b - rustcquerysystem[]::query::plumbing::tryexecutequery::<rustcqueryimpl[]::DynamicConfig<rustcquerysystem[]::query::caches::DefIdCache<rustcmiddle[]::query::erase::Erased<[u8; 4usize], false, false, false, rustcqueryimpl[]::plumbing::QueryCtxt, false21: 0x7f4065527dc9 - rustcqueryimpl[]::queryimpl::mirconstqualif::getquerynonincr::rustendshortbacktrace 22: 0x7f4065527bfe - rustcmiddle[]::query::plumbing::querygetat::<rustcquerysystem[]::query::caches::DefIdCache<rustcmiddle[]::query::erase::Erased<[u8;

4usize]23: 0x7f406358f097 - rustcmirtransform[]::mirpromoted 24: 0x7f40657fb812 - rustcqueryimpl[]::plumbing::rustbeginshortbacktrace::<rustcqueryimpl[]::queryimpl::mirpromoted::dynamicquery::{closure}::{closure}, rustcmiddle[]::query::erase::Erased<[u8; 16usize]25: 0x7f40657fbabb - rustcquerysystem[]::query::plumbing::tryexecutequery::<rustcqueryimpl[]::DynamicConfig<rustcquerysystem[]::query::caches::VecCache<rustcspan[]::defid::LocalDefId, rustcmiddle[]::query::erase::Erased<[u8; 16usize], false, false, false, rustcqueryimpl[]::plumbing::QueryCtxt, false26: 0x7f40660a745d - rustcqueryimpl[]::queryimpl::mirpromoted::getquerynonincr::rustendshortbacktrace 27: 0x7f40660a756e - rustcborrowck[]::mirborrowck 28: 0x7f40660a74a1 - rustcqueryimpl[]::plumbing::rustbeginshortbacktrace::<rustcqueryimpl[]::queryimpl::mirborrowck::dynamicquery::{closure}::{closure}, rustcmiddle[]::query::erase::Erased<[u8; 8usize]29: 0x7f40653858f0 - rustcquerysystem[]::query::plumbing::tryexecutequery::<rustcqueryimpl[]::DynamicConfig<rustcquerysystem[]::query::caches::VecCache<rustcspan[]::defid::LocalDefId, rustcmiddle[]::query::erase::Erased<[u8; 8usize], false, false, false, rustcqueryimpl[]::plumbing::QueryCtxt,

false30: 0x7f406538540c - rustcqueryimpl[]::queryimpl::mirborrowck::getquerynonincr::rustendshortbacktrace 31: 0x7f4065c136f0 - rustcinterface[]::passes::analysis 32: 0x7f4065c131e9 - rustcqueryimpl[]::plumbing::rustbeginshortbacktrace::<rustcqueryimpl[]::queryimpl::analysis::dynamicquery::{closure}::{closure}, rustcmiddle[]::query::erase::Erased<[u8; 1usize]33: 0x7f40661b0025 - rustcquerysystem[]::query::plumbing::tryexecutequery::<rustcqueryimpl[]::DynamicConfig<rustcquerysystem[]::query::caches::SingleCache<rustcmiddle[]::query::erase::Erased<[u8; 1usize], false, false, false, rustcqueryimpl[]::plumbing::QueryCtxt, false34: 0x7f40661afd89 - rustcqueryimpl[]::queryimpl::analysis::getquerynonincr::rustendshortbacktrace 35: 0x7f406602e055 - rustcinterface[]::interface::runcompiler::<core[]::result::Result<(), rustcspan[]::ErrorGuaranteed, rustcdriverimpl[]::runcompiler::{closure}::{closure} 36: 0x7f40661c7b58 - std[]::syscommon::backtrace::rustbeginshortbacktrace::<rustcinterface[]::util::runinthreadwithglobals<rustcinterface[]::util::runinthreadpoolwithglobals<rustcinterface[]::interface::runcompiler<core[]::result::Result<(), rustcspan[]::ErrorGuaranteed, rustcdriverimpl[]::runcompiler::{closure}::{closure}, core[]::result::Result<(), rustcspan[]::ErrorGuaranteed::{closure}, core[]::result::Result<(), rustcspan[]::ErrorGuaranteed::{closure}::{closure}, core[]::result::Result<(),

rustcspan[]::ErrorGuaranteed37: 0x7f40661c7984 - <<std[]::thread::Builder::spawnunchecked<rustcinterface[]::util::runinthreadwithglobals<rustcinterface[]::util::runinthreadpoolwithglobals<rustcinterface[]::interface::runcompiler<core[]::result::Result<(), rustcspan[]::ErrorGuaranteed, rustcdriverimpl[]::runcompiler::{closure}::{closure}, core[]::result::Result<(), rustcspan[]::ErrorGuaranteed::{closure}, core[]::result::Result<(), rustcspan[]::ErrorGuaranteed::{closure}::{closure}, core[]::result::Result<(), rustcspan[]::ErrorGuaranteed::{closure} as core[]::ops::function::FnOnce<()::callonce::{shim:vtable} 38: 0x7f40611991e5 - <alloc::boxed::Box<F,Aas core::ops::function::FnOnce<Args::callonce::h1516af221a452bc1 at 39: 0x7f40611991e5 - <alloc::boxed::Box<F,Aas core::ops::function::FnOnce<Args::callonce::hff2a9d52ad89d581 at 40: 0x7f40611991e5 - std::sys::pal::unix::thread::Thread::new::threadstart::hf359248e8c5b2b25 at 41: 0x7f4060f4a9eb - <unknown42: 0x7f4060fce7cc - <unknown43: 0x0 - <unknownerror: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: note: rustc 1.78.0-nightly ( 2024-02-14) running on x8664-unknown-linux-gnu note: compiler flags: --crate-type lib -Z dump-mir-dir=dir query stack during panic: [mirconstqualif] const checking [mirpromoted] promoting constants in MIR for [mirborrowck] borrow-checking [analysis] running analysis passes on this crate end of query stack error[E0433]: failed to resolve: there are too many leading keywords -- | 53 | fn reifytoexterncfnhrtbridge<Rfor extern "C" fn(bridge: super::BridgeConfig<') -R; | ^^^^^ there are too many leading keywords error: aborting due to 1 previous error For more information about this error, try . </p</details<!-- query stack: [mirconstqualif] const checking [mirpromoted] promoting constants in MIR for [mirborrowck] borrow-checking [analysis] running analysis passes on this crate --
Test is from originally cleaned up a bit
Regression in cc
Another smaller example :3
label +A-mir -needs-triage