1
Fork 0

Keep info on pre-desugaring expression for better "incorrect .await" suggestion

Keep the `HirId` of `.await`ed expressions so in the case of a `fn` call
on on a sync `fn`, we can suggest maybe turning it into an `async fn`.
This commit is contained in:
Esteban Kuber 2021-11-16 20:07:23 +00:00
parent d45e030c04
commit f640438b40
14 changed files with 138 additions and 36 deletions

View file

@ -1627,13 +1627,13 @@ pub fn is_range_literal(expr: &Expr<'_>) -> bool {
| LangItem::RangeFrom
| LangItem::RangeFull
| LangItem::RangeToInclusive,
_,
..
)
),
// `..=` desugars into `::std::ops::RangeInclusive::new(...)`.
ExprKind::Call(ref func, _) => {
matches!(func.kind, ExprKind::Path(QPath::LangItem(LangItem::RangeInclusiveNew, _)))
matches!(func.kind, ExprKind::Path(QPath::LangItem(LangItem::RangeInclusiveNew, ..)))
}
_ => false,
@ -1788,8 +1788,8 @@ pub enum QPath<'hir> {
/// the `X` and `Y` nodes each being a `TyKind::Path(QPath::TypeRelative(..))`.
TypeRelative(&'hir Ty<'hir>, &'hir PathSegment<'hir>),
/// Reference to a `#[lang = "foo"]` item.
LangItem(LangItem, Span),
/// Reference to a `#[lang = "foo"]` item. `HirId` of the inner expr.
LangItem(LangItem, Span, Option<HirId>),
}
impl<'hir> QPath<'hir> {
@ -1798,7 +1798,7 @@ impl<'hir> QPath<'hir> {
match *self {
QPath::Resolved(_, path) => path.span,
QPath::TypeRelative(qself, ps) => qself.span.to(ps.ident.span),
QPath::LangItem(_, span) => span,
QPath::LangItem(_, span, _) => span,
}
}
@ -1808,7 +1808,7 @@ impl<'hir> QPath<'hir> {
match *self {
QPath::Resolved(_, path) => path.span,
QPath::TypeRelative(qself, _) => qself.span,
QPath::LangItem(_, span) => span,
QPath::LangItem(_, span, _) => span,
}
}
@ -1818,7 +1818,7 @@ impl<'hir> QPath<'hir> {
match *self {
QPath::Resolved(_, path) => path.segments.last().unwrap().ident.span,
QPath::TypeRelative(_, segment) => segment.ident.span,
QPath::LangItem(_, span) => span,
QPath::LangItem(_, span, _) => span,
}
}
}