Description
I've encountered a compiler error in the latest rustc nightly (2025-04-23) and made a somewhat small reproduction example. It is, however, far from minimal, unfortunately. If I substitute the code, which contains macros, for the version with the macros expanded, and naively sidestep some issues I don't quite understand, the error seems to stop happening. It is possible this bug is related to something else, but, since it is on the latest nightly, I would assume it hasn't been addressed yet.
Code
I've got a Cargo project at https://github.com/veigaribo/rust-rpitit-error/.
Analyzing src/main.rs
, the definition of MyServerFnError
(up to line 24) is mostly noise so that I can create a server function in line 26/27. That server function expands to a function with the same name, but also to a struct with pascal case naming (MyServerFn
in this case) that implements the ServerFn
trait, defined here: https://github.com/leptos-rs/leptos/blob/2b50ddc0db85e12c7667a938ad5ce8c563da3f1b/server_fn/src/lib.rs#L216.
The error happens when I create a function (problem
in this case) with a parameter bounded on ServerFn
with an specific associated type (Output
in this case) set to some type, and then I invoke that function with a ServerFn
type that does not satisfy that associated type (line 34).
- The error does not occur with any trait:
ServerFn
seems to carry some significance. - I could not reproduce it by implementing
ServerFn
manually, and, as previously stated, I also could not reproduce the problem with the macros expanded. So theserver
macro may carry some significance too. It is defined at https://github.com/leptos-rs/leptos/blob/2b50ddc0db85e12c7667a938ad5ce8c563da3f1b/leptos_macro/src/lib.rs#L925.
Meta
rustc --version --verbose
:
rustc 1.88.0-nightly (df35ff6c3 2025-04-23)
binary: rustc
commit-hash: df35ff6c354f1f1fbf430b84e7dea37dfe997f34
commit-date: 2025-04-23
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2
Error output
Output of cargo run
Compiling rust-rpitit-error v0.1.0 (/media/shared/src/rs/rust-rpitit-error-2)
thread 'rustc' panicked at compiler/rustc_middle/src/ty/assoc.rs:43:25:
name of non-Rpitit assoc item
stack backtrace:
0: 0x7306c2ed3aa3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h69244135d6875fb2
1: 0x7306c3605ac7 - core::fmt::write::h8f228de95b735da4
2: 0x7306c4a38391 - std::io::Write::write_fmt::hb10b33e03dac9dbe
3: 0x7306c2ed3902 - std::sys::backtrace::BacktraceLock::print::hc0088d579301e87b
4: 0x7306c2ed727a - std::panicking::default_hook::{{closure}}::hf9e3ab0f550f7255
5: 0x7306c2ed6dff - std::panicking::default_hook::hde8dcea18bdfa1fc
6: 0x7306c1f56f23 - std[de55bbf40c15c1d9]::panicking::update_hook::<alloc[63d4616c10cc4540]::boxed::Box<rustc_driver_impl[60c1a2efe706eb75]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7306c2ed7af3 - std::panicking::rust_panic_with_hook::hf0478db2c66e7f22
8: 0x7306c2ed77ea - std::panicking::begin_panic_handler::{{closure}}::hf5c9cf9a13568e44
9: 0x7306c2ed3f69 - std::sys::backtrace::__rust_end_short_backtrace::h46e8c51804ed1227
10: 0x7306c2ed74ad - __rustc[fd8351c6b97e8b56]::rust_begin_unwind
11: 0x7306bf885e10 - core::panicking::panic_fmt::h2154da9d6eb82669
12: 0x7306c0a1eddb - core::option::expect_failed::h0f8c24e680e66720
13: 0x7306c4ea35a9 - <rustc_middle[71ebc2cfed4e8fd4]::ty::assoc::AssocItem>::ident.cold
14: 0x7306c2d958af - <rustc_trait_selection[585b92a45c9def05]::error_reporting::TypeErrCtxt>::report_projection_error::{closure#0}::{closure#3}::{closure#0}
15: 0x7306c2d5d181 - <rustc_trait_selection[585b92a45c9def05]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
16: 0x7306c374cab5 - <rustc_hir_typeck[ca61c334d7ba5195]::fn_ctxt::FnCtxt>::confirm_builtin_call
17: 0x7306c438c375 - <rustc_hir_typeck[ca61c334d7ba5195]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
18: 0x7306c43820bc - <rustc_hir_typeck[ca61c334d7ba5195]::fn_ctxt::FnCtxt>::check_expr_block
19: 0x7306c438cebf - <rustc_hir_typeck[ca61c334d7ba5195]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
20: 0x7306c3bdbd84 - rustc_hir_typeck[ca61c334d7ba5195]::check::check_fn
21: 0x7306c3bc929a - rustc_hir_typeck[ca61c334d7ba5195]::typeck_with_inspect::{closure#0}
22: 0x7306c3bc7fb6 - rustc_query_impl[10518d27c996caef]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[10518d27c996caef]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 8usize]>>
23: 0x7306c3848233 - rustc_query_system[5b8097dc30659efa]::query::plumbing::try_execute_query::<rustc_query_impl[10518d27c996caef]::DynamicConfig<rustc_data_structures[796c5d692efe04c0]::vec_cache::VecCache<rustc_span[98bd2c4b67b16de7]::def_id::LocalDefId, rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[5b8097dc30659efa]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[10518d27c996caef]::plumbing::QueryCtxt, true>
24: 0x7306c3844501 - rustc_query_impl[10518d27c996caef]::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
25: 0x7306c3843648 - rustc_hir_analysis[ded1f67b4756a5c]::check_crate
26: 0x7306c3ffed34 - rustc_interface[dc0dcaed68c46eda]::passes::run_required_analyses
27: 0x7306c44e2bde - rustc_interface[dc0dcaed68c46eda]::passes::analysis
28: 0x7306c44e2bad - rustc_query_impl[10518d27c996caef]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[10518d27c996caef]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 0usize]>>
29: 0x7306c48b4efd - rustc_query_system[5b8097dc30659efa]::query::plumbing::try_execute_query::<rustc_query_impl[10518d27c996caef]::DynamicConfig<rustc_query_system[5b8097dc30659efa]::query::caches::SingleCache<rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[10518d27c996caef]::plumbing::QueryCtxt, true>
30: 0x7306c48b4935 - rustc_query_impl[10518d27c996caef]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
31: 0x7306c483bc00 - rustc_interface[dc0dcaed68c46eda]::passes::create_and_enter_global_ctxt::<core[2e306e03d5fcddd8]::option::Option<rustc_interface[dc0dcaed68c46eda]::queries::Linker>, rustc_driver_impl[60c1a2efe706eb75]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
32: 0x7306c46d1a84 - rustc_interface[dc0dcaed68c46eda]::interface::run_compiler::<(), rustc_driver_impl[60c1a2efe706eb75]::run_compiler::{closure#0}>::{closure#1}
33: 0x7306c450f528 - std[de55bbf40c15c1d9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[dc0dcaed68c46eda]::util::run_in_thread_with_globals<rustc_interface[dc0dcaed68c46eda]::util::run_in_thread_pool_with_globals<rustc_interface[dc0dcaed68c46eda]::interface::run_compiler<(), rustc_driver_impl[60c1a2efe706eb75]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
34: 0x7306c450f974 - <<std[de55bbf40c15c1d9]::thread::Builder>::spawn_unchecked_<rustc_interface[dc0dcaed68c46eda]::util::run_in_thread_with_globals<rustc_interface[dc0dcaed68c46eda]::util::run_in_thread_pool_with_globals<rustc_interface[dc0dcaed68c46eda]::interface::run_compiler<(), rustc_driver_impl[60c1a2efe706eb75]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[2e306e03d5fcddd8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
35: 0x7306c4510d77 - std::sys::pal::unix::thread::Thread::new::thread_start::ha9b262a03fd58cd3
36: 0x7306be4a370a - <unknown>
37: 0x7306be527aac - <unknown>
38: 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 make sure that you have updated to the latest nightly
note: please attach the file at `/media/shared/src/rs/rust-rpitit-error-2/rustc-ice-2025-04-24T15_27_28-1827329.txt` to your bug report
note: compiler flags: --crate-type bin -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:
#0 [typeck] type-checking `x`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `rust-rpitit-error` (bin "rust-rpitit-error")
Caused by:
process didn't exit successfully: `/home/veigo/.asdf/installs/rust/1.82.0/toolchains/nightly-2025-04-24-x86_64-unknown-linux-gnu/bin/rustc --crate-name rust_rpitit_error --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=240 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=b5991a3a8d8d75e9 -C extra-filename=-f6a3f054f26c3530 --out-dir /media/shared/src/rs/rust-rpitit-error-2/target/debug/deps -C incremental=/media/shared/src/rs/rust-rpitit-error-2/target/debug/incremental -L dependency=/media/shared/src/rs/rust-rpitit-error-2/target/debug/deps --extern leptos=/media/shared/src/rs/rust-rpitit-error-2/target/debug/deps/libleptos-5bb239e90054f1f0.rlib --extern serde=/media/shared/src/rs/rust-rpitit-error-2/target/debug/deps/libserde-71436781fac4f282.rlib` (exit status: 101)
Backtrace
stack backtrace:
0: 0x7dcec2ed3aa3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h69244135d6875fb2
1: 0x7dcec3605ac7 - core::fmt::write::h8f228de95b735da4
2: 0x7dcec4a38391 - std::io::Write::write_fmt::hb10b33e03dac9dbe
3: 0x7dcec2ed3902 - std::sys::backtrace::BacktraceLock::print::hc0088d579301e87b
4: 0x7dcec2ed727a - std::panicking::default_hook::{{closure}}::hf9e3ab0f550f7255
5: 0x7dcec2ed6dff - std::panicking::default_hook::hde8dcea18bdfa1fc
6: 0x7dcec1f56f23 - std[de55bbf40c15c1d9]::panicking::update_hook::<alloc[63d4616c10cc4540]::boxed::Box<rustc_driver_impl[60c1a2efe706eb75]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7dcec2ed7af3 - std::panicking::rust_panic_with_hook::hf0478db2c66e7f22
8: 0x7dcec2ed77ea - std::panicking::begin_panic_handler::{{closure}}::hf5c9cf9a13568e44
9: 0x7dcec2ed3f69 - std::sys::backtrace::__rust_end_short_backtrace::h46e8c51804ed1227
10: 0x7dcec2ed74ad - __rustc[fd8351c6b97e8b56]::rust_begin_unwind
11: 0x7dcebf885e10 - core::panicking::panic_fmt::h2154da9d6eb82669
12: 0x7dcec0a1eddb - core::option::expect_failed::h0f8c24e680e66720
13: 0x7dcec4ea35a9 - <rustc_middle[71ebc2cfed4e8fd4]::ty::assoc::AssocItem>::ident.cold
14: 0x7dcec2d958af - <rustc_trait_selection[585b92a45c9def05]::error_reporting::TypeErrCtxt>::report_projection_error::{closure#0}::{closure#3}::{closure#0}
15: 0x7dcec2d5d181 - <rustc_trait_selection[585b92a45c9def05]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
16: 0x7dcec374cab5 - <rustc_hir_typeck[ca61c334d7ba5195]::fn_ctxt::FnCtxt>::confirm_builtin_call
17: 0x7dcec438c375 - <rustc_hir_typeck[ca61c334d7ba5195]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
18: 0x7dcec43820bc - <rustc_hir_typeck[ca61c334d7ba5195]::fn_ctxt::FnCtxt>::check_expr_block
19: 0x7dcec438cebf - <rustc_hir_typeck[ca61c334d7ba5195]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
20: 0x7dcec3bdbd84 - rustc_hir_typeck[ca61c334d7ba5195]::check::check_fn
21: 0x7dcec3bc929a - rustc_hir_typeck[ca61c334d7ba5195]::typeck_with_inspect::{closure#0}
22: 0x7dcec3bc7fb6 - rustc_query_impl[10518d27c996caef]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[10518d27c996caef]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 8usize]>>
23: 0x7dcec3848233 - rustc_query_system[5b8097dc30659efa]::query::plumbing::try_execute_query::<rustc_query_impl[10518d27c996caef]::DynamicConfig<rustc_data_structures[796c5d692efe04c0]::vec_cache::VecCache<rustc_span[98bd2c4b67b16de7]::def_id::LocalDefId, rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[5b8097dc30659efa]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[10518d27c996caef]::plumbing::QueryCtxt, true>
24: 0x7dcec3844501 - rustc_query_impl[10518d27c996caef]::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
25: 0x7dcec3843648 - rustc_hir_analysis[ded1f67b4756a5c]::check_crate
26: 0x7dcec3ffed34 - rustc_interface[dc0dcaed68c46eda]::passes::run_required_analyses
27: 0x7dcec44e2bde - rustc_interface[dc0dcaed68c46eda]::passes::analysis
28: 0x7dcec44e2bad - rustc_query_impl[10518d27c996caef]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[10518d27c996caef]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 0usize]>>
29: 0x7dcec48b4efd - rustc_query_system[5b8097dc30659efa]::query::plumbing::try_execute_query::<rustc_query_impl[10518d27c996caef]::DynamicConfig<rustc_query_system[5b8097dc30659efa]::query::caches::SingleCache<rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[10518d27c996caef]::plumbing::QueryCtxt, true>
30: 0x7dcec48b4935 - rustc_query_impl[10518d27c996caef]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
31: 0x7dcec483bc00 - rustc_interface[dc0dcaed68c46eda]::passes::create_and_enter_global_ctxt::<core[2e306e03d5fcddd8]::option::Option<rustc_interface[dc0dcaed68c46eda]::queries::Linker>, rustc_driver_impl[60c1a2efe706eb75]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
32: 0x7dcec46d1a84 - rustc_interface[dc0dcaed68c46eda]::interface::run_compiler::<(), rustc_driver_impl[60c1a2efe706eb75]::run_compiler::{closure#0}>::{closure#1}
33: 0x7dcec450f528 - std[de55bbf40c15c1d9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[dc0dcaed68c46eda]::util::run_in_thread_with_globals<rustc_interface[dc0dcaed68c46eda]::util::run_in_thread_pool_with_globals<rustc_interface[dc0dcaed68c46eda]::interface::run_compiler<(), rustc_driver_impl[60c1a2efe706eb75]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
34: 0x7dcec450f974 - <<std[de55bbf40c15c1d9]::thread::Builder>::spawn_unchecked_<rustc_interface[dc0dcaed68c46eda]::util::run_in_thread_with_globals<rustc_interface[dc0dcaed68c46eda]::util::run_in_thread_pool_with_globals<rustc_interface[dc0dcaed68c46eda]::interface::run_compiler<(), rustc_driver_impl[60c1a2efe706eb75]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[2e306e03d5fcddd8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
35: 0x7dcec4510d77 - std::sys::pal::unix::thread::Thread::new::thread_start::ha9b262a03fd58cd3
36: 0x7dcebe4a370a - <unknown>
37: 0x7dcebe527aac - <unknown>
38: 0x0 - <unknown>