Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lifetimes aren't fully supported #10

Open
1xX69 opened this issue Feb 26, 2025 · 3 comments
Open

lifetimes aren't fully supported #10

1xX69 opened this issue Feb 26, 2025 · 3 comments

Comments

@1xX69
Copy link

1xX69 commented Feb 26, 2025

#[axum_codec::apply(encode, decode)]
pub struct HelpLink<'a> {
    pub description: &'a str,
}

#[axum_codec::apply(encode, decode)]
pub enum ErrorDetail<'a> {
    Help { links: Vec<HelpLink<'a>> },
}

fn main() {}
➜  monorepo git:(master) ✗ cargo build -p sample
   Compiling serde v1.0.217
   Compiling axum-core v0.5.0
   Compiling thiserror v1.0.69
   Compiling serde_json v1.0.138
   Compiling axum v0.8.1
   Compiling axum-codec v0.0.19
   Compiling sample v0.1.0 (/home/user/workspace/monorepo/sample)
error: lifetime may not live long enough
 --> sample/src/main.rs:8:12
  |
6 | #[axum_codec::apply(encode, decode)]
  | ------------------------------------ lifetime `'de` defined here
7 | pub enum ErrorDetail<'a> {
  |                      -- lifetime `'a` defined here
8 |     Help { links: Vec<HelpLink<'a>> },
  |            ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'de` must outlive `'a`
  |
  = help: consider adding the following bound: `'de: 'a`

error: could not compile `sample` (bin "sample") due to 2 previous errors
@1xX69
Copy link
Author

1xX69 commented Feb 28, 2025

Whoops, my bad! It actually works, you just need to add #[serde(borrow)]

like this:

#[axum_codec::apply(encode, decode)]
pub struct HelpLink<'a> {
    pub description: &'a str,
}

#[axum_codec::apply(encode, decode)]
pub enum ErrorDetail<'a> {
    Help {
        #[serde(borrow)]
        links: Vec<HelpLink<'a>>,
    },
}

@1xX69
Copy link
Author

1xX69 commented Feb 28, 2025

But if I try to add more variants:

#[axum_codec::apply(encode, decode)]
pub struct HelpLink<'a> {
    pub description: &'a str,
}

/// Enum representing different types of error details.
#[axum_codec::apply(encode, decode)]
pub enum ErrorDetail<'a> {
    Help {
        #[serde(borrow)]
        links: Vec<HelpLink<'a>>,
    },

    LocalizedMessage {
        message: &'a str,
    },
}

I get an internal compiler error:

$ cargo build -p sample
   Compiling sample v0.1.0 (/home/user/workspace/monorepo/sample)
error: internal compiler error: encountered incremental compilation error with evaluate_obligation(f504fce775bc4b43-bf7636c59bb396fa)
  |
  = help: This is a known issue with the compiler. Run `cargo clean -p sample` or `cargo clean` to allow your project to compile
  = note: Please follow the instructions below to create a bug report with the provided information
  = note: See <https://github.com/rust-lang/rust/issues/84970> for more information


thread 'rustc' panicked at /rustc/f280acf4c743806abbbbcfe65050ac52ec4bdec0/compiler/rustc_query_system/src/query/plumbing.rs:731:9:
Found unstable fingerprints for evaluate_obligation(f504fce775bc4b43-bf7636c59bb396fa): Ok(EvaluatedToOk)
stack backtrace:
   0:     0x7ef031998c64 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h8d9b2abef2510cd1
   1:     0x7ef03221a2ac - core::fmt::write::heb9cf6889f45a11e
   2:     0x7ef033184ed1 - std::io::Write::write_fmt::h6360a21e44de67e4
   3:     0x7ef031998ac2 - std::sys::backtrace::BacktraceLock::print::h9319588d0d6e4878
   4:     0x7ef03199b2ce - std::panicking::default_hook::{{closure}}::h4c968bafc99c0b41
   5:     0x7ef03199aea4 - std::panicking::default_hook::hafb4ab1b4e12432b
   6:     0x7ef030ae86e7 - std[54256809445ede48]::panicking::update_hook::<alloc[4946864fce885641]::boxed::Box<rustc_driver_impl[f8acc18714ba66d9]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7ef03199bb43 - std::panicking::rust_panic_with_hook::h5b5ba4a5cbdd9043
   8:     0x7ef03199b83a - std::panicking::begin_panic_handler::{{closure}}::h761c7933b6bd63bc
   9:     0x7ef031999139 - std::sys::backtrace::__rust_end_short_backtrace::hf28ea39c64a8ec49
  10:     0x7ef03199b4fd - rust_begin_unwind
  11:     0x7ef02e646e60 - core::panicking::panic_fmt::hbb352f67f9fc2f03
  12:     0x7ef0310832d3 - rustc_query_system[63b8370bb4899dc2]::query::plumbing::incremental_verify_ich_failed::<rustc_middle[fa8070f18412b0da]::ty::context::TyCtxt>
  13:     0x7ef0326ffc58 - rustc_query_system[63b8370bb4899dc2]::query::plumbing::try_execute_query::<rustc_query_impl[1e0edd06af9652a1]::DynamicConfig<rustc_query_system[63b8370bb4899dc2]::query::caches::DefaultCache<rustc_type_ir[f32108c434f59f4e]::canonical::CanonicalQueryInput<rustc_middle[fa8070f18412b0da]::ty::context::TyCtxt, rustc_middle[fa8070f18412b0da]::ty::ParamEnvAnd<rustc_middle[fa8070f18412b0da]::ty::predicate::Predicate>>, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt, true>
  14:     0x7ef03270fd85 - rustc_query_impl[1e0edd06af9652a1]::query_impl::evaluate_obligation::get_query_incr::__rust_end_short_backtrace
  15:     0x7ef032baaeae - <rustc_trait_selection[d035bd7351711dff]::traits::fulfill::FulfillProcessor as rustc_data_structures[30a19619986f318]::obligation_forest::ObligationProcessor>::process_obligation
  16:     0x7ef03220f17f - <rustc_data_structures[30a19619986f318]::obligation_forest::ObligationForest<rustc_trait_selection[d035bd7351711dff]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[d035bd7351711dff]::traits::fulfill::FulfillProcessor>
  17:     0x7ef032650347 - <rustc_trait_selection[d035bd7351711dff]::traits::fulfill::FulfillmentContext<rustc_trait_selection[d035bd7351711dff]::traits::FulfillmentError> as rustc_infer[1161895a0fa9626d]::traits::engine::TraitEngine<rustc_trait_selection[d035bd7351711dff]::traits::FulfillmentError>>::select_all_or_error
  18:     0x7ef032ad2bce - rustc_hir_analysis[200ebf77cfece739]::check::compare_impl_item::check_type_bounds
  19:     0x7ef032ac82bc - rustc_hir_analysis[200ebf77cfece739]::check::compare_impl_item::compare_impl_item
  20:     0x7ef032ac64b7 - rustc_query_impl[1e0edd06af9652a1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1e0edd06af9652a1]::query_impl::compare_impl_item::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 1usize]>>
  21:     0x7ef03270d2aa - rustc_query_system[63b8370bb4899dc2]::query::plumbing::try_execute_query::<rustc_query_impl[1e0edd06af9652a1]::DynamicConfig<rustc_data_structures[30a19619986f318]::vec_cache::VecCache<rustc_span[a6bcc981ad5e83db]::def_id::LocalDefId, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[63b8370bb4899dc2]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt, true>
  22:     0x7ef03270f4f6 - rustc_query_impl[1e0edd06af9652a1]::query_impl::compare_impl_item::get_query_incr::__rust_end_short_backtrace
  23:     0x7ef02f991f83 - rustc_hir_analysis[200ebf77cfece739]::check::check::check_item_type
  24:     0x7ef02f9684fb - rustc_hir_analysis[200ebf77cfece739]::check::wfcheck::check_well_formed
  25:     0x7ef032c762b7 - rustc_query_impl[1e0edd06af9652a1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1e0edd06af9652a1]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 1usize]>>
  26:     0x7ef03270d661 - rustc_query_system[63b8370bb4899dc2]::query::plumbing::try_execute_query::<rustc_query_impl[1e0edd06af9652a1]::DynamicConfig<rustc_data_structures[30a19619986f318]::vec_cache::VecCache<rustc_span[a6bcc981ad5e83db]::def_id::LocalDefId, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[63b8370bb4899dc2]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt, true>
  27:     0x7ef0331f1954 - rustc_query_impl[1e0edd06af9652a1]::plumbing::force_from_dep_node::<rustc_query_impl[1e0edd06af9652a1]::DynamicConfig<rustc_data_structures[30a19619986f318]::vec_cache::VecCache<rustc_span[a6bcc981ad5e83db]::def_id::LocalDefId, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[63b8370bb4899dc2]::dep_graph::graph::DepNodeIndex>, false, false, false>>
  28:     0x7ef0331f17ad - <rustc_query_impl[1e0edd06af9652a1]::plumbing::query_callback<rustc_query_impl[1e0edd06af9652a1]::query_impl::check_well_formed::QueryType>::{closure#0} as core[c7a133740aa39aee]::ops::function::FnOnce<(rustc_middle[fa8070f18412b0da]::ty::context::TyCtxt, rustc_query_system[63b8370bb4899dc2]::dep_graph::dep_node::DepNode)>>::call_once
  29:     0x7ef03221fa7f - <rustc_query_system[63b8370bb4899dc2]::dep_graph::graph::DepGraphData<rustc_middle[fa8070f18412b0da]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt>
  30:     0x7ef03221f1ae - <rustc_query_system[63b8370bb4899dc2]::dep_graph::graph::DepGraphData<rustc_middle[fa8070f18412b0da]::dep_graph::DepsType>>::try_mark_green::<rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt>
  31:     0x7ef032cf317d - rustc_query_system[63b8370bb4899dc2]::query::plumbing::ensure_must_run::<rustc_query_impl[1e0edd06af9652a1]::DynamicConfig<rustc_query_system[63b8370bb4899dc2]::query::caches::DefaultCache<rustc_span[a6bcc981ad5e83db]::def_id::LocalModDefId, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt>
  32:     0x7ef03312c993 - rustc_query_impl[1e0edd06af9652a1]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
  33:     0x7ef0325c5b4d - rustc_hir_analysis[200ebf77cfece739]::check_crate
  34:     0x7ef0325cfc5c - rustc_interface[3b74b9441e612cca]::passes::run_required_analyses
  35:     0x7ef033180e7a - rustc_interface[3b74b9441e612cca]::passes::analysis
  36:     0x7ef033180e59 - rustc_query_impl[1e0edd06af9652a1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1e0edd06af9652a1]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 0usize]>>
  37:     0x7ef03317c759 - rustc_query_system[63b8370bb4899dc2]::query::plumbing::try_execute_query::<rustc_query_impl[1e0edd06af9652a1]::DynamicConfig<rustc_query_system[63b8370bb4899dc2]::query::caches::SingleCache<rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt, true>
  38:     0x7ef03317c162 - rustc_query_impl[1e0edd06af9652a1]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  39:     0x7ef03328923c - rustc_interface[3b74b9441e612cca]::passes::create_and_enter_global_ctxt::<core[c7a133740aa39aee]::option::Option<rustc_interface[3b74b9441e612cca]::queries::Linker>, rustc_driver_impl[f8acc18714ba66d9]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  40:     0x7ef03327caeb - rustc_interface[3b74b9441e612cca]::interface::run_compiler::<(), rustc_driver_impl[f8acc18714ba66d9]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7ef033107550 - std[54256809445ede48]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[3b74b9441e612cca]::util::run_in_thread_with_globals<rustc_interface[3b74b9441e612cca]::util::run_in_thread_pool_with_globals<rustc_interface[3b74b9441e612cca]::interface::run_compiler<(), rustc_driver_impl[f8acc18714ba66d9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  42:     0x7ef033107974 - <<std[54256809445ede48]::thread::Builder>::spawn_unchecked_<rustc_interface[3b74b9441e612cca]::util::run_in_thread_with_globals<rustc_interface[3b74b9441e612cca]::util::run_in_thread_pool_with_globals<rustc_interface[3b74b9441e612cca]::interface::run_compiler<(), rustc_driver_impl[f8acc18714ba66d9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c7a133740aa39aee]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7ef03310832f - std::sys::pal::unix::thread::Thread::new::thread_start::h208202f9d25af663
  44:     0x7ef02d297d02 - start_thread
  45:     0x7ef02d3173ac - __GI___clone3
  46:                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 `/home/user/workspace/monorepo/rustc-ice-2025-02-28T08_39_15-206461.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:
#0 [evaluate_obligation] evaluating trait selection obligation `_::HelpLinkEncoder: core::marker::Sync`  |  = note: this failure-note originates in the derive macro `axum_codec::__private::bitcode::Encode` (in Nightly builds, run with -Z macro-backtrace for more info)

#1 [compare_impl_item] checking assoc item `_::<impl at sample/src/lib.rs:7:1: 7:37>::Encoder` is compatible with trait definition
... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
there was a panic while trying to force a dep node
try_mark_green dep node stack:
#0 check_mod_type_wf(sample[d599])
end of try_mark_green dep node stack
error: could not compile `sample` (lib) due to 1 previous error
$ cat /home/user/workspace/monorepo/rustc-ice-2025-02-28T08_39_15-206461.txt
thread 'rustc' panicked at /rustc/f280acf4c743806abbbbcfe65050ac52ec4bdec0/compiler/rustc_query_system/src/query/plumbing.rs:731:9:
Found unstable fingerprints for evaluate_obligation(f504fce775bc4b43-bf7636c59bb396fa): Ok(EvaluatedToOk)
stack backtrace:
   0:     0x7ef0335b0771 - std::backtrace::Backtrace::create::h0975e4261c850498
   1:     0x7ef0319834d5 - std::backtrace::Backtrace::force_capture::hdd554246d802e7f4
   2:     0x7ef030ae8e31 - std[54256809445ede48]::panicking::update_hook::<alloc[4946864fce885641]::boxed::Box<rustc_driver_impl[f8acc18714ba66d9]::install_ice_hook::{closure#1}>>::{closure#0}
   3:     0x7ef03199bb43 - std::panicking::rust_panic_with_hook::h5b5ba4a5cbdd9043
   4:     0x7ef03199b83a - std::panicking::begin_panic_handler::{{closure}}::h761c7933b6bd63bc
   5:     0x7ef031999139 - std::sys::backtrace::__rust_end_short_backtrace::hf28ea39c64a8ec49
   6:     0x7ef03199b4fd - rust_begin_unwind
   7:     0x7ef02e646e60 - core::panicking::panic_fmt::hbb352f67f9fc2f03
   8:     0x7ef0310832d3 - rustc_query_system[63b8370bb4899dc2]::query::plumbing::incremental_verify_ich_failed::<rustc_middle[fa8070f18412b0da]::ty::context::TyCtxt>
   9:     0x7ef0326ffc58 - rustc_query_system[63b8370bb4899dc2]::query::plumbing::try_execute_query::<rustc_query_impl[1e0edd06af9652a1]::DynamicConfig<rustc_query_system[63b8370bb4899dc2]::query::caches::DefaultCache<rustc_type_ir[f32108c434f59f4e]::canonical::CanonicalQueryInput<rustc_middle[fa8070f18412b0da]::ty::context::TyCtxt, rustc_middle[fa8070f18412b0da]::ty::ParamEnvAnd<rustc_middle[fa8070f18412b0da]::ty::predicate::Predicate>>, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt, true>
  10:     0x7ef03270fd85 - rustc_query_impl[1e0edd06af9652a1]::query_impl::evaluate_obligation::get_query_incr::__rust_end_short_backtrace
  11:     0x7ef032baaeae - <rustc_trait_selection[d035bd7351711dff]::traits::fulfill::FulfillProcessor as rustc_data_structures[30a19619986f318]::obligation_forest::ObligationProcessor>::process_obligation
  12:     0x7ef03220f17f - <rustc_data_structures[30a19619986f318]::obligation_forest::ObligationForest<rustc_trait_selection[d035bd7351711dff]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[d035bd7351711dff]::traits::fulfill::FulfillProcessor>
  13:     0x7ef032650347 - <rustc_trait_selection[d035bd7351711dff]::traits::fulfill::FulfillmentContext<rustc_trait_selection[d035bd7351711dff]::traits::FulfillmentError> as rustc_infer[1161895a0fa9626d]::traits::engine::TraitEngine<rustc_trait_selection[d035bd7351711dff]::traits::FulfillmentError>>::select_all_or_error
  14:     0x7ef032ad2bce - rustc_hir_analysis[200ebf77cfece739]::check::compare_impl_item::check_type_bounds
  15:     0x7ef032ac82bc - rustc_hir_analysis[200ebf77cfece739]::check::compare_impl_item::compare_impl_item
  16:     0x7ef032ac64b7 - rustc_query_impl[1e0edd06af9652a1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1e0edd06af9652a1]::query_impl::compare_impl_item::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 1usize]>>
  17:     0x7ef03270d2aa - rustc_query_system[63b8370bb4899dc2]::query::plumbing::try_execute_query::<rustc_query_impl[1e0edd06af9652a1]::DynamicConfig<rustc_data_structures[30a19619986f318]::vec_cache::VecCache<rustc_span[a6bcc981ad5e83db]::def_id::LocalDefId, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[63b8370bb4899dc2]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt, true>
  18:     0x7ef03270f4f6 - rustc_query_impl[1e0edd06af9652a1]::query_impl::compare_impl_item::get_query_incr::__rust_end_short_backtrace
  19:     0x7ef02f991f83 - rustc_hir_analysis[200ebf77cfece739]::check::check::check_item_type
  20:     0x7ef02f9684fb - rustc_hir_analysis[200ebf77cfece739]::check::wfcheck::check_well_formed
  21:     0x7ef032c762b7 - rustc_query_impl[1e0edd06af9652a1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1e0edd06af9652a1]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 1usize]>>
  22:     0x7ef03270d661 - rustc_query_system[63b8370bb4899dc2]::query::plumbing::try_execute_query::<rustc_query_impl[1e0edd06af9652a1]::DynamicConfig<rustc_data_structures[30a19619986f318]::vec_cache::VecCache<rustc_span[a6bcc981ad5e83db]::def_id::LocalDefId, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[63b8370bb4899dc2]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt, true>
  23:     0x7ef0331f1954 - rustc_query_impl[1e0edd06af9652a1]::plumbing::force_from_dep_node::<rustc_query_impl[1e0edd06af9652a1]::DynamicConfig<rustc_data_structures[30a19619986f318]::vec_cache::VecCache<rustc_span[a6bcc981ad5e83db]::def_id::LocalDefId, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[63b8370bb4899dc2]::dep_graph::graph::DepNodeIndex>, false, false, false>>
  24:     0x7ef0331f17ad - <rustc_query_impl[1e0edd06af9652a1]::plumbing::query_callback<rustc_query_impl[1e0edd06af9652a1]::query_impl::check_well_formed::QueryType>::{closure#0} as core[c7a133740aa39aee]::ops::function::FnOnce<(rustc_middle[fa8070f18412b0da]::ty::context::TyCtxt, rustc_query_system[63b8370bb4899dc2]::dep_graph::dep_node::DepNode)>>::call_once
  25:     0x7ef03221fa7f - <rustc_query_system[63b8370bb4899dc2]::dep_graph::graph::DepGraphData<rustc_middle[fa8070f18412b0da]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt>
  26:     0x7ef03221f1ae - <rustc_query_system[63b8370bb4899dc2]::dep_graph::graph::DepGraphData<rustc_middle[fa8070f18412b0da]::dep_graph::DepsType>>::try_mark_green::<rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt>
  27:     0x7ef032cf317d - rustc_query_system[63b8370bb4899dc2]::query::plumbing::ensure_must_run::<rustc_query_impl[1e0edd06af9652a1]::DynamicConfig<rustc_query_system[63b8370bb4899dc2]::query::caches::DefaultCache<rustc_span[a6bcc981ad5e83db]::def_id::LocalModDefId, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt>
  28:     0x7ef03312c993 - rustc_query_impl[1e0edd06af9652a1]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
  29:     0x7ef0325c5b4d - rustc_hir_analysis[200ebf77cfece739]::check_crate
  30:     0x7ef0325cfc5c - rustc_interface[3b74b9441e612cca]::passes::run_required_analyses
  31:     0x7ef033180e7a - rustc_interface[3b74b9441e612cca]::passes::analysis
  32:     0x7ef033180e59 - rustc_query_impl[1e0edd06af9652a1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1e0edd06af9652a1]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 0usize]>>
  33:     0x7ef03317c759 - rustc_query_system[63b8370bb4899dc2]::query::plumbing::try_execute_query::<rustc_query_impl[1e0edd06af9652a1]::DynamicConfig<rustc_query_system[63b8370bb4899dc2]::query::caches::SingleCache<rustc_middle[fa8070f18412b0da]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1e0edd06af9652a1]::plumbing::QueryCtxt, true>
  34:     0x7ef03317c162 - rustc_query_impl[1e0edd06af9652a1]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  35:     0x7ef03328923c - rustc_interface[3b74b9441e612cca]::passes::create_and_enter_global_ctxt::<core[c7a133740aa39aee]::option::Option<rustc_interface[3b74b9441e612cca]::queries::Linker>, rustc_driver_impl[f8acc18714ba66d9]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  36:     0x7ef03327caeb - rustc_interface[3b74b9441e612cca]::interface::run_compiler::<(), rustc_driver_impl[f8acc18714ba66d9]::run_compiler::{closure#0}>::{closure#1}
  37:     0x7ef033107550 - std[54256809445ede48]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[3b74b9441e612cca]::util::run_in_thread_with_globals<rustc_interface[3b74b9441e612cca]::util::run_in_thread_pool_with_globals<rustc_interface[3b74b9441e612cca]::interface::run_compiler<(), rustc_driver_impl[f8acc18714ba66d9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  38:     0x7ef033107974 - <<std[54256809445ede48]::thread::Builder>::spawn_unchecked_<rustc_interface[3b74b9441e612cca]::util::run_in_thread_with_globals<rustc_interface[3b74b9441e612cca]::util::run_in_thread_pool_with_globals<rustc_interface[3b74b9441e612cca]::interface::run_compiler<(), rustc_driver_impl[f8acc18714ba66d9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c7a133740aa39aee]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7ef03310832f - std::sys::pal::unix::thread::Thread::new::thread_start::h208202f9d25af663
  40:     0x7ef02d297d02 - start_thread
  41:     0x7ef02d3173ac - __GI___clone3
  42:                0x0 - <unknown>


rustc version: 1.87.0-nightly (f280acf4c 2025-02-19)
platform: x86_64-unknown-linux-gnu

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `_::HelpLinkEncoder: core::marker::Sync`
#1 [compare_impl_item] checking assoc item `_::<impl at sample/src/lib.rs:7:1: 7:37>::Encoder` is compatible with trait definition
#2 [check_well_formed] checking that `_::<impl at sample/src/lib.rs:7:1: 7:37>` is well-formed
#3 [analysis] running analysis passes on this crate
end of query stack

@matteopolak
Copy link
Owner

Unfortunately the best I can do automatically with the macro is to derive the enabled traits - users will need to add whichever attributes are required for each enabled derive macro (like #[serde(borrow)]).

That ICE is a compiler bug though, I would recommend reporting it if it hasn't been done already :)

I'm not sure which features you have enabled for the second one, but a few of the formats do not support borrowing from input - you will likely want to use Cow<'a, str> instead of str (which is also needed with e.g. serde_json if the input has escaped characters).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants