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. --This was in a closed source codebase I don't have time to minimize right now. It happened when I called (or something like that, don't exactly remember) on a value with type . Don't remember what T or E were :( <!-- 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. --: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
might be related to one of these ^^
Ugh, this is due to adding this  call -- something is calling this with a type that has region variables that no longer exist, probably from an or ... I can possibly try to reproduce, but this will be difficult to do without an MVCE.
can you try or is this a different issue?
This is a different issue. is a trait solver issue having to do with higher ranked type equality and the . This has to do with a region variable escaping out of a . Specifically it's this one:
Actually wait this is a type variable that's escaping. Ugh, probably due to opaque types :?
oh I forgot I saved this code I will try to trim it down to something I can post publicly
if you can, it would be incredibly useful here.
WG-prioritization assigning priority (). label -I-prioritize +P-medium

Discussion:
use crate::infer::combine::ConstEquateRelation; use crate::infer::{TypeVariableOrigin, TypeVariableOriginKind}; use crate::traits::Obligation; <ins> use rustc_middle::ty::error::{ExpectedFound, TypeError}; </ins> use rustc_middle::ty::relate::{Cause, Relate, RelateResult, TypeRelation}; use rustc_middle::ty::visit::TypeVisitable; use rustc_middle::ty::TyVar;

Ok(infcx.tcx.mk_ty_var(var)) }; let (a, b) = if self.a_is_expected { (a, b) } else { (b, a) }; <del> let (a, b) = match (a.kind(), b.kind()) { </del> <ins> let (ga, gb) = match (a.kind(), b.kind()) { </ins> (&ty::Opaque(..), _) => (a, generalize(b, true)?), (_, &ty::Opaque(..)) => (generalize(a, false)?, b), _ => unreachable!(), }; self.fields.obligations.extend( infcx <del> .handle_opaque_type(a, b, true, &self.fields.trace.cause, self.param_env())? </del> <ins> .handle_opaque_type(ga, gb, true, &self.fields.trace.cause, self.param_env()) // Don't leak any generalized type variables out of this // subtyping relation in the case of a type error. .map_err(|err| { let (ga, gb) = self.fields.infcx.resolve_vars_if_possible((ga, gb)); if let TypeError::Sorts(sorts) = err && sorts.expected == ga && sorts.found == gb { TypeError::Sorts(ExpectedFound { expected: a, found: b }) } else { err } })? </ins> .obligations, ); <del> Ok(a) </del> <ins> Ok(ga) </ins> } _ => {

<ins> // edition:2021 fn main() {} struct Error; struct Okay; fn foo(t: Result<Okay, Error>) { t.and_then(|t| -> _ { bar(t) }); //~^ ERROR mismatched types } async fn bar(t: Okay) {} </ins>

<ins> error[E0308]: mismatched types --> $DIR/issue-99914.rs:9:27 | LL |     t.and_then(|t| -> _ { bar(t) }); |                           ^^^^^^ expected enum `Result`, found opaque type | note: while checking the return type of the `async fn` --> $DIR/issue-99914.rs:13:23 | LL | async fn bar(t: Okay) {} |                       ^ checked the `Output` of this `async fn`, found opaque type = note:     expected enum `Result<_, Error>` found opaque type `impl Future<Output = ()>` help: try wrapping the expression in `Ok` | LL |     t.and_then(|t| -> _ { Ok(bar(t)) }); |                           +++      + error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. </ins>