Skip to content

Commit 273fe60

Browse files
authored
Rollup merge of #105983 - compiler-errors:issue-105981, r=tmiasko
Add a missing early return in drop tracking `handle_uninhabited_return` This return is needed so we don't call `Ty::is_inhabited_from` from a type with ty/ct vars in it. Fixes #105981
2 parents 548d49c + 51ba7b4 commit 273fe60

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ impl<'a, 'tcx> DropRangeVisitor<'a, 'tcx> {
233233
self.tcx()
234234
.sess
235235
.delay_span_bug(expr.span, format!("could not resolve infer vars in `{ty}`"));
236+
return;
236237
}
237238
let ty = self.tcx().erase_regions(ty);
238239
let m = self.tcx().parent_module(expr.hir_id).to_def_id();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// incremental
2+
// edition:2021
3+
// compile-flags: -Zdrop-tracking
4+
5+
fn main() {
6+
let _ = async {
7+
let s = std::array::from_fn(|_| ()).await;
8+
//~^ ERROR `[(); _]` is not a future
9+
//~| ERROR type inside `async` block must be known in this context
10+
//~| ERROR type inside `async` block must be known in this context
11+
//~| ERROR type inside `async` block must be known in this context
12+
//~| ERROR type inside `async` block must be known in this context
13+
//~| ERROR type inside `async` block must be known in this context
14+
};
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
error[E0277]: `[(); _]` is not a future
2+
--> $DIR/unresolved-ct-var-drop-tracking.rs:7:44
3+
|
4+
LL | let s = std::array::from_fn(|_| ()).await;
5+
| ---------------------------^^^^^^
6+
| | |
7+
| | `[(); _]` is not a future
8+
| | help: remove the `.await`
9+
| this call returns `[(); _]`
10+
|
11+
= help: the trait `Future` is not implemented for `[(); _]`
12+
= note: [(); _] must be a future or must implement `IntoFuture` to be awaited
13+
= note: required for `[(); _]` to implement `IntoFuture`
14+
15+
error[E0698]: type inside `async` block must be known in this context
16+
--> $DIR/unresolved-ct-var-drop-tracking.rs:7:17
17+
|
18+
LL | let s = std::array::from_fn(|_| ()).await;
19+
| ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn`
20+
|
21+
note: the type is part of the `async` block because of this `await`
22+
--> $DIR/unresolved-ct-var-drop-tracking.rs:7:44
23+
|
24+
LL | let s = std::array::from_fn(|_| ()).await;
25+
| ^^^^^^
26+
27+
error[E0698]: type inside `async` block must be known in this context
28+
--> $DIR/unresolved-ct-var-drop-tracking.rs:7:17
29+
|
30+
LL | let s = std::array::from_fn(|_| ()).await;
31+
| ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn`
32+
|
33+
note: the type is part of the `async` block because of this `await`
34+
--> $DIR/unresolved-ct-var-drop-tracking.rs:7:44
35+
|
36+
LL | let s = std::array::from_fn(|_| ()).await;
37+
| ^^^^^^
38+
39+
error[E0698]: type inside `async` block must be known in this context
40+
--> $DIR/unresolved-ct-var-drop-tracking.rs:7:17
41+
|
42+
LL | let s = std::array::from_fn(|_| ()).await;
43+
| ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn`
44+
|
45+
note: the type is part of the `async` block because of this `await`
46+
--> $DIR/unresolved-ct-var-drop-tracking.rs:7:44
47+
|
48+
LL | let s = std::array::from_fn(|_| ()).await;
49+
| ^^^^^^
50+
51+
error[E0698]: type inside `async` block must be known in this context
52+
--> $DIR/unresolved-ct-var-drop-tracking.rs:7:17
53+
|
54+
LL | let s = std::array::from_fn(|_| ()).await;
55+
| ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn`
56+
|
57+
note: the type is part of the `async` block because of this `await`
58+
--> $DIR/unresolved-ct-var-drop-tracking.rs:7:44
59+
|
60+
LL | let s = std::array::from_fn(|_| ()).await;
61+
| ^^^^^^
62+
63+
error[E0698]: type inside `async` block must be known in this context
64+
--> $DIR/unresolved-ct-var-drop-tracking.rs:7:17
65+
|
66+
LL | let s = std::array::from_fn(|_| ()).await;
67+
| ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn`
68+
|
69+
note: the type is part of the `async` block because of this `await`
70+
--> $DIR/unresolved-ct-var-drop-tracking.rs:7:44
71+
|
72+
LL | let s = std::array::from_fn(|_| ()).await;
73+
| ^^^^^^
74+
75+
error: aborting due to 6 previous errors
76+
77+
Some errors have detailed explanations: E0277, E0698.
78+
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)