1
Fork 0

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:
Matthias Krüger 2024-04-03 22:11:02 +02:00 committed by GitHub
commit 25b0e84170
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 80 additions and 90 deletions

View file

@ -215,7 +215,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
fn parse_local_decls(&mut self, mut stmts: impl Iterator<Item = StmtId>) -> PResult<()> {
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 {
let (var, ty, span) = self.parse_let_statement(stmt)?;

View file

@ -573,7 +573,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
result_value,
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 tcx = self.tcx;

View file

@ -190,7 +190,7 @@ rustc_index::newtype_index! {
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:
///