Fix a couple more DefKind discrepancies between DefKind::Closure and DefKind::SyntheticCoroutineBody
This commit is contained in:
parent
af1ca7794a
commit
4beb1cf9e5
@ -287,7 +287,10 @@ pub fn def_path_data(self, name: Symbol) -> DefPathData {
|
||||
|
||||
#[inline]
|
||||
pub fn is_fn_like(self) -> bool {
|
||||
matches!(self, DefKind::Fn | DefKind::AssocFn | DefKind::Closure)
|
||||
matches!(
|
||||
self,
|
||||
DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::SyntheticCoroutineBody
|
||||
)
|
||||
}
|
||||
|
||||
/// Whether `query get_codegen_attrs` should be used with this definition.
|
||||
|
@ -24,7 +24,7 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
||||
|
||||
// This just reproduces the logic from Instance::requires_inline.
|
||||
match tcx.def_kind(def_id) {
|
||||
DefKind::Ctor(..) | DefKind::Closure => return true,
|
||||
DefKind::Ctor(..) | DefKind::Closure | DefKind::SyntheticCoroutineBody => return true,
|
||||
DefKind::Fn | DefKind::AssocFn => {}
|
||||
_ => return false,
|
||||
}
|
||||
|
@ -227,7 +227,11 @@ fn compute_symbol_name<'tcx>(
|
||||
// and we want to be sure to avoid any symbol conflicts here.
|
||||
let is_globally_shared_function = matches!(
|
||||
tcx.def_kind(instance.def_id()),
|
||||
DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Ctor(..)
|
||||
DefKind::Fn
|
||||
| DefKind::AssocFn
|
||||
| DefKind::Closure
|
||||
| DefKind::SyntheticCoroutineBody
|
||||
| DefKind::Ctor(..)
|
||||
) && matches!(
|
||||
MonoItem::Fn(instance).instantiation_mode(tcx),
|
||||
InstantiationMode::GloballyShared { may_conflict: true }
|
||||
|
34
tests/ui/async-await/async-closures/inline-body.rs
Normal file
34
tests/ui/async-await/async-closures/inline-body.rs
Normal file
@ -0,0 +1,34 @@
|
||||
//@ edition: 2021
|
||||
//@ compile-flags: -Zinline-mir
|
||||
//@ build-pass
|
||||
|
||||
// Ensure that we don't hit a Steal ICE because we forgot to ensure
|
||||
// `mir_inliner_callees` for the synthetic by-move coroutine body since
|
||||
// its def-id wasn't previously being considered.
|
||||
|
||||
#![feature(async_closure, noop_waker)]
|
||||
|
||||
use std::future::Future;
|
||||
use std::pin::pin;
|
||||
use std::task::*;
|
||||
|
||||
pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
|
||||
let mut fut = pin!(fut);
|
||||
let ctx = &mut Context::from_waker(Waker::noop());
|
||||
|
||||
loop {
|
||||
match fut.as_mut().poll(ctx) {
|
||||
Poll::Pending => {}
|
||||
Poll::Ready(t) => break t,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn call_once<T>(f: impl async FnOnce() -> T) -> T {
|
||||
f().await
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let c = async || {};
|
||||
block_on(call_once(c));
|
||||
}
|
Loading…
Reference in New Issue
Block a user