Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a4bff74
Test not never
dtolnay Nov 22, 2021
9e83478
impl Not for !
dtolnay Nov 22, 2021
881e093
Replace ! with * in ui test of unary expr reachability
dtolnay Nov 22, 2021
ef472f1
Stabilize arc_new_cyclic
bdbai Dec 13, 2021
ce31cbc
use generic params for arc_new_cyclic
bdbai Dec 30, 2021
7356e28
Tweak `expr.await` desugaring `Span`
estebank Jan 20, 2022
3136c5f
Update stabilization version of impl Not for !
dtolnay Jan 20, 2022
f0525da
Unify search input and buttons size
GuillaumeGomez Jan 20, 2022
ee6c33c
Fix spacing for `·` between stability and source
jsha Jan 19, 2022
fc16b81
rustdoc: Make some `pub` items crate-private
camelid Jan 22, 2022
9427ccb
Remove dead code from build_helper
mati865 Jan 22, 2022
00e191c
Update stabilization version of arc_new_cyclic
m-ou-se Jan 22, 2022
ab5437e
update uclibc instructions for new toolchain, add link from platforms…
skrap Jan 21, 2022
59d9ad9
Rollup merge of #90666 - bdbai:arc_new_cyclic, r=m-ou-se
matthiaskrgr Jan 23, 2022
55a1f8b
Rollup merge of #91122 - dtolnay:not, r=m-ou-se
matthiaskrgr Jan 23, 2022
24ac541
Rollup merge of #93068 - jsha:dot-spacing, r=GuillaumeGomez
matthiaskrgr Jan 23, 2022
a152528
Rollup merge of #93103 - estebank:await-span, r=nagisa
matthiaskrgr Jan 23, 2022
74b05ce
Rollup merge of #93113 - GuillaumeGomez:unify-sizes, r=jsha
matthiaskrgr Jan 23, 2022
389e712
Rollup merge of #93168 - skrap:master, r=Amanieu
matthiaskrgr Jan 23, 2022
d4c9c5a
Rollup merge of #93185 - camelid:crate-private, r=GuillaumeGomez
matthiaskrgr Jan 23, 2022
1a935a5
Rollup merge of #93196 - mati865:remove-build_helper-dead-code, r=Mar…
matthiaskrgr Jan 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tweak expr.await desugaring Span
Fix #93074
  • Loading branch information
estebank committed Jan 20, 2022
commit 7356e28abbd56ff600dff1d34553b5bebcfc8767
20 changes: 10 additions & 10 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,18 +630,18 @@ impl<'hir> LoweringContext<'_, 'hir> {
/// }
/// }
/// ```
fn lower_expr_await(&mut self, await_span: Span, expr: &Expr) -> hir::ExprKind<'hir> {
let dot_await_span = expr.span.shrink_to_hi().to(await_span);
fn lower_expr_await(&mut self, dot_await_span: Span, expr: &Expr) -> hir::ExprKind<'hir> {
let full_span = expr.span.to(dot_await_span);
match self.generator_kind {
Some(hir::GeneratorKind::Async(_)) => {}
Some(hir::GeneratorKind::Gen) | None => {
let mut err = struct_span_err!(
self.sess,
await_span,
dot_await_span,
E0728,
"`await` is only allowed inside `async` functions and blocks"
);
err.span_label(await_span, "only allowed inside `async` functions and blocks");
err.span_label(dot_await_span, "only allowed inside `async` functions and blocks");
if let Some(item_sp) = self.current_item {
err.span_label(item_sp, "this is not `async`");
}
Expand All @@ -651,7 +651,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let span = self.mark_span_with_reason(DesugaringKind::Await, dot_await_span, None);
let gen_future_span = self.mark_span_with_reason(
DesugaringKind::Await,
await_span,
full_span,
self.allow_gen_future.clone(),
);
let expr = self.lower_expr_mut(expr);
Expand Down Expand Up @@ -704,9 +704,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
let loop_hir_id = self.lower_node_id(loop_node_id);
let ready_arm = {
let x_ident = Ident::with_dummy_span(sym::result);
let (x_pat, x_pat_hid) = self.pat_ident(span, x_ident);
let x_expr = self.expr_ident(span, x_ident, x_pat_hid);
let ready_field = self.single_pat_field(span, x_pat);
let (x_pat, x_pat_hid) = self.pat_ident(gen_future_span, x_ident);
let x_expr = self.expr_ident(gen_future_span, x_ident, x_pat_hid);
let ready_field = self.single_pat_field(gen_future_span, x_pat);
let ready_pat = self.pat_lang_item_variant(
span,
hir::LangItem::PollReady,
Expand All @@ -716,7 +716,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let break_x = self.with_loop_scope(loop_node_id, move |this| {
let expr_break =
hir::ExprKind::Break(this.lower_loop_destination(None), Some(x_expr));
this.arena.alloc(this.expr(span, expr_break, ThinVec::new()))
this.arena.alloc(this.expr(gen_future_span, expr_break, ThinVec::new()))
});
self.arm(ready_pat, break_x)
};
Expand Down Expand Up @@ -788,7 +788,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// `match ::std::future::IntoFuture::into_future(<expr>) { ... }`
let into_future_span = self.mark_span_with_reason(
DesugaringKind::Await,
await_span,
dot_await_span,
self.allow_into_future.clone(),
);
let into_future_expr = self.expr_call_lang_item_fn(
Expand Down
11 changes: 11 additions & 0 deletions src/test/ui/async-await/proper-span-for-type-error.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// edition:2021
// run-rustfix
#![allow(dead_code)]

async fn a() {}

async fn foo() -> Result<(), i32> {
Ok(a().await) //~ ERROR mismatched types
}

fn main() {}
11 changes: 11 additions & 0 deletions src/test/ui/async-await/proper-span-for-type-error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// edition:2021
// run-rustfix
#![allow(dead_code)]

async fn a() {}

async fn foo() -> Result<(), i32> {
a().await //~ ERROR mismatched types
}

fn main() {}
16 changes: 16 additions & 0 deletions src/test/ui/async-await/proper-span-for-type-error.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error[E0308]: mismatched types
--> $DIR/proper-span-for-type-error.rs:8:5
|
LL | a().await
| ^^^^^^^^^ expected enum `Result`, found `()`
|
= note: expected enum `Result<(), i32>`
found unit type `()`
help: try wrapping the expression in `Ok`
|
LL | Ok(a().await)
| +++ +

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.