Skip to content

Commit 1c81540

Browse files
Unconditional check FRU expression, even if there are errors present
1 parent d442c01 commit 1c81540

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

compiler/rustc_hir_typeck/src/expr.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16461646
// the fields with the base_expr. This could cause us to hit errors later
16471647
// when certain fields are assumed to exist that in fact do not.
16481648
if error_happened {
1649+
if let Some(base_expr) = base_expr {
1650+
self.check_expr(base_expr);
1651+
}
16491652
return;
16501653
}
16511654

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// compile-flags: -Zdrop-tracking
2+
// edition: 2021
3+
4+
fn main() {}
5+
6+
async fn foo() {
7+
None { value: (), ..Default::default() }.await;
8+
//~^ ERROR `Option<_>` is not a future
9+
//~| ERROR variant `Option<_>::None` has no field named `value`
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0559]: variant `Option<_>::None` has no field named `value`
2+
--> $DIR/drop-track-bad-field-in-fru.rs:7:12
3+
|
4+
LL | None { value: (), ..Default::default() }.await;
5+
| ^^^^^ `Option<_>::None` does not have this field
6+
7+
error[E0277]: `Option<_>` is not a future
8+
--> $DIR/drop-track-bad-field-in-fru.rs:7:45
9+
|
10+
LL | None { value: (), ..Default::default() }.await;
11+
| ^^^^^^
12+
| |
13+
| `Option<_>` is not a future
14+
| help: remove the `.await`
15+
|
16+
= help: the trait `Future` is not implemented for `Option<_>`
17+
= note: Option<_> must be a future or must implement `IntoFuture` to be awaited
18+
= note: required for `Option<_>` to implement `IntoFuture`
19+
20+
error: aborting due to 2 previous errors
21+
22+
Some errors have detailed explanations: E0277, E0559.
23+
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)