diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-03-26 08:39:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-26 08:39:28 +0200 |
| commit | 4aa4ce6ee26045f74f28d6a5067d01bf54221616 (patch) | |
| tree | 3808129509fbe0bc71c4be45b5fddef1c678c4de /compiler/rustc_const_eval/src/transform/validate.rs | |
| parent | 776a8f4ecae4292b064987f10b01b4e2e81fc2f4 (diff) | |
| parent | 0439d131768081174fe4ed53a6f09d41a9e5629f (diff) | |
| download | rust-4aa4ce6ee26045f74f28d6a5067d01bf54221616.tar.gz rust-4aa4ce6ee26045f74f28d6a5067d01bf54221616.zip | |
Rollup merge of #109621 - scottmcm:update-variantidx, r=compiler-errors
Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT` Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant. So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since [it doesn't have any today](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/abi/struct.VariantIdx.html).
Diffstat (limited to 'compiler/rustc_const_eval/src/transform/validate.rs')
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/validate.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index 66fc1c07e20..2be385d551e 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -17,7 +17,7 @@ use rustc_middle::ty::{self, InstanceDef, ParamEnv, Ty, TyCtxt, TypeVisitableExt use rustc_mir_dataflow::impls::MaybeStorageLive; use rustc_mir_dataflow::storage::always_storage_live_locals; use rustc_mir_dataflow::{Analysis, ResultsCursor}; -use rustc_target::abi::{Size, VariantIdx}; +use rustc_target::abi::{Size, FIRST_VARIANT}; #[derive(Copy, Clone, Debug, PartialEq, Eq)] enum EdgeKind { @@ -359,7 +359,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { check_equal(self, location, *f_ty); } ty::Adt(adt_def, substs) => { - let var = parent_ty.variant_index.unwrap_or(VariantIdx::from_u32(0)); + let var = parent_ty.variant_index.unwrap_or(FIRST_VARIANT); let Some(field) = adt_def.variant(var).fields.get(f.as_usize()) else { fail_out_of_bounds(self, location); return; |
