1
Fork 0

fix RedundantLocals clippy caused by async and await

This commit is contained in:
yukang 2023-08-02 16:17:31 +08:00
parent 75b9f53e47
commit ac25636a8f
2 changed files with 22 additions and 3 deletions

View file

@ -463,3 +463,12 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool {
ExpnKind::Macro { .. } => true, // definitely a plugin
}
}
/// Return whether `span` is generated by `async` or `await`.
pub fn is_from_async_await(span: Span) -> bool {
let expn_data = span.ctxt().outer_expn_data();
match expn_data.kind {
ExpnKind::Desugaring(DesugaringKind::Async | DesugaringKind::Await) => true,
_ => false,
}
}