diff options
| author | bors <bors@rust-lang.org> | 2022-04-16 09:19:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-16 09:19:26 +0000 |
| commit | c8422403f775126c40d558838d321c063554c822 (patch) | |
| tree | 931c38fb5db853c1a2bbb0d0fa585a533df76b9f /compiler/rustc_const_eval/src | |
| parent | 07bb916d44a66d2caba427c7ee132bbeb245977b (diff) | |
| parent | f559cf98b5db32942ec9be050fecf58538910648 (diff) | |
| download | rust-c8422403f775126c40d558838d321c063554c822.tar.gz rust-c8422403f775126c40d558838d321c063554c822.zip | |
Auto merge of #96108 - Dylan-DPC:rollup-t5f2fc9, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - #93969 (Only add codegen backend to dep info if -Zbinary-dep-depinfo is used) - #94605 (Add missing links in platform support docs) - #95372 (make unaligned_references lint deny-by-default) - #95859 (Improve diagnostics for unterminated nested block comment) - #95961 (implement SIMD gather/scatter via vector getelementptr) - #96004 (Consider lifetimes when comparing types for equality in MIR validator) - #96050 (Remove some now-dead code that was only relevant before deaggregation.) - #96070 ([test] Add test cases for untested functions for BTreeMap) - #96099 (MaybeUninit array cleanup) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/step.rs | 22 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/validate.rs | 7 |
2 files changed, 6 insertions, 23 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index eb1a184bf9b..e6dfdf54a32 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -196,27 +196,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { self.write_immediate(*val, &dest)?; } - Aggregate(ref kind, ref operands) => { - // active_field_index is for union initialization. - let (dest, active_field_index) = match **kind { - mir::AggregateKind::Adt(adt_did, variant_index, _, _, active_field_index) => { - self.write_discriminant(variant_index, &dest)?; - if self.tcx.adt_def(adt_did).is_enum() { - assert!(active_field_index.is_none()); - (self.place_downcast(&dest, variant_index)?, None) - } else { - if active_field_index.is_some() { - assert_eq!(operands.len(), 1); - } - (dest, active_field_index) - } - } - _ => (dest, None), - }; + Aggregate(box ref kind, ref operands) => { + assert!(matches!(kind, mir::AggregateKind::Array(..))); - for (i, operand) in operands.iter().enumerate() { + for (field_index, operand) in operands.iter().enumerate() { let op = self.eval_operand(operand, None)?; - let field_index = active_field_index.unwrap_or(i); let field_dest = self.place_field(&dest, field_index)?; self.copy_op(&op, &field_dest)?; } diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index 01af9585135..79d427ccc44 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -315,9 +315,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { | ty::FnPtr(..) ) } - // None of the possible types have lifetimes, so we can just compare - // directly - if a != b { + // The function pointer types can have lifetimes + if !self.mir_assign_valid_types(a, b) { self.fail( location, format!("Cannot compare unequal types {:?} and {:?}", a, b), @@ -464,7 +463,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { }; // since CopyNonOverlapping is parametrized by 1 type, // we only need to check that they are equal and not keep an extra parameter. - if op_src_ty != op_dst_ty { + if !self.mir_assign_valid_types(op_src_ty, op_dst_ty) { self.fail(location, format!("bad arg ({:?} != {:?})", op_src_ty, op_dst_ty)); } |
