diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-12-15 01:28:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-15 01:28:04 +0100 |
| commit | 272188eecd59e122d2ad435256c0f65a0f63ccbf (patch) | |
| tree | c1f7c6eb8711727fb3b43d592f5abf1a8abf3948 /compiler/rustc_passes/src | |
| parent | 2f4da6243f817b26c5c8156408911a01b39f9759 (diff) | |
| parent | f2fc84f60456d2acc480ca3b5616e5e9612575ec (diff) | |
| download | rust-272188eecd59e122d2ad435256c0f65a0f63ccbf.tar.gz rust-272188eecd59e122d2ad435256c0f65a0f63ccbf.zip | |
Rollup merge of #90939 - estebank:wg-af-polish, r=tmandry
Tweak errors coming from `for`-loop, `?` and `.await` desugaring
* Suggest removal of `.await` on non-`Future` expression
* Keep track of obligations introduced by desugaring
* Remove span pointing at method for obligation errors coming from desugaring
* Point at called local sync `fn` and suggest making it `async`
```
error[E0277]: `()` is not a future
--> $DIR/unnecessary-await.rs:9:10
|
LL | boo().await;
| -----^^^^^^ `()` is not a future
| |
| this call returns `()`
|
= help: the trait `Future` is not implemented for `()`
help: do not `.await` the expression
|
LL - boo().await;
LL + boo();
|
help: alternatively, consider making `fn boo` asynchronous
|
LL | async fn boo () {}
| +++++
```
Fix #66731.
Diffstat (limited to 'compiler/rustc_passes/src')
| -rw-r--r-- | compiler/rustc_passes/src/region.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_passes/src/region.rs b/compiler/rustc_passes/src/region.rs index ae423070392..8968c163987 100644 --- a/compiler/rustc_passes/src/region.rs +++ b/compiler/rustc_passes/src/region.rs @@ -421,11 +421,14 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h // Mark this expr's scope and all parent scopes as containing `yield`. let mut scope = Scope { id: expr.hir_id.local_id, data: ScopeData::Node }; loop { - let data = YieldData { - span: expr.span, - expr_and_pat_count: visitor.expr_and_pat_count, - source: *source, + let span = match expr.kind { + hir::ExprKind::Yield(expr, hir::YieldSource::Await { .. }) => { + expr.span.shrink_to_hi().to(expr.span) + } + _ => expr.span, }; + let data = + YieldData { span, expr_and_pat_count: visitor.expr_and_pat_count, source: *source }; visitor.scope_tree.yield_in_scope.insert(scope, data); if visitor.pessimistic_yield { debug!("resolve_expr in pessimistic_yield - marking scope {:?} for fixup", scope); |
