mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Rollup merge of #123419 - petrochenkov:zeroindex, r=compiler-errors
rustc_index: Add a `ZERO` constant to index types It is commonly used.
This commit is contained in:
commit
25b0e84170
@ -3,7 +3,7 @@ use rustc_hir as hir;
|
|||||||
use rustc_hir::def_id::{LocalDefId, LocalDefIdMap};
|
use rustc_hir::def_id::{LocalDefId, LocalDefIdMap};
|
||||||
use rustc_hir::intravisit::Visitor;
|
use rustc_hir::intravisit::Visitor;
|
||||||
use rustc_hir::*;
|
use rustc_hir::*;
|
||||||
use rustc_index::{Idx, IndexVec};
|
use rustc_index::IndexVec;
|
||||||
use rustc_middle::span_bug;
|
use rustc_middle::span_bug;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
@ -31,7 +31,7 @@ pub(super) fn index_hir<'hir>(
|
|||||||
bodies: &SortedMap<ItemLocalId, &'hir Body<'hir>>,
|
bodies: &SortedMap<ItemLocalId, &'hir Body<'hir>>,
|
||||||
num_nodes: usize,
|
num_nodes: usize,
|
||||||
) -> (IndexVec<ItemLocalId, ParentedNode<'hir>>, LocalDefIdMap<ItemLocalId>) {
|
) -> (IndexVec<ItemLocalId, ParentedNode<'hir>>, LocalDefIdMap<ItemLocalId>) {
|
||||||
let zero_id = ItemLocalId::new(0);
|
let zero_id = ItemLocalId::ZERO;
|
||||||
let err_node = ParentedNode { parent: zero_id, node: Node::Err(item.span()) };
|
let err_node = ParentedNode { parent: zero_id, node: Node::Err(item.span()) };
|
||||||
let mut nodes = IndexVec::from_elem_n(err_node, num_nodes);
|
let mut nodes = IndexVec::from_elem_n(err_node, num_nodes);
|
||||||
// This node's parent should never be accessed: the owner's parent is computed by the
|
// This node's parent should never be accessed: the owner's parent is computed by the
|
||||||
|
@ -11,7 +11,7 @@ use rustc_hir as hir;
|
|||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
|
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
|
||||||
use rustc_hir::PredicateOrigin;
|
use rustc_hir::PredicateOrigin;
|
||||||
use rustc_index::{Idx, IndexSlice, IndexVec};
|
use rustc_index::{IndexSlice, IndexVec};
|
||||||
use rustc_middle::span_bug;
|
use rustc_middle::span_bug;
|
||||||
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
|
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
|
||||||
use rustc_span::edit_distance::find_best_match_for_name;
|
use rustc_span::edit_distance::find_best_match_for_name;
|
||||||
@ -563,7 +563,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||||||
let kind =
|
let kind =
|
||||||
this.lower_use_tree(use_tree, &prefix, id, vis_span, &mut ident, attrs);
|
this.lower_use_tree(use_tree, &prefix, id, vis_span, &mut ident, attrs);
|
||||||
if let Some(attrs) = attrs {
|
if let Some(attrs) = attrs {
|
||||||
this.attrs.insert(hir::ItemLocalId::new(0), attrs);
|
this.attrs.insert(hir::ItemLocalId::ZERO, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
let item = hir::Item {
|
let item = hir::Item {
|
||||||
|
@ -157,7 +157,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
attrs: SortedMap::default(),
|
attrs: SortedMap::default(),
|
||||||
children: Vec::default(),
|
children: Vec::default(),
|
||||||
current_hir_id_owner: hir::CRATE_OWNER_ID,
|
current_hir_id_owner: hir::CRATE_OWNER_ID,
|
||||||
item_local_id_counter: hir::ItemLocalId::new(0),
|
item_local_id_counter: hir::ItemLocalId::ZERO,
|
||||||
node_id_to_local_id: Default::default(),
|
node_id_to_local_id: Default::default(),
|
||||||
trait_map: Default::default(),
|
trait_map: Default::default(),
|
||||||
|
|
||||||
@ -583,7 +583,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
// and the caller to refer to some of the subdefinitions' nodes' `LocalDefId`s.
|
// and the caller to refer to some of the subdefinitions' nodes' `LocalDefId`s.
|
||||||
|
|
||||||
// Always allocate the first `HirId` for the owner itself.
|
// Always allocate the first `HirId` for the owner itself.
|
||||||
let _old = self.node_id_to_local_id.insert(owner, hir::ItemLocalId::new(0));
|
let _old = self.node_id_to_local_id.insert(owner, hir::ItemLocalId::ZERO);
|
||||||
debug_assert_eq!(_old, None);
|
debug_assert_eq!(_old, None);
|
||||||
|
|
||||||
let item = f(self);
|
let item = f(self);
|
||||||
@ -677,7 +677,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
v.insert(local_id);
|
v.insert(local_id);
|
||||||
self.item_local_id_counter.increment_by(1);
|
self.item_local_id_counter.increment_by(1);
|
||||||
|
|
||||||
assert_ne!(local_id, hir::ItemLocalId::new(0));
|
assert_ne!(local_id, hir::ItemLocalId::ZERO);
|
||||||
if let Some(def_id) = self.opt_local_def_id(ast_node_id) {
|
if let Some(def_id) = self.opt_local_def_id(ast_node_id) {
|
||||||
self.children.push((def_id, hir::MaybeOwner::NonOwner(hir_id)));
|
self.children.push((def_id, hir::MaybeOwner::NonOwner(hir_id)));
|
||||||
}
|
}
|
||||||
@ -696,7 +696,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
fn next_id(&mut self) -> hir::HirId {
|
fn next_id(&mut self) -> hir::HirId {
|
||||||
let owner = self.current_hir_id_owner;
|
let owner = self.current_hir_id_owner;
|
||||||
let local_id = self.item_local_id_counter;
|
let local_id = self.item_local_id_counter;
|
||||||
assert_ne!(local_id, hir::ItemLocalId::new(0));
|
assert_ne!(local_id, hir::ItemLocalId::ZERO);
|
||||||
self.item_local_id_counter.increment_by(1);
|
self.item_local_id_counter.increment_by(1);
|
||||||
hir::HirId { owner, local_id }
|
hir::HirId { owner, local_id }
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ impl<'tcx> BorrowSet<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn indices(&self) -> impl Iterator<Item = BorrowIndex> {
|
pub(crate) fn indices(&self) -> impl Iterator<Item = BorrowIndex> {
|
||||||
BorrowIndex::from_usize(0)..BorrowIndex::from_usize(self.len())
|
BorrowIndex::ZERO..BorrowIndex::from_usize(self.len())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn iter_enumerated(&self) -> impl Iterator<Item = (BorrowIndex, &BorrowData<'tcx>)> {
|
pub(crate) fn iter_enumerated(&self) -> impl Iterator<Item = (BorrowIndex, &BorrowData<'tcx>)> {
|
||||||
|
@ -1393,7 +1393,7 @@ fn llvm_add_sub<'tcx>(
|
|||||||
|
|
||||||
// c + carry -> c + first intermediate carry or borrow respectively
|
// c + carry -> c + first intermediate carry or borrow respectively
|
||||||
let int0 = crate::num::codegen_checked_int_binop(fx, bin_op, a, b);
|
let int0 = crate::num::codegen_checked_int_binop(fx, bin_op, a, b);
|
||||||
let c = int0.value_field(fx, FieldIdx::new(0));
|
let c = int0.value_field(fx, FieldIdx::ZERO);
|
||||||
let cb0 = int0.value_field(fx, FieldIdx::new(1)).load_scalar(fx);
|
let cb0 = int0.value_field(fx, FieldIdx::new(1)).load_scalar(fx);
|
||||||
|
|
||||||
// c + carry -> c + second intermediate carry or borrow respectively
|
// c + carry -> c + second intermediate carry or borrow respectively
|
||||||
|
@ -61,7 +61,7 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>(
|
|||||||
if ty.is_dyn_star() {
|
if ty.is_dyn_star() {
|
||||||
let inner_layout = fx.layout_of(arg.layout().ty.builtin_deref(true).unwrap().ty);
|
let inner_layout = fx.layout_of(arg.layout().ty.builtin_deref(true).unwrap().ty);
|
||||||
let dyn_star = CPlace::for_ptr(Pointer::new(arg.load_scalar(fx)), inner_layout);
|
let dyn_star = CPlace::for_ptr(Pointer::new(arg.load_scalar(fx)), inner_layout);
|
||||||
let ptr = dyn_star.place_field(fx, FieldIdx::new(0)).to_ptr();
|
let ptr = dyn_star.place_field(fx, FieldIdx::ZERO).to_ptr();
|
||||||
let vtable =
|
let vtable =
|
||||||
dyn_star.place_field(fx, FieldIdx::new(1)).to_cvalue(fx).load_scalar(fx);
|
dyn_star.place_field(fx, FieldIdx::new(1)).to_cvalue(fx).load_scalar(fx);
|
||||||
break 'block (ptr, vtable);
|
break 'block (ptr, vtable);
|
||||||
|
@ -72,7 +72,7 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
|
|||||||
IndexVec::with_capacity(graph.num_nodes());
|
IndexVec::with_capacity(graph.num_nodes());
|
||||||
|
|
||||||
let mut stack = vec![PreOrderFrame {
|
let mut stack = vec![PreOrderFrame {
|
||||||
pre_order_idx: PreorderIndex::new(0),
|
pre_order_idx: PreorderIndex::ZERO,
|
||||||
iter: graph.successors(graph.start_node()),
|
iter: graph.successors(graph.start_node()),
|
||||||
}];
|
}];
|
||||||
let mut pre_order_to_real: IndexVec<PreorderIndex, G::Node> =
|
let mut pre_order_to_real: IndexVec<PreorderIndex, G::Node> =
|
||||||
@ -80,8 +80,8 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
|
|||||||
let mut real_to_pre_order: IndexVec<G::Node, Option<PreorderIndex>> =
|
let mut real_to_pre_order: IndexVec<G::Node, Option<PreorderIndex>> =
|
||||||
IndexVec::from_elem_n(None, graph.num_nodes());
|
IndexVec::from_elem_n(None, graph.num_nodes());
|
||||||
pre_order_to_real.push(graph.start_node());
|
pre_order_to_real.push(graph.start_node());
|
||||||
parent.push(PreorderIndex::new(0)); // the parent of the root node is the root for now.
|
parent.push(PreorderIndex::ZERO); // the parent of the root node is the root for now.
|
||||||
real_to_pre_order[graph.start_node()] = Some(PreorderIndex::new(0));
|
real_to_pre_order[graph.start_node()] = Some(PreorderIndex::ZERO);
|
||||||
let mut post_order_idx = 0;
|
let mut post_order_idx = 0;
|
||||||
|
|
||||||
// Traverse the graph, collecting a number of things:
|
// Traverse the graph, collecting a number of things:
|
||||||
@ -111,7 +111,7 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
|
|||||||
|
|
||||||
let reachable_vertices = pre_order_to_real.len();
|
let reachable_vertices = pre_order_to_real.len();
|
||||||
|
|
||||||
let mut idom = IndexVec::from_elem_n(PreorderIndex::new(0), reachable_vertices);
|
let mut idom = IndexVec::from_elem_n(PreorderIndex::ZERO, reachable_vertices);
|
||||||
let mut semi = IndexVec::from_fn_n(std::convert::identity, reachable_vertices);
|
let mut semi = IndexVec::from_fn_n(std::convert::identity, reachable_vertices);
|
||||||
let mut label = semi.clone();
|
let mut label = semi.clone();
|
||||||
let mut bucket = IndexVec::from_elem_n(vec![], reachable_vertices);
|
let mut bucket = IndexVec::from_elem_n(vec![], reachable_vertices);
|
||||||
|
@ -846,9 +846,8 @@ pub struct OwnerNodes<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> OwnerNodes<'tcx> {
|
impl<'tcx> OwnerNodes<'tcx> {
|
||||||
pub fn node(&self) -> OwnerNode<'tcx> {
|
pub fn node(&self) -> OwnerNode<'tcx> {
|
||||||
use rustc_index::Idx;
|
|
||||||
// Indexing must ensure it is an OwnerNode.
|
// Indexing must ensure it is an OwnerNode.
|
||||||
self.nodes[ItemLocalId::new(0)].node.as_owner().unwrap()
|
self.nodes[ItemLocalId::ZERO].node.as_owner().unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -856,7 +855,7 @@ impl fmt::Debug for OwnerNodes<'_> {
|
|||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("OwnerNodes")
|
f.debug_struct("OwnerNodes")
|
||||||
// Do not print all the pointers to all the nodes, as it would be unreadable.
|
// Do not print all the pointers to all the nodes, as it would be unreadable.
|
||||||
.field("node", &self.nodes[ItemLocalId::from_u32(0)])
|
.field("node", &self.nodes[ItemLocalId::ZERO])
|
||||||
.field(
|
.field(
|
||||||
"parents",
|
"parents",
|
||||||
&self
|
&self
|
||||||
|
@ -17,7 +17,7 @@ impl Debug for OwnerId {
|
|||||||
|
|
||||||
impl From<OwnerId> for HirId {
|
impl From<OwnerId> for HirId {
|
||||||
fn from(owner: OwnerId) -> HirId {
|
fn from(owner: OwnerId) -> HirId {
|
||||||
HirId { owner, local_id: ItemLocalId::from_u32(0) }
|
HirId { owner, local_id: ItemLocalId::ZERO }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ impl HirId {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn make_owner(owner: LocalDefId) -> Self {
|
pub fn make_owner(owner: LocalDefId) -> Self {
|
||||||
Self { owner: OwnerId { def_id: owner }, local_id: ItemLocalId::from_u32(0) }
|
Self { owner: OwnerId { def_id: owner }, local_id: ItemLocalId::ZERO }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn index(self) -> (usize, usize) {
|
pub fn index(self) -> (usize, usize) {
|
||||||
@ -172,6 +172,6 @@ unsafe impl StableOrd for ItemLocalId {
|
|||||||
|
|
||||||
/// The `HirId` corresponding to `CRATE_NODE_ID` and `CRATE_DEF_ID`.
|
/// The `HirId` corresponding to `CRATE_NODE_ID` and `CRATE_DEF_ID`.
|
||||||
pub const CRATE_HIR_ID: HirId =
|
pub const CRATE_HIR_ID: HirId =
|
||||||
HirId { owner: OwnerId { def_id: CRATE_DEF_ID }, local_id: ItemLocalId::from_u32(0) };
|
HirId { owner: OwnerId { def_id: CRATE_DEF_ID }, local_id: ItemLocalId::ZERO };
|
||||||
|
|
||||||
pub const CRATE_OWNER_ID: OwnerId = OwnerId { def_id: CRATE_DEF_ID };
|
pub const CRATE_OWNER_ID: OwnerId = OwnerId { def_id: CRATE_DEF_ID };
|
||||||
|
@ -899,7 +899,7 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
|||||||
struct_span_code_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
|
struct_span_code_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let e = fields[FieldIdx::from_u32(0)].ty(tcx, args);
|
let e = fields[FieldIdx::ZERO].ty(tcx, args);
|
||||||
if !fields.iter().all(|f| f.ty(tcx, args) == e) {
|
if !fields.iter().all(|f| f.ty(tcx, args) == e) {
|
||||||
struct_span_code_err!(tcx.dcx(), sp, E0076, "SIMD vector should be homogeneous")
|
struct_span_code_err!(tcx.dcx(), sp, E0076, "SIMD vector should be homogeneous")
|
||||||
.with_span_label(sp, "SIMD elements must have the same type")
|
.with_span_label(sp, "SIMD elements must have the same type")
|
||||||
|
@ -183,7 +183,7 @@ pub fn check_intrinsic_type(
|
|||||||
let region = ty::Region::new_bound(
|
let region = ty::Region::new_bound(
|
||||||
tcx,
|
tcx,
|
||||||
ty::INNERMOST,
|
ty::INNERMOST,
|
||||||
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon },
|
ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon },
|
||||||
);
|
);
|
||||||
let env_region = ty::Region::new_bound(
|
let env_region = ty::Region::new_bound(
|
||||||
tcx,
|
tcx,
|
||||||
@ -495,7 +495,7 @@ pub fn check_intrinsic_type(
|
|||||||
);
|
);
|
||||||
let discriminant_def_id = assoc_items[0];
|
let discriminant_def_id = assoc_items[0];
|
||||||
|
|
||||||
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon };
|
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon };
|
||||||
(
|
(
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
@ -555,7 +555,7 @@ pub fn check_intrinsic_type(
|
|||||||
}
|
}
|
||||||
|
|
||||||
sym::raw_eq => {
|
sym::raw_eq => {
|
||||||
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon };
|
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon };
|
||||||
let param_ty_lhs =
|
let param_ty_lhs =
|
||||||
Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
|
Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
|
||||||
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrAnon };
|
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrAnon };
|
||||||
|
@ -67,7 +67,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||||||
ty::RawPtr(ty, _) if self.is_thin_ptr_ty(ty) => Some(asm_ty_isize),
|
ty::RawPtr(ty, _) if self.is_thin_ptr_ty(ty) => Some(asm_ty_isize),
|
||||||
ty::Adt(adt, args) if adt.repr().simd() => {
|
ty::Adt(adt, args) if adt.repr().simd() => {
|
||||||
let fields = &adt.non_enum_variant().fields;
|
let fields = &adt.non_enum_variant().fields;
|
||||||
let elem_ty = fields[FieldIdx::from_u32(0)].ty(self.tcx, args);
|
let elem_ty = fields[FieldIdx::ZERO].ty(self.tcx, args);
|
||||||
|
|
||||||
let (size, ty) = match elem_ty.kind() {
|
let (size, ty) = match elem_ty.kind() {
|
||||||
ty::Array(ty, len) => {
|
ty::Array(ty, len) => {
|
||||||
@ -146,7 +146,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||||||
"expected first field of `MaybeUnit` to be `ManuallyDrop`"
|
"expected first field of `MaybeUnit` to be `ManuallyDrop`"
|
||||||
);
|
);
|
||||||
let fields = &ty.non_enum_variant().fields;
|
let fields = &ty.non_enum_variant().fields;
|
||||||
let ty = fields[FieldIdx::from_u32(0)].ty(self.tcx, args);
|
let ty = fields[FieldIdx::ZERO].ty(self.tcx, args);
|
||||||
self.get_asm_ty(ty)
|
self.get_asm_ty(ty)
|
||||||
}
|
}
|
||||||
_ => self.get_asm_ty(ty),
|
_ => self.get_asm_ty(ty),
|
||||||
|
@ -628,7 +628,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
let projection_ty = pred.skip_binder().projection_ty;
|
let projection_ty = pred.skip_binder().projection_ty;
|
||||||
|
|
||||||
let args_with_infer_self = tcx.mk_args_from_iter(
|
let args_with_infer_self = tcx.mk_args_from_iter(
|
||||||
std::iter::once(Ty::new_var(tcx, ty::TyVid::from_u32(0)).into())
|
std::iter::once(Ty::new_var(tcx, ty::TyVid::ZERO).into())
|
||||||
.chain(projection_ty.args.iter().skip(1)),
|
.chain(projection_ty.args.iter().skip(1)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>
|
|||||||
ty::Region::new_bound(
|
ty::Region::new_bound(
|
||||||
tcx,
|
tcx,
|
||||||
ty::INNERMOST,
|
ty::INNERMOST,
|
||||||
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon },
|
ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon },
|
||||||
),
|
),
|
||||||
panic_info_ty,
|
panic_info_ty,
|
||||||
);
|
);
|
||||||
|
@ -17,7 +17,7 @@ fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
|||||||
let data_idx;
|
let data_idx;
|
||||||
|
|
||||||
let one = VariantIdx::new(1);
|
let one = VariantIdx::new(1);
|
||||||
let zero = VariantIdx::new(0);
|
let zero = VariantIdx::ZERO;
|
||||||
|
|
||||||
if def.variant(zero).fields.is_empty() {
|
if def.variant(zero).fields.is_empty() {
|
||||||
data_idx = one;
|
data_idx = one;
|
||||||
|
@ -774,7 +774,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let projection_ty = pred.skip_binder().projection_ty;
|
let projection_ty = pred.skip_binder().projection_ty;
|
||||||
|
|
||||||
let args_with_infer_self = tcx.mk_args_from_iter(
|
let args_with_infer_self = tcx.mk_args_from_iter(
|
||||||
iter::once(Ty::new_var(tcx, ty::TyVid::from_u32(0)).into())
|
iter::once(Ty::new_var(tcx, ty::TyVid::ZERO).into())
|
||||||
.chain(projection_ty.args.iter().skip(1)),
|
.chain(projection_ty.args.iter().skip(1)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -343,10 +343,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let closure_env_region: ty::Region<'_> = ty::Region::new_bound(
|
let closure_env_region: ty::Region<'_> = ty::Region::new_bound(
|
||||||
self.tcx,
|
self.tcx,
|
||||||
ty::INNERMOST,
|
ty::INNERMOST,
|
||||||
ty::BoundRegion {
|
ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::BrEnv },
|
||||||
var: ty::BoundVar::from_usize(0),
|
|
||||||
kind: ty::BoundRegionKind::BrEnv,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
let tupled_upvars_ty_for_borrow = Ty::new_tup_from_iter(
|
let tupled_upvars_ty_for_borrow = Ty::new_tup_from_iter(
|
||||||
self.tcx,
|
self.tcx,
|
||||||
|
@ -174,6 +174,9 @@ impl Parse for Newtype {
|
|||||||
/// Maximum value the index can take.
|
/// Maximum value the index can take.
|
||||||
#vis const MAX: Self = Self::from_u32(#max);
|
#vis const MAX: Self = Self::from_u32(#max);
|
||||||
|
|
||||||
|
/// Zero value of the index.
|
||||||
|
#vis const ZERO: Self = Self::from_u32(0);
|
||||||
|
|
||||||
/// Creates a new index from a given `usize`.
|
/// Creates a new index from a given `usize`.
|
||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
|
@ -13,7 +13,6 @@ use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId, LOCAL_CRATE};
|
|||||||
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
|
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
|
||||||
use rustc_hir::intravisit::Visitor;
|
use rustc_hir::intravisit::Visitor;
|
||||||
use rustc_hir::*;
|
use rustc_hir::*;
|
||||||
use rustc_index::Idx;
|
|
||||||
use rustc_middle::hir::nested_filter;
|
use rustc_middle::hir::nested_filter;
|
||||||
use rustc_span::def_id::StableCrateId;
|
use rustc_span::def_id::StableCrateId;
|
||||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||||
@ -69,7 +68,7 @@ impl<'hir> Iterator for ParentOwnerIterator<'hir> {
|
|||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
if self.current_id.local_id.index() != 0 {
|
if self.current_id.local_id.index() != 0 {
|
||||||
self.current_id.local_id = ItemLocalId::new(0);
|
self.current_id.local_id = ItemLocalId::ZERO;
|
||||||
let node = self.map.tcx.hir_owner_node(self.current_id.owner);
|
let node = self.map.tcx.hir_owner_node(self.current_id.owner);
|
||||||
return Some((self.current_id.owner, node));
|
return Some((self.current_id.owner, node));
|
||||||
}
|
}
|
||||||
@ -133,7 +132,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
/// If calling repeatedly and iterating over parents, prefer [`Map::parent_iter`].
|
/// If calling repeatedly and iterating over parents, prefer [`Map::parent_iter`].
|
||||||
pub fn parent_hir_id(self, hir_id: HirId) -> HirId {
|
pub fn parent_hir_id(self, hir_id: HirId) -> HirId {
|
||||||
let HirId { owner, local_id } = hir_id;
|
let HirId { owner, local_id } = hir_id;
|
||||||
if local_id == ItemLocalId::from_u32(0) {
|
if local_id == ItemLocalId::ZERO {
|
||||||
self.hir_owner_parent(owner)
|
self.hir_owner_parent(owner)
|
||||||
} else {
|
} else {
|
||||||
let parent_local_id = self.hir_owner_nodes(owner).nodes[local_id].parent;
|
let parent_local_id = self.hir_owner_nodes(owner).nodes[local_id].parent;
|
||||||
|
@ -82,7 +82,7 @@ impl CanonicalVarValues<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_identity_modulo_regions(&self) -> bool {
|
pub fn is_identity_modulo_regions(&self) -> bool {
|
||||||
let mut var = ty::BoundVar::from_u32(0);
|
let mut var = ty::BoundVar::ZERO;
|
||||||
for arg in self.var_values {
|
for arg in self.var_values {
|
||||||
match arg.unpack() {
|
match arg.unpack() {
|
||||||
ty::GenericArgKind::Lifetime(r) => {
|
ty::GenericArgKind::Lifetime(r) => {
|
||||||
|
@ -34,7 +34,7 @@ rustc_index::newtype_index! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CounterId {
|
impl CounterId {
|
||||||
pub const START: Self = Self::from_u32(0);
|
pub const START: Self = Self::ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
rustc_index::newtype_index! {
|
rustc_index::newtype_index! {
|
||||||
@ -56,7 +56,7 @@ rustc_index::newtype_index! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ExpressionId {
|
impl ExpressionId {
|
||||||
pub const START: Self = Self::from_u32(0);
|
pub const START: Self = Self::ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enum that can hold a constant zero value, the ID of an physical coverage
|
/// Enum that can hold a constant zero value, the ID of an physical coverage
|
||||||
|
@ -1324,7 +1324,7 @@ impl VariantDef {
|
|||||||
pub fn single_field(&self) -> &FieldDef {
|
pub fn single_field(&self) -> &FieldDef {
|
||||||
assert!(self.fields.len() == 1);
|
assert!(self.fields.len() == 1);
|
||||||
|
|
||||||
&self.fields[FieldIdx::from_u32(0)]
|
&self.fields[FieldIdx::ZERO]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the last field in this variant, if present.
|
/// Returns the last field in this variant, if present.
|
||||||
|
@ -2589,7 +2589,7 @@ impl<'a, 'tcx> ty::TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> {
|
|||||||
ty::BrAnon | ty::BrEnv => r,
|
ty::BrAnon | ty::BrEnv => r,
|
||||||
_ => {
|
_ => {
|
||||||
// Index doesn't matter, since this is just for naming and these never get bound
|
// Index doesn't matter, since this is just for naming and these never get bound
|
||||||
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind };
|
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind };
|
||||||
*self
|
*self
|
||||||
.region_map
|
.region_map
|
||||||
.entry(br)
|
.entry(br)
|
||||||
|
@ -1958,7 +1958,7 @@ impl<'tcx> Ty<'tcx> {
|
|||||||
Adt(def, args) => {
|
Adt(def, args) => {
|
||||||
assert!(def.repr().simd(), "`simd_size_and_type` called on non-SIMD type");
|
assert!(def.repr().simd(), "`simd_size_and_type` called on non-SIMD type");
|
||||||
let variant = def.non_enum_variant();
|
let variant = def.non_enum_variant();
|
||||||
let f0_ty = variant.fields[FieldIdx::from_u32(0)].ty(tcx, args);
|
let f0_ty = variant.fields[FieldIdx::ZERO].ty(tcx, args);
|
||||||
|
|
||||||
match f0_ty.kind() {
|
match f0_ty.kind() {
|
||||||
// If the first field is an array, we assume it is the only field and its
|
// If the first field is an array, we assume it is the only field and its
|
||||||
|
@ -19,7 +19,7 @@ use rustc_hir::{
|
|||||||
hir_id::OwnerId,
|
hir_id::OwnerId,
|
||||||
BindingAnnotation, ByRef, HirId, ItemLocalId, ItemLocalMap, ItemLocalSet, Mutability,
|
BindingAnnotation, ByRef, HirId, ItemLocalId, ItemLocalMap, ItemLocalSet, Mutability,
|
||||||
};
|
};
|
||||||
use rustc_index::{Idx, IndexVec};
|
use rustc_index::IndexVec;
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
use rustc_middle::mir::FakeReadCause;
|
use rustc_middle::mir::FakeReadCause;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
@ -680,7 +680,7 @@ impl<'tcx> IsIdentity for CanonicalUserType<'tcx> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
iter::zip(user_args.args, BoundVar::new(0)..).all(|(kind, cvar)| {
|
iter::zip(user_args.args, BoundVar::ZERO..).all(|(kind, cvar)| {
|
||||||
match kind.unpack() {
|
match kind.unpack() {
|
||||||
GenericArgKind::Type(ty) => match ty.kind() {
|
GenericArgKind::Type(ty) => match ty.kind() {
|
||||||
ty::Bound(debruijn, b) => {
|
ty::Bound(debruijn, b) => {
|
||||||
|
@ -215,7 +215,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
|
|||||||
|
|
||||||
fn parse_local_decls(&mut self, mut stmts: impl Iterator<Item = StmtId>) -> PResult<()> {
|
fn parse_local_decls(&mut self, mut stmts: impl Iterator<Item = StmtId>) -> PResult<()> {
|
||||||
let (ret_var, ..) = self.parse_let_statement(stmts.next().unwrap())?;
|
let (ret_var, ..) = self.parse_let_statement(stmts.next().unwrap())?;
|
||||||
self.local_map.insert(ret_var, Local::from_u32(0));
|
self.local_map.insert(ret_var, Local::ZERO);
|
||||||
|
|
||||||
for stmt in stmts {
|
for stmt in stmts {
|
||||||
let (var, ty, span) = self.parse_let_statement(stmt)?;
|
let (var, ty, span) = self.parse_let_statement(stmt)?;
|
||||||
|
@ -573,7 +573,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
result_value,
|
result_value,
|
||||||
Rvalue::CheckedBinaryOp(op, Box::new((lhs.to_copy(), rhs.to_copy()))),
|
Rvalue::CheckedBinaryOp(op, Box::new((lhs.to_copy(), rhs.to_copy()))),
|
||||||
);
|
);
|
||||||
let val_fld = FieldIdx::new(0);
|
let val_fld = FieldIdx::ZERO;
|
||||||
let of_fld = FieldIdx::new(1);
|
let of_fld = FieldIdx::new(1);
|
||||||
|
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
@ -190,7 +190,7 @@ rustc_index::newtype_index! {
|
|||||||
struct DropIdx {}
|
struct DropIdx {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ROOT_NODE: DropIdx = DropIdx::from_u32(0);
|
const ROOT_NODE: DropIdx = DropIdx::ZERO;
|
||||||
|
|
||||||
/// A tree of drops that we have deferred lowering. It's used for:
|
/// A tree of drops that we have deferred lowering. It's used for:
|
||||||
///
|
///
|
||||||
|
@ -420,14 +420,14 @@ where
|
|||||||
) -> BasicBlock {
|
) -> BasicBlock {
|
||||||
// drop glue is sent straight to codegen
|
// drop glue is sent straight to codegen
|
||||||
// box cannot be directly dereferenced
|
// box cannot be directly dereferenced
|
||||||
let unique_ty = adt.non_enum_variant().fields[FieldIdx::new(0)].ty(self.tcx(), args);
|
let unique_ty = adt.non_enum_variant().fields[FieldIdx::ZERO].ty(self.tcx(), args);
|
||||||
let unique_variant = unique_ty.ty_adt_def().unwrap().non_enum_variant();
|
let unique_variant = unique_ty.ty_adt_def().unwrap().non_enum_variant();
|
||||||
let nonnull_ty = unique_variant.fields[FieldIdx::from_u32(0)].ty(self.tcx(), args);
|
let nonnull_ty = unique_variant.fields[FieldIdx::ZERO].ty(self.tcx(), args);
|
||||||
let ptr_ty = Ty::new_imm_ptr(self.tcx(), args[0].expect_ty());
|
let ptr_ty = Ty::new_imm_ptr(self.tcx(), args[0].expect_ty());
|
||||||
|
|
||||||
let unique_place = self.tcx().mk_place_field(self.place, FieldIdx::new(0), unique_ty);
|
let unique_place = self.tcx().mk_place_field(self.place, FieldIdx::ZERO, unique_ty);
|
||||||
let nonnull_place = self.tcx().mk_place_field(unique_place, FieldIdx::new(0), nonnull_ty);
|
let nonnull_place = self.tcx().mk_place_field(unique_place, FieldIdx::ZERO, nonnull_ty);
|
||||||
let ptr_place = self.tcx().mk_place_field(nonnull_place, FieldIdx::new(0), ptr_ty);
|
let ptr_place = self.tcx().mk_place_field(nonnull_place, FieldIdx::ZERO, ptr_ty);
|
||||||
let interior = self.tcx().mk_place_deref(ptr_place);
|
let interior = self.tcx().mk_place_deref(ptr_place);
|
||||||
|
|
||||||
let interior_path = self.elaborator.deref_subpath(self.path);
|
let interior_path = self.elaborator.deref_subpath(self.path);
|
||||||
|
@ -168,7 +168,7 @@ impl<'tcx> MutVisitor<'tcx> for PinArgVisitor<'tcx> {
|
|||||||
Place {
|
Place {
|
||||||
local: SELF_ARG,
|
local: SELF_ARG,
|
||||||
projection: self.tcx().mk_place_elems(&[ProjectionElem::Field(
|
projection: self.tcx().mk_place_elems(&[ProjectionElem::Field(
|
||||||
FieldIdx::new(0),
|
FieldIdx::ZERO,
|
||||||
self.ref_coroutine_ty,
|
self.ref_coroutine_ty,
|
||||||
)]),
|
)]),
|
||||||
},
|
},
|
||||||
@ -267,7 +267,7 @@ impl<'tcx> TransformVisitor<'tcx> {
|
|||||||
Rvalue::Aggregate(
|
Rvalue::Aggregate(
|
||||||
Box::new(AggregateKind::Adt(
|
Box::new(AggregateKind::Adt(
|
||||||
option_def_id,
|
option_def_id,
|
||||||
VariantIdx::from_usize(0),
|
VariantIdx::ZERO,
|
||||||
self.tcx.mk_args(&[self.old_yield_ty.into()]),
|
self.tcx.mk_args(&[self.old_yield_ty.into()]),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -329,7 +329,7 @@ impl<'tcx> TransformVisitor<'tcx> {
|
|||||||
Rvalue::Aggregate(
|
Rvalue::Aggregate(
|
||||||
Box::new(AggregateKind::Adt(
|
Box::new(AggregateKind::Adt(
|
||||||
poll_def_id,
|
poll_def_id,
|
||||||
VariantIdx::from_usize(0),
|
VariantIdx::ZERO,
|
||||||
args,
|
args,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -358,7 +358,7 @@ impl<'tcx> TransformVisitor<'tcx> {
|
|||||||
Rvalue::Aggregate(
|
Rvalue::Aggregate(
|
||||||
Box::new(AggregateKind::Adt(
|
Box::new(AggregateKind::Adt(
|
||||||
option_def_id,
|
option_def_id,
|
||||||
VariantIdx::from_usize(0),
|
VariantIdx::ZERO,
|
||||||
args,
|
args,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -420,7 +420,7 @@ impl<'tcx> TransformVisitor<'tcx> {
|
|||||||
Rvalue::Aggregate(
|
Rvalue::Aggregate(
|
||||||
Box::new(AggregateKind::Adt(
|
Box::new(AggregateKind::Adt(
|
||||||
coroutine_state_def_id,
|
coroutine_state_def_id,
|
||||||
VariantIdx::from_usize(0),
|
VariantIdx::ZERO,
|
||||||
args,
|
args,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
//! Box is not actually a pointer so it is incorrect to dereference it directly.
|
//! Box is not actually a pointer so it is incorrect to dereference it directly.
|
||||||
|
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_index::Idx;
|
|
||||||
use rustc_middle::mir::patch::MirPatch;
|
use rustc_middle::mir::patch::MirPatch;
|
||||||
use rustc_middle::mir::visit::MutVisitor;
|
use rustc_middle::mir::visit::MutVisitor;
|
||||||
use rustc_middle::mir::*;
|
use rustc_middle::mir::*;
|
||||||
@ -32,9 +31,9 @@ pub fn build_projection<'tcx>(
|
|||||||
ptr_ty: Ty<'tcx>,
|
ptr_ty: Ty<'tcx>,
|
||||||
) -> [PlaceElem<'tcx>; 3] {
|
) -> [PlaceElem<'tcx>; 3] {
|
||||||
[
|
[
|
||||||
PlaceElem::Field(FieldIdx::new(0), unique_ty),
|
PlaceElem::Field(FieldIdx::ZERO, unique_ty),
|
||||||
PlaceElem::Field(FieldIdx::new(0), nonnull_ty),
|
PlaceElem::Field(FieldIdx::ZERO, nonnull_ty),
|
||||||
PlaceElem::Field(FieldIdx::new(0), ptr_ty),
|
PlaceElem::Field(FieldIdx::ZERO, ptr_ty),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,15 +90,14 @@ pub struct ElaborateBoxDerefs;
|
|||||||
impl<'tcx> MirPass<'tcx> for ElaborateBoxDerefs {
|
impl<'tcx> MirPass<'tcx> for ElaborateBoxDerefs {
|
||||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||||
if let Some(def_id) = tcx.lang_items().owned_box() {
|
if let Some(def_id) = tcx.lang_items().owned_box() {
|
||||||
let unique_did =
|
let unique_did = tcx.adt_def(def_id).non_enum_variant().fields[FieldIdx::ZERO].did;
|
||||||
tcx.adt_def(def_id).non_enum_variant().fields[FieldIdx::from_u32(0)].did;
|
|
||||||
|
|
||||||
let Some(nonnull_def) = tcx.type_of(unique_did).instantiate_identity().ty_adt_def()
|
let Some(nonnull_def) = tcx.type_of(unique_did).instantiate_identity().ty_adt_def()
|
||||||
else {
|
else {
|
||||||
span_bug!(tcx.def_span(unique_did), "expected Box to contain Unique")
|
span_bug!(tcx.def_span(unique_did), "expected Box to contain Unique")
|
||||||
};
|
};
|
||||||
|
|
||||||
let nonnull_did = nonnull_def.non_enum_variant().fields[FieldIdx::from_u32(0)].did;
|
let nonnull_did = nonnull_def.non_enum_variant().fields[FieldIdx::ZERO].did;
|
||||||
|
|
||||||
let patch = MirPatch::new(body);
|
let patch = MirPatch::new(body);
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn insert_tuple(&mut self, values: Vec<VnIndex>) -> VnIndex {
|
fn insert_tuple(&mut self, values: Vec<VnIndex>) -> VnIndex {
|
||||||
self.insert(Value::Aggregate(AggregateTy::Tuple, VariantIdx::from_u32(0), values))
|
self.insert(Value::Aggregate(AggregateTy::Tuple, VariantIdx::ZERO, values))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "trace", skip(self), ret)]
|
#[instrument(level = "trace", skip(self), ret)]
|
||||||
|
@ -13,7 +13,7 @@ use rustc_const_eval::interpret::{
|
|||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_hir::HirId;
|
use rustc_hir::HirId;
|
||||||
use rustc_index::{bit_set::BitSet, Idx, IndexVec};
|
use rustc_index::{bit_set::BitSet, IndexVec};
|
||||||
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
|
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
|
||||||
use rustc_middle::mir::*;
|
use rustc_middle::mir::*;
|
||||||
use rustc_middle::ty::layout::{LayoutError, LayoutOf, LayoutOfHelpers, TyAndLayout};
|
use rustc_middle::ty::layout::{LayoutError, LayoutOf, LayoutOfHelpers, TyAndLayout};
|
||||||
@ -124,10 +124,8 @@ impl<'tcx> Value<'tcx> {
|
|||||||
fields.ensure_contains_elem(*idx, || Value::Uninit)
|
fields.ensure_contains_elem(*idx, || Value::Uninit)
|
||||||
}
|
}
|
||||||
(PlaceElem::Field(..), val @ Value::Uninit) => {
|
(PlaceElem::Field(..), val @ Value::Uninit) => {
|
||||||
*val = Value::Aggregate {
|
*val =
|
||||||
variant: VariantIdx::new(0),
|
Value::Aggregate { variant: VariantIdx::ZERO, fields: Default::default() };
|
||||||
fields: Default::default(),
|
|
||||||
};
|
|
||||||
val.project_mut(&[*proj])?
|
val.project_mut(&[*proj])?
|
||||||
}
|
}
|
||||||
_ => return None,
|
_ => return None,
|
||||||
@ -572,7 +570,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
|||||||
self.use_ecx(|this| this.ecx.overflowing_binary_op(bin_op, &left, &right))?;
|
self.use_ecx(|this| this.ecx.overflowing_binary_op(bin_op, &left, &right))?;
|
||||||
let overflowed = ImmTy::from_bool(overflowed, self.tcx);
|
let overflowed = ImmTy::from_bool(overflowed, self.tcx);
|
||||||
Value::Aggregate {
|
Value::Aggregate {
|
||||||
variant: VariantIdx::new(0),
|
variant: VariantIdx::ZERO,
|
||||||
fields: [Value::from(val), overflowed.into()].into_iter().collect(),
|
fields: [Value::from(val), overflowed.into()].into_iter().collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -607,7 +605,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
|||||||
| AggregateKind::Tuple
|
| AggregateKind::Tuple
|
||||||
| AggregateKind::Closure(_, _)
|
| AggregateKind::Closure(_, _)
|
||||||
| AggregateKind::Coroutine(_, _)
|
| AggregateKind::Coroutine(_, _)
|
||||||
| AggregateKind::CoroutineClosure(_, _) => VariantIdx::new(0),
|
| AggregateKind::CoroutineClosure(_, _) => VariantIdx::ZERO,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,7 +415,7 @@ fn make_local_map<V>(
|
|||||||
used_locals: &UsedLocals,
|
used_locals: &UsedLocals,
|
||||||
) -> IndexVec<Local, Option<Local>> {
|
) -> IndexVec<Local, Option<Local>> {
|
||||||
let mut map: IndexVec<Local, Option<Local>> = IndexVec::from_elem(None, local_decls);
|
let mut map: IndexVec<Local, Option<Local>> = IndexVec::from_elem(None, local_decls);
|
||||||
let mut used = Local::new(0);
|
let mut used = Local::ZERO;
|
||||||
|
|
||||||
for alive_index in local_decls.indices() {
|
for alive_index in local_decls.indices() {
|
||||||
// `is_used` treats the `RETURN_PLACE` and arguments as used.
|
// `is_used` treats the `RETURN_PLACE` and arguments as used.
|
||||||
|
@ -40,7 +40,7 @@ rustc_index::newtype_index! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DepNodeIndex {
|
impl DepNodeIndex {
|
||||||
const SINGLETON_DEPENDENCYLESS_ANON_NODE: DepNodeIndex = DepNodeIndex::from_u32(0);
|
const SINGLETON_DEPENDENCYLESS_ANON_NODE: DepNodeIndex = DepNodeIndex::ZERO;
|
||||||
pub const FOREVER_RED_NODE: DepNodeIndex = DepNodeIndex::from_u32(1);
|
pub const FOREVER_RED_NODE: DepNodeIndex = DepNodeIndex::from_u32(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||||||
|
|
||||||
let mut seen_spans = FxHashSet::default();
|
let mut seen_spans = FxHashSet::default();
|
||||||
let mut errors = vec![];
|
let mut errors = vec![];
|
||||||
let mut prev_root_id: NodeId = NodeId::from_u32(0);
|
let mut prev_root_id: NodeId = NodeId::ZERO;
|
||||||
let determined_imports = mem::take(&mut self.determined_imports);
|
let determined_imports = mem::take(&mut self.determined_imports);
|
||||||
let indeterminate_imports = mem::take(&mut self.indeterminate_imports);
|
let indeterminate_imports = mem::take(&mut self.indeterminate_imports);
|
||||||
|
|
||||||
@ -556,8 +556,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if prev_root_id.as_u32() != 0
|
if prev_root_id != NodeId::ZERO
|
||||||
&& prev_root_id.as_u32() != import.root_id.as_u32()
|
&& prev_root_id != import.root_id
|
||||||
&& !errors.is_empty()
|
&& !errors.is_empty()
|
||||||
{
|
{
|
||||||
// In the case of a new import line, throw a diagnostic message
|
// In the case of a new import line, throw a diagnostic message
|
||||||
|
@ -22,7 +22,7 @@ rustc_index::newtype_index! {
|
|||||||
|
|
||||||
/// Item definitions in the currently-compiled crate would have the `CrateNum`
|
/// Item definitions in the currently-compiled crate would have the `CrateNum`
|
||||||
/// `LOCAL_CRATE` in their `DefId`.
|
/// `LOCAL_CRATE` in their `DefId`.
|
||||||
pub const LOCAL_CRATE: CrateNum = CrateNum::from_u32(0);
|
pub const LOCAL_CRATE: CrateNum = CrateNum::ZERO;
|
||||||
|
|
||||||
impl CrateNum {
|
impl CrateNum {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -165,7 +165,7 @@ pub enum Transparency {
|
|||||||
|
|
||||||
impl LocalExpnId {
|
impl LocalExpnId {
|
||||||
/// The ID of the theoretical expansion that generates freshly parsed, unexpanded AST.
|
/// The ID of the theoretical expansion that generates freshly parsed, unexpanded AST.
|
||||||
pub const ROOT: LocalExpnId = LocalExpnId::from_u32(0);
|
pub const ROOT: LocalExpnId = LocalExpnId::ZERO;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_raw(idx: ExpnIndex) -> LocalExpnId {
|
fn from_raw(idx: ExpnIndex) -> LocalExpnId {
|
||||||
@ -242,7 +242,7 @@ impl ExpnId {
|
|||||||
/// The ID of the theoretical expansion that generates freshly parsed, unexpanded AST.
|
/// The ID of the theoretical expansion that generates freshly parsed, unexpanded AST.
|
||||||
/// Invariant: we do not create any ExpnId with local_id == 0 and krate != 0.
|
/// Invariant: we do not create any ExpnId with local_id == 0 and krate != 0.
|
||||||
pub const fn root() -> ExpnId {
|
pub const fn root() -> ExpnId {
|
||||||
ExpnId { krate: LOCAL_CRATE, local_id: ExpnIndex::from_u32(0) }
|
ExpnId { krate: LOCAL_CRATE, local_id: ExpnIndex::ZERO }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -243,7 +243,7 @@ fn t10() {
|
|||||||
src_hash,
|
src_hash,
|
||||||
stable_id,
|
stable_id,
|
||||||
source_len.to_u32(),
|
source_len.to_u32(),
|
||||||
CrateNum::new(0),
|
CrateNum::ZERO,
|
||||||
FreezeLock::new(lines.read().clone()),
|
FreezeLock::new(lines.read().clone()),
|
||||||
multibyte_chars,
|
multibyte_chars,
|
||||||
non_narrow_chars,
|
non_narrow_chars,
|
||||||
|
@ -554,11 +554,7 @@ fn plug_infer_with_placeholders<'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
value.visit_with(&mut PlugInferWithPlaceholder {
|
value.visit_with(&mut PlugInferWithPlaceholder { infcx, universe, var: ty::BoundVar::ZERO });
|
||||||
infcx,
|
|
||||||
universe,
|
|
||||||
var: ty::BoundVar::from_u32(0),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_prove_negated_where_clause<'tcx>(
|
fn try_prove_negated_where_clause<'tcx>(
|
||||||
|
@ -377,7 +377,7 @@ fn layout_of_uncached<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Type of the first ADT field:
|
// Type of the first ADT field:
|
||||||
let f0_ty = fields[FieldIdx::from_u32(0)].ty(tcx, args);
|
let f0_ty = fields[FieldIdx::ZERO].ty(tcx, args);
|
||||||
|
|
||||||
// Heterogeneous SIMD vectors are not supported:
|
// Heterogeneous SIMD vectors are not supported:
|
||||||
// (should be caught by typeck)
|
// (should be caught by typeck)
|
||||||
|
@ -314,7 +314,7 @@ rustc_index::newtype_index! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl UniverseIndex {
|
impl UniverseIndex {
|
||||||
pub const ROOT: UniverseIndex = UniverseIndex::from_u32(0);
|
pub const ROOT: UniverseIndex = UniverseIndex::ZERO;
|
||||||
|
|
||||||
/// Returns the "next" universe index in order -- this new index
|
/// Returns the "next" universe index in order -- this new index
|
||||||
/// is considered to extend all previous universes. This
|
/// is considered to extend all previous universes. This
|
||||||
|
Loading…
Reference in New Issue
Block a user