Change:
Here's a MVCE: I expected to see this happen: compilation fails because I'm clearly returning an instead of a Instead, this happened: bad codegen ("async fn resumed after completion") :
This is specifically a bug with default body in traits, this doesn't happen in s. I'll check it out, it's probably a very simple fix.

Discussion:
use crate::errors::OpaqueHiddenTypeDiag; use crate::infer::{DefiningAnchor, InferCtxt, InferOk}; use crate::traits; <ins> use hir::def::DefKind; </ins> use hir::def_id::{DefId, LocalDefId}; use hir::{HirId, OpaqueTyOrigin}; use rustc_data_structures::sync::Lrc;

ty_op: |ty| match *ty.kind() { // We can't normalize associated types from `rustc_infer`, // but we can eagerly register inference variables for them. <del> ty::Projection(projection_ty) if !projection_ty.has_escaping_bound_vars() => { </del> <ins> // FIXME(RPITIT): Don't replace RPITITs with inference vars. ty::Projection(projection_ty) if !projection_ty.has_escaping_bound_vars() && tcx.def_kind(projection_ty.item_def_id) != DefKind::ImplTraitPlaceholder => { </ins> self.infer_projection( param_env, projection_ty,

{ hidden_ty } <ins> // FIXME(RPITIT): This can go away when we move to associated types ty::Projection(proj) if def_id.to_def_id() == proj.item_def_id && substs == proj.substs => { hidden_ty } </ins> _ => ty, }, lt_op: |lt| lt,

<ins> // edition:2021 #![allow(incomplete_features)] #![feature(async_fn_in_trait)] pub trait Foo { async fn woopsie_async(&self) -> String { 42 //~^ ERROR mismatched types } } fn main() {} </ins>

<ins> error[E0308]: mismatched types --> $DIR/default-body-type-err-2.rs:8:9 | LL |         42 |         ^^- help: try using a conversion method: `.to_string()` |         | |         expected struct `String`, found integer error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. </ins>

<ins> #![allow(incomplete_features)] #![feature(return_position_impl_trait_in_trait)] use std::ops::Deref; pub trait Foo { fn lol(&self) -> impl Deref<Target = String> { //~^ type mismatch resolving `<&i32 as Deref>::Target == String` &1i32 } } fn main() {} </ins>

<ins> error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String` --> $DIR/default-body-type-err.rs:7:22 | LL |     fn lol(&self) -> impl Deref<Target = String> { |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found struct `String` LL | LL |         &1i32 |         ----- return type was inferred to be `&i32` here error: aborting due to previous error For more information about this error, try `rustc --explain E0271`. </ins>

<del> // known-bug: #102688 </del> <ins> // check-pass </ins> // edition:2021 #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]

<del> error[E0720]: cannot resolve opaque type --> $DIR/default-body-with-rpit.rs:10:28 | LL |     async fn baz(&self) -> impl Debug { |                            ^^^^^^^^^^ cannot resolve opaque type | = note: these returned values have a concrete "never" type = help: this error will resolve once the item's body returns a concrete type error: aborting due to previous error For more information about this error, try `rustc --explain E0720`. </del>