diff options
| author | bors <bors@rust-lang.org> | 2024-09-16 17:41:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-16 17:41:17 +0000 |
| commit | fd2c811d25ad5773fbd2463e058bf4edf4d44eb2 (patch) | |
| tree | dde590488fc8ae7d73849637edaca57d7a6268d2 /compiler/rustc_mir_transform/src | |
| parent | 3a22be33db27e4f90e95dfaad301af400386efc1 (diff) | |
| parent | 1807fdadb4a76c4b02c5b83a3b5de3a04d02146e (diff) | |
| download | rust-fd2c811d25ad5773fbd2463e058bf4edf4d44eb2.tar.gz rust-fd2c811d25ad5773fbd2463e058bf4edf4d44eb2.zip | |
Auto merge of #130439 - matthiaskrgr:rollup-1lkzo74, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #123436 (linker: Allow MSVC to use import libraries following the Meson/MinGW convention) - #130410 (Don't ICE when generating `Fn` shim for async closure with borrowck error) - #130412 (Don't ICE when RPITIT captures more method args than trait definition) - #130436 (Ignore reduce-fadd-unordered on SGX platform) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/shim.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index f1bd803d835..47d04d8a00b 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -1070,19 +1070,26 @@ fn build_construct_coroutine_by_move_shim<'tcx>( let locals = local_decls_for_sig(&sig, span); let mut fields = vec![]; + + // Move all of the closure args. for idx in 1..sig.inputs().len() { fields.push(Operand::Move(Local::from_usize(idx + 1).into())); } + for (idx, ty) in args.as_coroutine_closure().upvar_tys().iter().enumerate() { if receiver_by_ref { // The only situation where it's possible is when we capture immuatable references, // since those don't need to be reborrowed with the closure's env lifetime. Since // references are always `Copy`, just emit a copy. - assert_matches!( - ty.kind(), - ty::Ref(_, _, hir::Mutability::Not), - "field should be captured by immutable ref if we have an `Fn` instance" - ); + if !matches!(ty.kind(), ty::Ref(_, _, hir::Mutability::Not)) { + // This copy is only sound if it's a `&T`. This may be + // reachable e.g. when eagerly computing the `Fn` instance + // of an async closure that doesn't borrowck. + tcx.dcx().delayed_bug(format!( + "field should be captured by immutable ref if we have \ + an `Fn` instance, but it was: {ty}" + )); + } fields.push(Operand::Copy(tcx.mk_place_field( self_local, FieldIdx::from_usize(idx), |
