Change:
Followup to I think we only have one use site of left: and it iterates over all fields anyway. So we can call instead and iterate over the resulting fields. There should be no more results for searching in the rust source after this, so some comments may need updating to mentioning instead of . These mentoring instructions are a bit vague, I do realize that, so if you encounter any hickup of any magnitude, don't hesitate to write here or contact me via discord/zulip. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --This issue has been assigned to via . <!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOT_END --
claim
EDIT: Okay, it is a word. Still, to me "destruct" sounds better. But maybe that's just because I am used to theorem provers?

Discussion:
use crate::mir::operand::OperandRef; use crate::traits::*; <del> use rustc_index::vec::Idx; </del> use rustc_middle::mir; use rustc_middle::mir::interpret::{ConstValue, ErrorHandled}; use rustc_middle::ty::layout::HasTyCtxt;

constant .map(|val| { let field_ty = ty.builtin_index().unwrap(); <del> let fields = match ty.kind { ty::Array(_, n) => n.eval_usize(bx.tcx(), ty::ParamEnv::reveal_all()), _ => bug!("invalid simd shuffle type: {}", ty), }; </del> let c = ty::Const::from_value(bx.tcx(), val, ty); <del> let values: Vec<_> = (0..fields) </del> <ins> let values: Vec<_> = bx .tcx() .destructure_const(ty::ParamEnv::reveal_all().and(&c)) .fields .into_iter() </ins> .map(|field| { <del> let field = bx.tcx().const_field( ty::ParamEnv::reveal_all().and((&c, mir::Field::new(field as usize))), ); if let Some(prim) = field.try_to_scalar() { </del> <ins> if let Some(prim) = field.val.try_to_scalar() { </ins> let layout = bx.layout_of(field_ty); let scalar = match layout.abi { Abi::Scalar(ref x) => x,

//! user of the `DepNode` API of having to know how to compute the expected //! fingerprint for a given set of node parameters. <del> use crate::mir; </del> use crate::mir::interpret::{GlobalId, LitToConstInput}; use crate::traits; use crate::traits::query::{

use crate::dep_graph::SerializedDepNodeIndex; <del> use crate::mir; </del> use crate::mir::interpret::{GlobalId, LitToConstInput}; use crate::traits; use crate::traits::query::{

} } <del> /// Extracts a field of a (variant of a) const. query const_field( key: ty::ParamEnvAnd<'tcx, (&'tcx ty::Const<'tcx>, mir::Field)> ) -> ConstValue<'tcx> { desc { "extract field of const" } } </del> /// Destructure a constant ADT or array into its variant index and its /// field values. query destructure_const(

} else { // It is guaranteed that any non-slice scalar pair is actually ByRef here. // When we come back from raw const eval, we are always by-ref. The only way our op here is <del> // by-val is if we are in const_field, i.e., if this is (a field of) something that we </del> <ins> // by-val is if we are in destructure_const, i.e., if this is (a field of) something that we </ins> // "tried to make immediate" before. We wouldn't do that for non-slice scalar pairs or // structs containing such. op.try_as_mplace(ecx)

use rustc_middle::mir; use rustc_middle::ty::{self, TyCtxt}; use rustc_span::{source_map::DUMMY_SP, symbol::Symbol}; <del> use rustc_target::abi::VariantIdx; </del> use crate::interpret::{intern_const_alloc_recursive, ConstValue, InternKind, InterpCx};

pub use fn_queries::*; pub use machine::*; <del> /// Extracts a field of a (variant of a) const. // this function uses `unwrap` copiously, because an already validated constant must have valid // fields and can thus never fail outside of compiler bugs pub(crate) fn const_field<'tcx>( tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, variant: Option<VariantIdx>, field: mir::Field, value: &'tcx ty::Const<'tcx>, ) -> ConstValue<'tcx> { trace!("const_field: {:?}, {:?}", field, value); let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, false); // get the operand again let op = ecx.eval_const_to_op(value, None).unwrap(); // downcast let down = match variant { None => op, Some(variant) => ecx.operand_downcast(op, variant).unwrap(), }; // then project let field = ecx.operand_field(down, field.index()).unwrap(); // and finally move back to the const world, always normalizing because // this is not called for statics. op_to_const(&ecx, field) } </del> pub(crate) fn const_caller_location( tcx: TyCtxt<'tcx>, (file, line, col): (Symbol, u32, u32),

providers.const_eval_validated = const_eval::const_eval_validated_provider; providers.const_eval_raw = const_eval::const_eval_raw_provider; providers.const_caller_location = const_eval::const_caller_location; <del> providers.const_field = |tcx, param_env_and_value| { let (param_env, (value, field)) = param_env_and_value.into_parts(); const_eval::const_field(tcx, param_env, None, field, value) }; </del> providers.destructure_const = |tcx, param_env_and_value| { let (param_env, value) = param_env_and_value.into_parts(); const_eval::destructure_const(tcx, param_env, value)