Skip to content

Commit

Permalink
Unconditional check FRU expression, even if there are errors present
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Dec 5, 2022
1 parent d442c01 commit 1c81540
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// the fields with the base_expr. This could cause us to hit errors later
// when certain fields are assumed to exist that in fact do not.
if error_happened {
if let Some(base_expr) = base_expr {
self.check_expr(base_expr);
}
return;
}

Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/async-await/drop-track-bad-field-in-fru.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// compile-flags: -Zdrop-tracking
// edition: 2021

fn main() {}

async fn foo() {
None { value: (), ..Default::default() }.await;
//~^ ERROR `Option<_>` is not a future
//~| ERROR variant `Option<_>::None` has no field named `value`
}
23 changes: 23 additions & 0 deletions src/test/ui/async-await/drop-track-bad-field-in-fru.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error[E0559]: variant `Option<_>::None` has no field named `value`
--> $DIR/drop-track-bad-field-in-fru.rs:7:12
|
LL | None { value: (), ..Default::default() }.await;
| ^^^^^ `Option<_>::None` does not have this field

error[E0277]: `Option<_>` is not a future
--> $DIR/drop-track-bad-field-in-fru.rs:7:45
|
LL | None { value: (), ..Default::default() }.await;
| ^^^^^^
| |
| `Option<_>` is not a future
| help: remove the `.await`
|
= help: the trait `Future` is not implemented for `Option<_>`
= note: Option<_> must be a future or must implement `IntoFuture` to be awaited
= note: required for `Option<_>` to implement `IntoFuture`

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0277, E0559.
For more information about an error, try `rustc --explain E0277`.

0 comments on commit 1c81540

Please sign in to comment.