Skip to content

Commit b40ea03

Browse files
committed
rustc_index: Add a ZERO constant to index types
It is commonly used.
1 parent ceab612 commit b40ea03

File tree

42 files changed

+80
-90
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+80
-90
lines changed

compiler/rustc_ast_lowering/src/index.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_hir as hir;
33
use rustc_hir::def_id::{LocalDefId, LocalDefIdMap};
44
use rustc_hir::intravisit::Visitor;
55
use rustc_hir::*;
6-
use rustc_index::{Idx, IndexVec};
6+
use rustc_index::IndexVec;
77
use rustc_middle::span_bug;
88
use rustc_middle::ty::TyCtxt;
99
use rustc_span::{Span, DUMMY_SP};
@@ -31,7 +31,7 @@ pub(super) fn index_hir<'hir>(
3131
bodies: &SortedMap<ItemLocalId, &'hir Body<'hir>>,
3232
num_nodes: usize,
3333
) -> (IndexVec<ItemLocalId, ParentedNode<'hir>>, LocalDefIdMap<ItemLocalId>) {
34-
let zero_id = ItemLocalId::new(0);
34+
let zero_id = ItemLocalId::ZERO;
3535
let err_node = ParentedNode { parent: zero_id, node: Node::Err(item.span()) };
3636
let mut nodes = IndexVec::from_elem_n(err_node, num_nodes);
3737
// This node's parent should never be accessed: the owner's parent is computed by the

compiler/rustc_ast_lowering/src/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir as hir;
1111
use rustc_hir::def::{DefKind, Res};
1212
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
1313
use rustc_hir::PredicateOrigin;
14-
use rustc_index::{Idx, IndexSlice, IndexVec};
14+
use rustc_index::{IndexSlice, IndexVec};
1515
use rustc_middle::span_bug;
1616
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
1717
use rustc_span::edit_distance::find_best_match_for_name;
@@ -563,7 +563,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
563563
let kind =
564564
this.lower_use_tree(use_tree, &prefix, id, vis_span, &mut ident, attrs);
565565
if let Some(attrs) = attrs {
566-
this.attrs.insert(hir::ItemLocalId::new(0), attrs);
566+
this.attrs.insert(hir::ItemLocalId::ZERO, attrs);
567567
}
568568

569569
let item = hir::Item {

compiler/rustc_ast_lowering/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
157157
attrs: SortedMap::default(),
158158
children: Vec::default(),
159159
current_hir_id_owner: hir::CRATE_OWNER_ID,
160-
item_local_id_counter: hir::ItemLocalId::new(0),
160+
item_local_id_counter: hir::ItemLocalId::ZERO,
161161
node_id_to_local_id: Default::default(),
162162
trait_map: Default::default(),
163163

@@ -583,7 +583,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
583583
// and the caller to refer to some of the subdefinitions' nodes' `LocalDefId`s.
584584

585585
// Always allocate the first `HirId` for the owner itself.
586-
let _old = self.node_id_to_local_id.insert(owner, hir::ItemLocalId::new(0));
586+
let _old = self.node_id_to_local_id.insert(owner, hir::ItemLocalId::ZERO);
587587
debug_assert_eq!(_old, None);
588588

589589
let item = f(self);
@@ -677,7 +677,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
677677
v.insert(local_id);
678678
self.item_local_id_counter.increment_by(1);
679679

680-
assert_ne!(local_id, hir::ItemLocalId::new(0));
680+
assert_ne!(local_id, hir::ItemLocalId::ZERO);
681681
if let Some(def_id) = self.opt_local_def_id(ast_node_id) {
682682
self.children.push((def_id, hir::MaybeOwner::NonOwner(hir_id)));
683683
}
@@ -696,7 +696,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
696696
fn next_id(&mut self) -> hir::HirId {
697697
let owner = self.current_hir_id_owner;
698698
let local_id = self.item_local_id_counter;
699-
assert_ne!(local_id, hir::ItemLocalId::new(0));
699+
assert_ne!(local_id, hir::ItemLocalId::ZERO);
700700
self.item_local_id_counter.increment_by(1);
701701
hir::HirId { owner, local_id }
702702
}

compiler/rustc_borrowck/src/borrow_set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl<'tcx> BorrowSet<'tcx> {
159159
}
160160

161161
pub(crate) fn indices(&self) -> impl Iterator<Item = BorrowIndex> {
162-
BorrowIndex::from_usize(0)..BorrowIndex::from_usize(self.len())
162+
BorrowIndex::ZERO..BorrowIndex::from_usize(self.len())
163163
}
164164

165165
pub(crate) fn iter_enumerated(&self) -> impl Iterator<Item = (BorrowIndex, &BorrowData<'tcx>)> {

compiler/rustc_codegen_cranelift/src/intrinsics/llvm_x86.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ fn llvm_add_sub<'tcx>(
13931393

13941394
// c + carry -> c + first intermediate carry or borrow respectively
13951395
let int0 = crate::num::codegen_checked_int_binop(fx, bin_op, a, b);
1396-
let c = int0.value_field(fx, FieldIdx::new(0));
1396+
let c = int0.value_field(fx, FieldIdx::ZERO);
13971397
let cb0 = int0.value_field(fx, FieldIdx::new(1)).load_scalar(fx);
13981398

13991399
// c + carry -> c + second intermediate carry or borrow respectively

compiler/rustc_codegen_cranelift/src/vtable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>(
6161
if ty.is_dyn_star() {
6262
let inner_layout = fx.layout_of(arg.layout().ty.builtin_deref(true).unwrap().ty);
6363
let dyn_star = CPlace::for_ptr(Pointer::new(arg.load_scalar(fx)), inner_layout);
64-
let ptr = dyn_star.place_field(fx, FieldIdx::new(0)).to_ptr();
64+
let ptr = dyn_star.place_field(fx, FieldIdx::ZERO).to_ptr();
6565
let vtable =
6666
dyn_star.place_field(fx, FieldIdx::new(1)).to_cvalue(fx).load_scalar(fx);
6767
break 'block (ptr, vtable);

compiler/rustc_data_structures/src/graph/dominators/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,16 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
7272
IndexVec::with_capacity(graph.num_nodes());
7373

7474
let mut stack = vec![PreOrderFrame {
75-
pre_order_idx: PreorderIndex::new(0),
75+
pre_order_idx: PreorderIndex::ZERO,
7676
iter: graph.successors(graph.start_node()),
7777
}];
7878
let mut pre_order_to_real: IndexVec<PreorderIndex, G::Node> =
7979
IndexVec::with_capacity(graph.num_nodes());
8080
let mut real_to_pre_order: IndexVec<G::Node, Option<PreorderIndex>> =
8181
IndexVec::from_elem_n(None, graph.num_nodes());
8282
pre_order_to_real.push(graph.start_node());
83-
parent.push(PreorderIndex::new(0)); // the parent of the root node is the root for now.
84-
real_to_pre_order[graph.start_node()] = Some(PreorderIndex::new(0));
83+
parent.push(PreorderIndex::ZERO); // the parent of the root node is the root for now.
84+
real_to_pre_order[graph.start_node()] = Some(PreorderIndex::ZERO);
8585
let mut post_order_idx = 0;
8686

8787
// Traverse the graph, collecting a number of things:
@@ -111,7 +111,7 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
111111

112112
let reachable_vertices = pre_order_to_real.len();
113113

114-
let mut idom = IndexVec::from_elem_n(PreorderIndex::new(0), reachable_vertices);
114+
let mut idom = IndexVec::from_elem_n(PreorderIndex::ZERO, reachable_vertices);
115115
let mut semi = IndexVec::from_fn_n(std::convert::identity, reachable_vertices);
116116
let mut label = semi.clone();
117117
let mut bucket = IndexVec::from_elem_n(vec![], reachable_vertices);

compiler/rustc_hir/src/hir.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -846,17 +846,16 @@ pub struct OwnerNodes<'tcx> {
846846

847847
impl<'tcx> OwnerNodes<'tcx> {
848848
pub fn node(&self) -> OwnerNode<'tcx> {
849-
use rustc_index::Idx;
850849
// Indexing must ensure it is an OwnerNode.
851-
self.nodes[ItemLocalId::new(0)].node.as_owner().unwrap()
850+
self.nodes[ItemLocalId::ZERO].node.as_owner().unwrap()
852851
}
853852
}
854853

855854
impl fmt::Debug for OwnerNodes<'_> {
856855
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
857856
f.debug_struct("OwnerNodes")
858857
// Do not print all the pointers to all the nodes, as it would be unreadable.
859-
.field("node", &self.nodes[ItemLocalId::from_u32(0)])
858+
.field("node", &self.nodes[ItemLocalId::ZERO])
860859
.field(
861860
"parents",
862861
&self

compiler/rustc_hir/src/hir_id.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl Debug for OwnerId {
1717

1818
impl From<OwnerId> for HirId {
1919
fn from(owner: OwnerId) -> HirId {
20-
HirId { owner, local_id: ItemLocalId::from_u32(0) }
20+
HirId { owner, local_id: ItemLocalId::ZERO }
2121
}
2222
}
2323

@@ -110,7 +110,7 @@ impl HirId {
110110

111111
#[inline]
112112
pub fn make_owner(owner: LocalDefId) -> Self {
113-
Self { owner: OwnerId { def_id: owner }, local_id: ItemLocalId::from_u32(0) }
113+
Self { owner: OwnerId { def_id: owner }, local_id: ItemLocalId::ZERO }
114114
}
115115

116116
pub fn index(self) -> (usize, usize) {
@@ -172,6 +172,6 @@ unsafe impl StableOrd for ItemLocalId {
172172

173173
/// The `HirId` corresponding to `CRATE_NODE_ID` and `CRATE_DEF_ID`.
174174
pub const CRATE_HIR_ID: HirId =
175-
HirId { owner: OwnerId { def_id: CRATE_DEF_ID }, local_id: ItemLocalId::from_u32(0) };
175+
HirId { owner: OwnerId { def_id: CRATE_DEF_ID }, local_id: ItemLocalId::ZERO };
176176

177177
pub const CRATE_OWNER_ID: OwnerId = OwnerId { def_id: CRATE_DEF_ID };

compiler/rustc_hir_analysis/src/check/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
899899
struct_span_code_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
900900
return;
901901
}
902-
let e = fields[FieldIdx::from_u32(0)].ty(tcx, args);
902+
let e = fields[FieldIdx::ZERO].ty(tcx, args);
903903
if !fields.iter().all(|f| f.ty(tcx, args) == e) {
904904
struct_span_code_err!(tcx.dcx(), sp, E0076, "SIMD vector should be homogeneous")
905905
.with_span_label(sp, "SIMD elements must have the same type")

compiler/rustc_hir_analysis/src/check/intrinsic.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub fn check_intrinsic_type(
183183
let region = ty::Region::new_bound(
184184
tcx,
185185
ty::INNERMOST,
186-
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon },
186+
ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon },
187187
);
188188
let env_region = ty::Region::new_bound(
189189
tcx,
@@ -495,7 +495,7 @@ pub fn check_intrinsic_type(
495495
);
496496
let discriminant_def_id = assoc_items[0];
497497

498-
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon };
498+
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon };
499499
(
500500
1,
501501
0,
@@ -555,7 +555,7 @@ pub fn check_intrinsic_type(
555555
}
556556

557557
sym::raw_eq => {
558-
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon };
558+
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon };
559559
let param_ty_lhs =
560560
Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
561561
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrAnon };

compiler/rustc_hir_analysis/src/check/intrinsicck.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
6767
ty::RawPtr(ty, _) if self.is_thin_ptr_ty(ty) => Some(asm_ty_isize),
6868
ty::Adt(adt, args) if adt.repr().simd() => {
6969
let fields = &adt.non_enum_variant().fields;
70-
let elem_ty = fields[FieldIdx::from_u32(0)].ty(self.tcx, args);
70+
let elem_ty = fields[FieldIdx::ZERO].ty(self.tcx, args);
7171

7272
let (size, ty) = match elem_ty.kind() {
7373
ty::Array(ty, len) => {
@@ -146,7 +146,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
146146
"expected first field of `MaybeUnit` to be `ManuallyDrop`"
147147
);
148148
let fields = &ty.non_enum_variant().fields;
149-
let ty = fields[FieldIdx::from_u32(0)].ty(self.tcx, args);
149+
let ty = fields[FieldIdx::ZERO].ty(self.tcx, args);
150150
self.get_asm_ty(ty)
151151
}
152152
_ => self.get_asm_ty(ty),

compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
628628
let projection_ty = pred.skip_binder().projection_ty;
629629

630630
let args_with_infer_self = tcx.mk_args_from_iter(
631-
std::iter::once(Ty::new_var(tcx, ty::TyVid::from_u32(0)).into())
631+
std::iter::once(Ty::new_var(tcx, ty::TyVid::ZERO).into())
632632
.chain(projection_ty.args.iter().skip(1)),
633633
);
634634

compiler/rustc_hir_typeck/src/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>
182182
ty::Region::new_bound(
183183
tcx,
184184
ty::INNERMOST,
185-
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon },
185+
ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon },
186186
),
187187
panic_info_ty,
188188
);

compiler/rustc_hir_typeck/src/intrinsicck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
1717
let data_idx;
1818

1919
let one = VariantIdx::new(1);
20-
let zero = VariantIdx::new(0);
20+
let zero = VariantIdx::ZERO;
2121

2222
if def.variant(zero).fields.is_empty() {
2323
data_idx = one;

compiler/rustc_hir_typeck/src/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
774774
let projection_ty = pred.skip_binder().projection_ty;
775775

776776
let args_with_infer_self = tcx.mk_args_from_iter(
777-
iter::once(Ty::new_var(tcx, ty::TyVid::from_u32(0)).into())
777+
iter::once(Ty::new_var(tcx, ty::TyVid::ZERO).into())
778778
.chain(projection_ty.args.iter().skip(1)),
779779
);
780780

compiler/rustc_hir_typeck/src/upvar.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
343343
let closure_env_region: ty::Region<'_> = ty::Region::new_bound(
344344
self.tcx,
345345
ty::INNERMOST,
346-
ty::BoundRegion {
347-
var: ty::BoundVar::from_usize(0),
348-
kind: ty::BoundRegionKind::BrEnv,
349-
},
346+
ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::BrEnv },
350347
);
351348
let tupled_upvars_ty_for_borrow = Ty::new_tup_from_iter(
352349
self.tcx,

compiler/rustc_index_macros/src/newtype.rs

+3
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ impl Parse for Newtype {
174174
/// Maximum value the index can take.
175175
#vis const MAX: Self = Self::from_u32(#max);
176176

177+
/// Zero value of the index.
178+
#vis const ZERO: Self = Self::from_u32(0);
179+
177180
/// Creates a new index from a given `usize`.
178181
///
179182
/// # Panics

compiler/rustc_middle/src/hir/map/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId, LOCAL_CRATE};
1313
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
1414
use rustc_hir::intravisit::Visitor;
1515
use rustc_hir::*;
16-
use rustc_index::Idx;
1716
use rustc_middle::hir::nested_filter;
1817
use rustc_span::def_id::StableCrateId;
1918
use rustc_span::symbol::{kw, sym, Ident, Symbol};
@@ -69,7 +68,7 @@ impl<'hir> Iterator for ParentOwnerIterator<'hir> {
6968

7069
fn next(&mut self) -> Option<Self::Item> {
7170
if self.current_id.local_id.index() != 0 {
72-
self.current_id.local_id = ItemLocalId::new(0);
71+
self.current_id.local_id = ItemLocalId::ZERO;
7372
let node = self.map.tcx.hir_owner_node(self.current_id.owner);
7473
return Some((self.current_id.owner, node));
7574
}
@@ -133,7 +132,7 @@ impl<'tcx> TyCtxt<'tcx> {
133132
/// If calling repeatedly and iterating over parents, prefer [`Map::parent_iter`].
134133
pub fn parent_hir_id(self, hir_id: HirId) -> HirId {
135134
let HirId { owner, local_id } = hir_id;
136-
if local_id == ItemLocalId::from_u32(0) {
135+
if local_id == ItemLocalId::ZERO {
137136
self.hir_owner_parent(owner)
138137
} else {
139138
let parent_local_id = self.hir_owner_nodes(owner).nodes[local_id].parent;

compiler/rustc_middle/src/infer/canonical.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl CanonicalVarValues<'_> {
8282
}
8383

8484
pub fn is_identity_modulo_regions(&self) -> bool {
85-
let mut var = ty::BoundVar::from_u32(0);
85+
let mut var = ty::BoundVar::ZERO;
8686
for arg in self.var_values {
8787
match arg.unpack() {
8888
ty::GenericArgKind::Lifetime(r) => {

compiler/rustc_middle/src/mir/coverage.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ rustc_index::newtype_index! {
3434
}
3535

3636
impl CounterId {
37-
pub const START: Self = Self::from_u32(0);
37+
pub const START: Self = Self::ZERO;
3838
}
3939

4040
rustc_index::newtype_index! {
@@ -56,7 +56,7 @@ rustc_index::newtype_index! {
5656
}
5757

5858
impl ExpressionId {
59-
pub const START: Self = Self::from_u32(0);
59+
pub const START: Self = Self::ZERO;
6060
}
6161

6262
/// Enum that can hold a constant zero value, the ID of an physical coverage

compiler/rustc_middle/src/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ impl VariantDef {
13241324
pub fn single_field(&self) -> &FieldDef {
13251325
assert!(self.fields.len() == 1);
13261326

1327-
&self.fields[FieldIdx::from_u32(0)]
1327+
&self.fields[FieldIdx::ZERO]
13281328
}
13291329

13301330
/// Returns the last field in this variant, if present.

compiler/rustc_middle/src/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2589,7 +2589,7 @@ impl<'a, 'tcx> ty::TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> {
25892589
ty::BrAnon | ty::BrEnv => r,
25902590
_ => {
25912591
// Index doesn't matter, since this is just for naming and these never get bound
2592-
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind };
2592+
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind };
25932593
*self
25942594
.region_map
25952595
.entry(br)

compiler/rustc_middle/src/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ impl<'tcx> Ty<'tcx> {
19541954
Adt(def, args) => {
19551955
assert!(def.repr().simd(), "`simd_size_and_type` called on non-SIMD type");
19561956
let variant = def.non_enum_variant();
1957-
let f0_ty = variant.fields[FieldIdx::from_u32(0)].ty(tcx, args);
1957+
let f0_ty = variant.fields[FieldIdx::ZERO].ty(tcx, args);
19581958

19591959
match f0_ty.kind() {
19601960
// If the first field is an array, we assume it is the only field and its

compiler/rustc_middle/src/ty/typeck_results.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_hir::{
1919
hir_id::OwnerId,
2020
BindingAnnotation, ByRef, HirId, ItemLocalId, ItemLocalMap, ItemLocalSet, Mutability,
2121
};
22-
use rustc_index::{Idx, IndexVec};
22+
use rustc_index::IndexVec;
2323
use rustc_macros::HashStable;
2424
use rustc_middle::mir::FakeReadCause;
2525
use rustc_session::Session;
@@ -680,7 +680,7 @@ impl<'tcx> IsIdentity for CanonicalUserType<'tcx> {
680680
return false;
681681
}
682682

683-
iter::zip(user_args.args, BoundVar::new(0)..).all(|(kind, cvar)| {
683+
iter::zip(user_args.args, BoundVar::ZERO..).all(|(kind, cvar)| {
684684
match kind.unpack() {
685685
GenericArgKind::Type(ty) => match ty.kind() {
686686
ty::Bound(debruijn, b) => {

compiler/rustc_mir_build/src/build/custom/parse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
215215

216216
fn parse_local_decls(&mut self, mut stmts: impl Iterator<Item = StmtId>) -> PResult<()> {
217217
let (ret_var, ..) = self.parse_let_statement(stmts.next().unwrap())?;
218-
self.local_map.insert(ret_var, Local::from_u32(0));
218+
self.local_map.insert(ret_var, Local::ZERO);
219219

220220
for stmt in stmts {
221221
let (var, ty, span) = self.parse_let_statement(stmt)?;

0 commit comments

Comments
 (0)