Skip to content

Commit 2ce543c

Browse files
committed
Auto merge of #116279 - cuviper:beta-next, r=cuviper
[beta] backports - Only prevent field projections into opaque types, not types containing opaque types #116156 - Update LLVM submodule #116227 r? cuviper
2 parents 975e63f + a544df1 commit 2ce543c

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

Diff for: compiler/rustc_hir_typeck/src/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
464464
// Opaque types can't have field projections, but we can instead convert
465465
// the current place in-place (heh) to the hidden type, and then apply all
466466
// follow up projections on that.
467-
if node_ty != place_ty && place_ty.has_opaque_types() {
467+
if node_ty != place_ty && matches!(place_ty.kind(), ty::Alias(ty::Opaque, ..)) {
468468
projections.push(Projection { kind: ProjectionKind::OpaqueCast, ty: node_ty });
469469
}
470470
projections.push(Projection { kind, ty });
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// edition: 2021
2+
3+
use std::future::Future;
4+
5+
async fn bop() {
6+
fold(run(), |mut foo| async move {
7+
&mut foo.bar;
8+
})
9+
}
10+
11+
fn fold<Fut, F, U>(_: Foo<U>, f: F)
12+
where
13+
F: FnMut(Foo<U>) -> Fut,
14+
{
15+
loop {}
16+
}
17+
18+
struct Foo<F> {
19+
bar: Vec<F>,
20+
}
21+
22+
fn run() -> Foo<impl Future<Output = ()>> {
23+
//~^ ERROR type annotations needed
24+
loop {}
25+
}
26+
27+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/opaque-cast-field-access-in-future.rs:22:17
3+
|
4+
LL | fn run() -> Foo<impl Future<Output = ()>> {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0282`.

0 commit comments

Comments
 (0)