summaryrefslogtreecommitdiff
path: root/compiler/rustc_mir_dataflow
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2023-03-25 18:43:03 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2023-03-25 18:58:25 -0700
commit0439d131768081174fe4ed53a6f09d41a9e5629f (patch)
treeefc8f62e4d041d9dd08285d87787e0ae71884583 /compiler/rustc_mir_dataflow
parent96bd50dd47b645efa52d1312b9cc32e507d9cd76 (diff)
downloadrust-0439d131768081174fe4ed53a6f09d41a9e5629f.tar.gz
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.
Diffstat (limited to 'compiler/rustc_mir_dataflow')
-rw-r--r--compiler/rustc_mir_dataflow/src/elaborate_drops.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs
index 486275570bd..fe6728fc76e 100644
--- a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs
+++ b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs
@@ -7,7 +7,7 @@ use rustc_middle::traits::Reveal;
use rustc_middle::ty::subst::SubstsRef;
use rustc_middle::ty::util::IntTypeExt;
use rustc_middle::ty::{self, Ty, TyCtxt};
-use rustc_target::abi::VariantIdx;
+use rustc_target::abi::{VariantIdx, FIRST_VARIANT};
use std::{fmt, iter};
/// The value of an inserted drop flag.
@@ -468,7 +468,7 @@ where
let fields = self.move_paths_for_fields(
self.place,
self.path,
- &adt.variant(VariantIdx::new(0)),
+ &adt.variant(FIRST_VARIANT),
substs,
);
self.drop_ladder(fields, succ, unwind)
@@ -894,7 +894,7 @@ where
let unit_temp = Place::from(self.new_temp(tcx.mk_unit()));
let free_func = tcx.require_lang_item(LangItem::BoxFree, Some(self.source_info.span));
let args = adt
- .variant(VariantIdx::new(0))
+ .variant(FIRST_VARIANT)
.fields
.iter()
.enumerate()