rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.61k stars 12.48k forks source link

Failure to compile on nightly: perhaps the `coroutine_for_closure` query was never assigned a provider function #121017

Closed humb1t closed 6 months ago

humb1t commented 6 months ago

Code

Unfortunately the codebase is proprietary, but this piece of code is safe to share.


#[allow(clippy::unused_async)]
pub async fn graphql_ws_handler<Q: ObjectType + 'static, M: ObjectType + 'static, S: SubscriptionType + 'static>(
    schema: Extension<Schema<Q, M, S>>,
    protocol: GraphQLProtocol,
    websocket: WebSocketUpgrade,
    state: State<String>,
) -> impl IntoResponse {
    let secret = state.0;
    let on_connection_init = async move |connection_init_payload: serde_json::Value| {
        #[derive(Deserialize)]
        struct Payload {
            #[serde(rename = "Authorization")]
            bearer_token_string: String,
        }
        if let Ok(payload) = serde_json::from_value::<Payload>(connection_init_payload) {
            let mut data = Data::default();
            let jwt_claims = JwtClaims(
                jsonwebtoken::decode::<RegisteredClaims>(
                    payload.bearer_token_string.trim_start_matches("Bearer "),
                    &DecodingKey::from_secret(secret.as_bytes()),
                    &Validation::default(),
                )?
                .claims,
            );
            tracing::debug!("{:?}", &jwt_claims);
            data.insert(jwt_claims);
            Ok(data)
        } else {
            Err("Failed to init connection - token required".into())
        }
    };
    websocket.protocols(ALL_WEBSOCKET_PROTOCOLS).on_upgrade(move |stream| {
        GraphQLWebSocket::new(stream, schema.0, protocol)
            .on_connection_init(on_connection_init)
            .serve()
    })
}

Meta∆

rustc --version --verbose:

rustc 1.78.0-nightly (1a648b397 2024-02-11)

Error output

error: internal compiler error: compiler/rustc_middle/src/query/mod.rs:2222:1: `tcx.coroutine_for_closure(DefId(143:50 ~ graphql[eea6]::handlers::graphql_ws_handler::{closure#0}::{closure#0}))` unsupported by its crate; perhaps the `coroutine_for_closure` query was never assigned a provider function
Backtrace

