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:
parent
d45e030c04
commit
f640438b40
14 changed files with 138 additions and 36 deletions
|
@ -2362,7 +2362,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
.map(|(ty, _, _)| ty)
|
||||
.unwrap_or_else(|_| tcx.ty_error())
|
||||
}
|
||||
hir::TyKind::Path(hir::QPath::LangItem(lang_item, span)) => {
|
||||
hir::TyKind::Path(hir::QPath::LangItem(lang_item, span, _)) => {
|
||||
let def_id = tcx.require_lang_item(lang_item, Some(span));
|
||||
let (substs, _) = self.create_substs_for_ast_path(
|
||||
span,
|
||||
|
|
|
@ -277,8 +277,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
ExprKind::AddrOf(kind, mutbl, oprnd) => {
|
||||
self.check_expr_addr_of(kind, mutbl, oprnd, expected, expr)
|
||||
}
|
||||
ExprKind::Path(QPath::LangItem(lang_item, _)) => {
|
||||
self.check_lang_item_path(lang_item, expr)
|
||||
ExprKind::Path(QPath::LangItem(lang_item, _, hir_id)) => {
|
||||
self.check_lang_item_path(lang_item, expr, hir_id)
|
||||
}
|
||||
ExprKind::Path(ref qpath) => self.check_expr_path(qpath, expr, &[]),
|
||||
ExprKind::InlineAsm(asm) => self.check_expr_asm(asm),
|
||||
|
@ -498,8 +498,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
&self,
|
||||
lang_item: hir::LangItem,
|
||||
expr: &'tcx hir::Expr<'tcx>,
|
||||
hir_id: Option<hir::HirId>,
|
||||
) -> Ty<'tcx> {
|
||||
self.resolve_lang_item_path(lang_item, expr.span, expr.hir_id).1
|
||||
self.resolve_lang_item_path(lang_item, expr.span, expr.hir_id, hir_id).1
|
||||
}
|
||||
|
||||
pub(crate) fn check_expr_path(
|
||||
|
|
|
@ -791,6 +791,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
lang_item: hir::LangItem,
|
||||
span: Span,
|
||||
hir_id: hir::HirId,
|
||||
expr_hir_id: Option<hir::HirId>,
|
||||
) -> (Res, Ty<'tcx>) {
|
||||
let def_id = self.tcx.require_lang_item(lang_item, Some(span));
|
||||
let def_kind = self.tcx.def_kind(def_id);
|
||||
|
@ -809,7 +810,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
def_id,
|
||||
&substs,
|
||||
match lang_item {
|
||||
hir::LangItem::FuturePoll => ObligationCauseCode::AwaitableExpr,
|
||||
hir::LangItem::FuturePoll => ObligationCauseCode::AwaitableExpr(expr_hir_id),
|
||||
hir::LangItem::IteratorNext | hir::LangItem::IntoIterIntoIter => {
|
||||
ObligationCauseCode::ForLoopIterator
|
||||
}
|
||||
|
|
|
@ -938,8 +938,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
(result.map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id)), ty)
|
||||
}
|
||||
QPath::LangItem(lang_item, span) => {
|
||||
self.resolve_lang_item_path(lang_item, span, hir_id)
|
||||
QPath::LangItem(lang_item, span, id) => {
|
||||
self.resolve_lang_item_path(lang_item, span, hir_id, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue