Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --Does not happen with this callback: <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: </p</details
The code snippet is incomplete: is there a repository available that we could try, to reproduce the error? If not, could you at least add the full function? Thanks!
Rust use tungstenite::handshake::server::{Response, ErrorResponse}; fn acceptconnection(stream: TcpStream, config: rustls::server::ServerConfig) -Result<Socket{ let mut conn = rustls::server::ServerConnection::new(std::sync::Arc::new(()))?; let tlsstream = rustls::StreamOwned::new(conn, stream.tryclone()?); if let Ok(ws) = match tungstenite::accepthdrwithconfig(tlsstream, -std::result::Result<Response, ErrorResponse{ let callback = -std::result::Result<tungstenite::handshake::server::Response, tungstenite::handshake::server::ErrorResponse{ dbg!(&req); dbg!(&res); Ok(res) }; if let Ok(ws) = match tungstenite::accepthdrwithconfig(tlsstream, callback, None) { Err(HandshakeError::Interrupted(midhandshake)) ={ info!( "Handshake interrupted with peer {} - waiting to try again.", peer_addr ); Ok(Socket::Interrupted(midhandshake)) } Err(e) ={ error!("Error accepting secure websocket connection: {e}"); Err(e)? } Ok(ws) =Ok(Socket::SecureWebSocket(ws)), } } }
This is still incomplete and doesn't parse. Do you have a repository where the issue can be reproduced?
No repo. You can make it parse pretty easily. I am not a rustc expert but I believe the issue was with the callback.
Here's a small (but not minimal yet) working repro: and with that we can finally bisect, to : probably that (no need to ping anyone here) I'll minimize next to remove this dependency and create an MCVE.
removed:
Probably not yet an MCVE and could be further simplified, but getting close.
62 error -1.63 error + ice
WG-prioritization assigning priority (). label -I-prioritize +P-medium -E-needs-mcve

Discussion:
} pub(crate) fn universe_info(&self, universe: ty::UniverseIndex) -> UniverseInfo<'tcx> { <del> self.universe_causes[&universe].clone() </del> <ins> // Query canonicalization can create local superuniverses (for example in // `InferCtx::query_response_substitution_guess`), but they don't have an associated // `UniverseInfo` explaining why they were created. // This can cause ICEs if these causes are accessed in diagnostics, for example in issue // #114907 where this happens via liveness and dropck outlives results. // Therefore, we return a default value in case that happens, which should at worst emit a // suboptimal error, instead of the ICE. self.universe_causes.get(&universe).cloned().unwrap_or_else(|| UniverseInfo::other()) </ins> } /// Tries to find the terminator of the loop in which the region 'r' resides.

use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput}; use rustc_trait_selection::traits::ObligationCause; <del> use crate::diagnostics::{ToUniverseInfo, UniverseInfo}; </del> <ins> use crate::diagnostics::ToUniverseInfo; </ins> use super::{Locations, NormalizeLocation, TypeChecker};

self.push_region_constraints(locations, category, data); } <ins> // If the query has created new universes and errors are going to be emitted, register the // cause of these new universes for improved diagnostics. </ins> let universe = self.infcx.universe(); <del> if old_universe != universe { let universe_info = match error_info { Some(error_info) => error_info.to_universe_info(old_universe), None => UniverseInfo::other(), }; </del> <ins> if old_universe != universe && let Some(error_info) = error_info { let universe_info = error_info.to_universe_info(old_universe); </ins> for u in (old_universe + 1)..=universe { self.borrowck_context.constraints.universe_causes.insert(u, universe_info.clone()); }

where T: TypeFoldable<TyCtxt<'tcx>>, { <del> let old_universe = self.infcx.universe(); </del> let (instantiated, _) = self.infcx.instantiate_canonical_with_fresh_inference_vars(span, canonical); <del> for u in (old_universe + 1)..=self.infcx.universe() { self.borrowck_context.constraints.universe_causes.insert(u, UniverseInfo::other()); } </del> instantiated }

debug!(?normalized_inputs_and_output); <del> for u in ty::UniverseIndex::ROOT..=infcx.universe() { constraints.universe_causes.insert(u, UniverseInfo::other()); } </del> let mut borrowck_context = BorrowCheckContext { universal_regions, location_table,

<ins> // This is a non-regression test for issue #114907 where an ICE happened because of missing // `UniverseInfo`s accessed during diagnostics. // // A couple notes: // - the `FnOnce` bounds need an arg that is a reference // - a custom `Drop` is needed somewhere in the type that `accept` returns, to create universes //   during liveness and dropck outlives computation // check-fail trait Role { type Inner; } struct HandshakeCallback<C>(C); impl<C: FnOnce(&())> Role for HandshakeCallback<C> { type Inner = (); } struct Handshake<R: Role> { _inner: Option<R::Inner>, } impl<R: Role> Drop for Handshake<R> { fn drop(&mut self) {} } fn accept<C: FnOnce(&())>(_: C) -> Handshake<HandshakeCallback<C>> { todo!() } fn main() { let callback = |_| {}; accept(callback); //~^ ERROR mismatched types //~| ERROR mismatched types //~| ERROR implementation of `FnOnce` is not general enough //~| ERROR implementation of `FnOnce` is not general enough //~| ERROR higher-ranked subtype error //~| ERROR higher-ranked subtype error } </ins>

<ins> error[E0308]: mismatched types --> $DIR/missing-universe-cause-issue-114907.rs:33:5 | LL |     accept(callback); |     ^^^^^^^^^^^^^^^^ one type is more general than the other | = note: expected trait `for<'a> FnOnce<(&'a (),)>` found trait `FnOnce<(&(),)>` note: this closure does not fulfill the lifetime requirements --> $DIR/missing-universe-cause-issue-114907.rs:32:20 | LL |     let callback = |_| {}; |                    ^^^ note: the lifetime requirement is introduced here --> $DIR/missing-universe-cause-issue-114907.rs:27:14 | LL | fn accept<C: FnOnce(&())>(_: C) -> Handshake<HandshakeCallback<C>> { |              ^^^^^^^^^^^ help: consider specifying the type of the closure parameters | LL |     let callback = |_: &_| {}; |                    ~~~~~~~ error: implementation of `FnOnce` is not general enough --> $DIR/missing-universe-cause-issue-114907.rs:33:5 | LL |     accept(callback); |     ^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | = note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` error: implementation of `FnOnce` is not general enough --> $DIR/missing-universe-cause-issue-114907.rs:33:5 | LL |     accept(callback); |     ^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | = note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` error[E0308]: mismatched types --> $DIR/missing-universe-cause-issue-114907.rs:33:5 | LL |     accept(callback); |     ^^^^^^^^^^^^^^^^ one type is more general than the other | = note: expected trait `for<'a> FnOnce<(&'a (),)>` found trait `FnOnce<(&(),)>` note: this closure does not fulfill the lifetime requirements --> $DIR/missing-universe-cause-issue-114907.rs:32:20 | LL |     let callback = |_| {}; |                    ^^^ note: the lifetime requirement is introduced here --> $DIR/missing-universe-cause-issue-114907.rs:20:21 | LL | struct Handshake<R: Role> { |                     ^^^^ help: consider specifying the type of the closure parameters | LL |     let callback = |_: &_| {}; |                    ~~~~~~~ error: higher-ranked subtype error --> $DIR/missing-universe-cause-issue-114907.rs:33:21 | LL |     accept(callback); |                     ^ error: higher-ranked subtype error --> $DIR/missing-universe-cause-issue-114907.rs:33:21 | LL |     accept(callback); |                     ^ error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0308`. </ins>