``` stack backtrace: 0: 0x1015ddfbc - ::fmt::h4a0a68be335d4914 1: 0x1016211a8 - core::fmt::write::h6e402872426c84c7 2: 0x1015d4720 - std::io::Write::write_fmt::hccb279f7ddeda194 3: 0x1015dddf8 - std::sys_common::backtrace::print::h10502623eb5a7d38 4: 0x1015e08e8 - std::panicking::default_hook::{{closure}}::h38eb31f24465acd2 5: 0x1015e0628 - std::panicking::default_hook::h1b82db842fc41ec1 6: 0x10abc7324 - std[e77b8cc82bfbcdfd]::panicking::update_hook::>::{closure#0} 7: 0x1015e0f74 - std::panicking::rust_panic_with_hook::hc40baab8129fe7f9 8: 0x10ac468bc - std[e77b8cc82bfbcdfd]::panicking::begin_panic::::{closure#0} 9: 0x10ac430a0 - std[e77b8cc82bfbcdfd]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 10: 0x10e9e6360 - std[e77b8cc82bfbcdfd]::panicking::begin_panic:: 11: 0x10ac501d0 - ::emit_producing_guarantee 12: 0x10b62ce40 - ::bug:: 13: 0x10b6f8bb4 - rustc_middle[82fdd60edd279704]::util::bug::opt_span_bug_fmt::::{closure#0} 14: 0x10b6f7324 - rustc_middle[82fdd60edd279704]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 15: 0x10b6f6f5c - rustc_middle[82fdd60edd279704]::ty::context::tls::with_context_opt::::default::{closure#28} as core[3a363f1eef6f7cb2]::ops::function::FnOnce<(rustc_middle[82fdd60edd279704]::ty::cont 18: 0x10be04388 - rustc_query_impl[d9b7452daba4f436]::plumbing::__rust_begin_short_backtrace::>> 23: 0x10c444ba8 - rustc_trait_selection[245e993a42eb5754]::traits::project::project 24: 0x10c4419a8 - rustc_trait_selection[245e993a42eb5754]::traits::project::opt_normalize_projection_type 25: 0x10c43ee10 - rustc_trait_selection[245e993a42eb5754]::traits::project::project_and_unify_type 26: 0x10c2e4838 - ::commit_if_ok::::evaluate_predicate_recursively 29: 0x10c31e9c0 - ::evaluate_predicates_recursively::::evaluation_probe::<::evaluate_candidate::{closure#0}::{closure# 31: 0x10c2e8acc - ::probe::::evaluate_stack 33: 0x10c3050d4 - ::with_deps::<::in_task<>::with_anon_task::::evaluate_trait_predicate_recursively 36: 0x10c31ecf0 - ::evaluate_predicate_recursively 37: 0x10c2ffd34 - ::evaluation_probe::<::evaluate_root_obligation::{closure#0}>::{c 38: 0x10c2e9064 - ::probe::::evaluate_obligation 45: 0x10c2fe978 - ::evaluate_obligation_no_overflow 46: 0x10c38be98 - ::process_trait_obligation 47: 0x10c38b030 - ::process_obligation 48: 0x10c378fe4 - >::process_obligations::::select_where_possible 50: 0x10c4e030c - rustc_traits[6ea151025c428050]::codegen::codegen_select_candidate 51: 0x10be056e8 - rustc_query_impl[d9b7452daba4f436]::plumbing::__rust_begin_short_backtrace::::resolve 61: 0x10b6e1bbc - ::expect_resolve 62: 0x10ba02db0 - ::visit_terminator 63: 0x10ba001e8 - ::super_body 64: 0x10ba05e50 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 65: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 66: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 67: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 68: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 69: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 70: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 71: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 72: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 73: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 74: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 75: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 76: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 77: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 78: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 79: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 80: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 81: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 82: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 83: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 84: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 85: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 86: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 87: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 88: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 89: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 90: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 91: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 92: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 93: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 94: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 95: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 96: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 97: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 98: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 99: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 100: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 101: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 102: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 103: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 104: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 105: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 106: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 107: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 108: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 109: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 110: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 111: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 112: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 113: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 114: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 115: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 116: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 117: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 118: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 119: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 120: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 121: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 122: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 123: 0x10ba06480 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_items_rec 124: 0x10ba28fec - std[e77b8cc82bfbcdfd]::panicking::try::<(), core[3a363f1eef6f7cb2]::panic::unwind_safe::AssertUnwindSafe::run::<(), rustc_data_structures[712596e8823b4fc6]::sync::parallel::enabled::par_for_each_in, rayon[c833ee01c0c95405]::iter::for_each:: 127: 0x10ba295d4 - rayon_core[cd5ddfc0c0f16cb0]::join::join_context::, rayon[c833ee01c0c95405]::iter::for_each:: 130: 0x10ba295d4 - rayon_core[cd5ddfc0c0f16cb0]::join::join_context::, rayon[c833ee01c0c95405]::iter::for_each:: 133: 0x10ba295d4 - rayon_core[cd5ddfc0c0f16cb0]::join::join_context:: as rayon[c833ee01c0c95405]::iter::IndexedParallelIterator>::with_producer::::time::<(), rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_crate_mono_items::{closure#1}> 138: 0x10ba04498 - rustc_monomorphize[44a02060cf3ad5f6]::collector::collect_crate_mono_items 139: 0x10ba123fc - rustc_monomorphize[44a02060cf3ad5f6]::partitioning::collect_and_partition_mono_items 140: 0x10be061a4 - rustc_query_impl[d9b7452daba4f436]::plumbing::__rust_begin_short_backtrace::> 141: 0x10bef3bf0 - >::call_once 142: 0x10bd33710 - rustc_query_system[f11765a6e63743ab]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[d9b7452daba4f436]::plumbing::QueryCtxt, true> 143: 0x10be83620 - rustc_query_impl[d9b7452daba4f436]::query_impl::collect_and_partition_mono_items::get_query_incr::__rust_end_short_backtrace 144: 0x10a919080 - rustc_codegen_ssa[da70ac4bdeef98b3]::base::codegen_crate:: 145: 0x10a95d4f4 - ::codegen_crate 146: 0x10b35fc80 - ::time::, rustc_interface[9b9c728c161af33d]::passes::start_codegen::{closure#0}> 147: 0x10b35f5e4 - rustc_interface[9b9c728c161af33d]::passes::start_codegen 148: 0x10b30ba80 - ::enter::<::codegen_and_build_linker::{closure#0}, core[3a363f1eef6f7cb2]::result::Result> 149: 0x10b32b4dc - ::codegen_and_build_linker 150: 0x10ab9b42c - ::enter::, rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>> 151: 0x10abcec38 - rustc_span[9910a9a9a2b8b1b0]::set_source_map::, rustc_interface[9b9c728c161af33d]::interface::run_compiler, rustc_driver_impl[219c9928d75f923b]::run_compiler::{closure#0}>::{closure#0}::{closure#0}> 152: 0x10abc6414 - ::install::, rustc_driver_impl[219c9928d75f923b]::run_compiler::{closure#0}>::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#0} 153: 0x10abc4550 - std[e77b8cc82bfbcdfd]::panicking::try::, core[3a363f1eef6f7cb2]::panic::unwind_safe::AssertUnwindSafe<>>::call<::in_worker_cold<::install, rustc_driver_impl[219c9928d75f923b]::run_compiler::{closure#0}>::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#0}::{closure#0}>::{closure#0}>> 154: 0x10ab959f0 - , ::in_worker_cold<::install, rustc_driver_impl[219c9928d75f923b]::run_compiler::{closure#0}>::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>> as rayon_core[cd5ddfc0c0f16cb0]::job::Job>::execute 155: 0x10e97d3c8 - ::wait_until_cold 156: 0x10a2c5314 - ::run 157: 0x10abcf098 - rustc_span[9910a9a9a2b8b1b0]::set_session_globals_then::<(), rustc_interface[9b9c728c161af33d]::util::run_in_thread_pool_with_globals, rustc_driver_impl[219c9928d75f923b]::run_compiler::{closure#0}>::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#3}::{closure#0}::{closure#0}::{closure#0}> 158: 0x10abc7778 - <::spawn<::build_scoped, rustc_driver_impl[219c9928d75f923b]::run_compiler::{closure#0}>::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#3}::{closure#0}::{closure#0}, rustc_interface[9b9c728c161af33d]::util::run_in_thread_pool_with_globals, rustc_driver_impl[219c9928d75f923b]::run_compiler::{closure#0}>::{closure#0}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#3}::{closure#0}::{closure#1}, core[3a363f1eef6f7cb2]::result::Result<(), rustc_span[9910a9a9a2b8b1b0]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, ()>::{closure#0} as core[3a363f1eef6f7cb2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 159: 0x10abc4a2c - std[e77b8cc82bfbcdfd]::sys_common::backtrace::__rust_begin_short_backtrace:: + core[3a363f1eef6f7cb2]::marker::Send>, ()> 160: 0x10ab94a54 - <::spawn_unchecked_ + core[3a363f1eef6f7cb2]::marker::Send>, ()>::{closure#1} as core[3a363f1eef6f7cb2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 161: 0x1015e8788 - std::sys::pal::unix::thread::Thread::new::thread_start::ha368f5c01e431785 162: 0x18eecd034 - __pthread_joiner_wake ```

humb1t commented 6 months ago

Extracting on_connection_init to a function helps to work around that issue.

compiler-errors commented 6 months ago

This should be fixed by #120897.