From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_index/src/bit_set.rs | 4 ++-- compiler/rustc_index/src/interval.rs | 5 +---- compiler/rustc_index/src/vec.rs | 8 ++++++-- compiler/rustc_index/src/vec/tests.rs | 5 ++++- 4 files changed, 13 insertions(+), 9 deletions(-) (limited to 'compiler/rustc_index') diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index 777112442..15179392c 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -209,7 +209,7 @@ impl BitSet { self.words[start_word_index] |= !(start_mask - 1); // And all trailing bits (i.e. from 0..=end) in the end word, // including the end. - self.words[end_word_index] |= end_mask | end_mask - 1; + self.words[end_word_index] |= end_mask | (end_mask - 1); } else { self.words[start_word_index] |= end_mask | (end_mask - start_mask); } @@ -1091,7 +1091,7 @@ impl ToString for BitSet { assert!(mask <= 0xFF); let byte = word & mask; - result.push_str(&format!("{}{:02x}", sep, byte)); + result.push_str(&format!("{sep}{byte:02x}")); if remain <= 8 { break; diff --git a/compiler/rustc_index/src/interval.rs b/compiler/rustc_index/src/interval.rs index 3592fb330..d809740c6 100644 --- a/compiler/rustc_index/src/interval.rs +++ b/compiler/rustc_index/src/interval.rs @@ -135,10 +135,7 @@ impl IntervalSet { }; debug_assert!( self.check_invariants(), - "wrong intervals after insert {:?}..={:?} to {:?}", - start, - end, - self + "wrong intervals after insert {start:?}..={end:?} to {self:?}" ); result } diff --git a/compiler/rustc_index/src/vec.rs b/compiler/rustc_index/src/vec.rs index 39aa27a23..68cdc6d77 100644 --- a/compiler/rustc_index/src/vec.rs +++ b/compiler/rustc_index/src/vec.rs @@ -4,7 +4,6 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use std::fmt; use std::fmt::Debug; use std::hash::Hash; -use std::iter::FromIterator; use std::marker::PhantomData; use std::ops::{Index, IndexMut, RangeBounds}; use std::slice; @@ -208,7 +207,12 @@ impl IndexVec { &'a mut self, range: R, ) -> impl Iterator + 'a { - self.raw.drain(range).enumerate().map(|(n, t)| (I::new(n), t)) + let begin = match range.start_bound() { + std::ops::Bound::Included(i) => *i, + std::ops::Bound::Excluded(i) => i.checked_add(1).unwrap(), + std::ops::Bound::Unbounded => 0, + }; + self.raw.drain(range).enumerate().map(move |(n, t)| (I::new(begin + n), t)) } #[inline] diff --git a/compiler/rustc_index/src/vec/tests.rs b/compiler/rustc_index/src/vec/tests.rs index 915d2e8bc..cb0f0db22 100644 --- a/compiler/rustc_index/src/vec/tests.rs +++ b/compiler/rustc_index/src/vec/tests.rs @@ -3,7 +3,10 @@ // Allows the macro invocation below to work use crate as rustc_index; -rustc_macros::newtype_index!(struct MyIdx { MAX = 0xFFFF_FFFA }); +rustc_macros::newtype_index! { + #[max = 0xFFFF_FFFA] + struct MyIdx {} +} #[test] fn index_size_is_optimized() { -- cgit v1.2.3