Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check FRU expr even in the presence of errors #105268

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
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`.