-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression from 1.61 to 1.62 #98932
Comments
Mre: pub struct EntriesBuffer(Box<[[u8; HashesEntry::LEN]; 5]>);
impl EntriesBuffer {
pub fn new() -> Self {
Self(Box::new([[0; HashesEntry::LEN]; 5]))
}
pub fn current_entry_buffer(&mut self) -> &mut [u8; HashesEntry::LEN] {
&mut self.0[0]
}
pub fn iter_child_buffers(&mut self) -> impl Iterator<Item = &mut [u8; HashesEntry::LEN]> {
self.0.iter_mut().skip(1)
}
pub fn split_children<'a, 'b>(
&'a mut self,
references: &'b [u32],
) -> (HashesEntryWriter<'a>, EntriesBufferChildren<'b>)
where
'a: 'b,
{
let [first, tail @ ..] = &mut *self.0;
(
HashesEntryWriter(first),
EntriesBufferChildren(references, tail),
)
}
}
pub struct EntriesBufferChildren<'a>(&'a [u32], &'a [[u8; HashesEntry::LEN]]);
impl EntriesBufferChildren<'_> {
pub fn iter(&self) -> impl Iterator<Item = (&u32, HashesEntry)> {
self.0
.iter()
.zip(self.1)
.map(|(index, item)| (index, HashesEntry(item)))
}
}
pub struct HashesEntryWriter<'a>(&'a mut [u8]);
impl HashesEntryWriter<'_> {
pub fn as_reader(&self) -> HashesEntry {
HashesEntry(self.0)
}
pub fn clear(&mut self) {
for byte in &mut *self.0 {
*byte = 0;
}
}
pub fn set_tree_bits_count(&mut self, count: u64) {
self.0[4..12].copy_from_slice(&count.to_le_bytes());
}
pub fn set_tree_cell_count(&mut self, count: u64) {
self.0[12..20].copy_from_slice(&count.to_le_bytes());
}
pub fn get_tree_counters(&mut self) -> &[u8] {
&self.0[4..20]
}
pub fn set_hash(&mut self, i: u8, hash: &[u8]) {
self.get_hash_slice(i).copy_from_slice(hash);
}
pub fn get_hash_slice(&mut self, i: u8) -> &mut [u8] {
let offset = HashesEntry::HASHES_OFFSET + 32 * i as usize;
&mut self.0[offset..offset + 32]
}
pub fn set_depth(&mut self, i: u8, depth: u16) {
self.get_depth_slice(i)
.copy_from_slice(&depth.to_le_bytes());
}
pub fn get_depth_slice(&mut self, i: u8) -> &mut [u8] {
let offset = HashesEntry::DEPTHS_OFFSET + 2 * i as usize;
&mut self.0[offset..offset + 2]
}
}
pub struct HashesEntry<'a>(&'a [u8]);
impl<'a> HashesEntry<'a> {
// 4 bytes - info (1 byte level mask, 1 byte cell type, 2 bytes padding)
// 8 bytes - tree bits count
// 4 bytes - cell count
// 32 * 4 bytes - hashes
// 2 * 4 bytes - depths
pub const LEN: usize = 4 + 8 + 8 + 32 * 4 + 2 * 4;
pub const HASHES_OFFSET: usize = 4 + 8 + 8;
pub const DEPTHS_OFFSET: usize = 4 + 8 + 8 + 32 * 4;
pub fn tree_bits_count(&self) -> u64 {
u64::from_le_bytes(self.0[4..12].try_into().unwrap())
}
pub fn tree_cell_count(&self) -> u64 {
u64::from_le_bytes(self.0[12..20].try_into().unwrap())
}
pub fn hash(&self, n: u8) -> &[u8] {
let offset = Self::HASHES_OFFSET + 32 * self.level_mask().calc_hash_index(n as usize);
&self.0[offset..offset + 32]
}
pub fn depth(&self, n: u8) -> u16 {
let offset = Self::DEPTHS_OFFSET + 2 * self.level_mask().calc_hash_index(n as usize);
u16::from_le_bytes([self.0[offset], self.0[offset + 1]])
}
pub fn pruned_branch_hash<'b>(&self, n: u8, data: &'b [u8]) -> &'b [u8]
where
'a: 'b,
{
let level_mask = self.level_mask();
let index = level_mask.calc_hash_index(n as usize);
let level = level_mask.level() as usize;
if index == level {
let offset = Self::HASHES_OFFSET;
&self.0[offset..offset + 32]
} else {
let offset = 1 + 1 + index * 32;
&data[offset..offset + 32]
}
}
pub fn pruned_branch_depth(&self, n: u8, data: &[u8]) -> u16 {
let level_mask = self.level_mask();
let index = level_mask.calc_hash_index(n as usize);
let level = level_mask.level() as usize;
if index == level {
let offset = Self::DEPTHS_OFFSET;
u16::from_le_bytes([self.0[offset], self.0[offset + 1]])
} else {
let offset = 1 + 1 + level * 32 + index * 2;
u16::from_be_bytes([data[offset], data[offset + 1]])
}
}
} searched nightlies: from nightly-2022-04-15 to nightly-2022-05-02 bisected with cargo-bisect-rustc v0.6.3Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc --test-dir=. --start=2022-04-15 --end=2022-05-02 |
WG-prioritization assigning priority (Zulip discussion). Tagging PR #95776 @rustbot label -I-prioritize +P-medium |
Before the regression, the sample code reported a compile error: error summary~/tmp/issue-98932$ cargo +nightly-2022-04-15-x86_64-unknown-linux-gnu check
Checking issue-98932 v0.1.0 (~/tmp/issue-98932)
error[E0599]: no method named `level_mask` found for reference `&HashesEntry<'a>` in the current scope
--> src/main.rs:108:54
|
108 | let offset = Self::HASHES_OFFSET + 32 * self.level_mask().calc_hash_index(n as usize);
| ^^^^^^^^^^ method not found in `&HashesEntry<'a>`
error[E0599]: no method named `level_mask` found for reference `&HashesEntry<'a>` in the current scope
--> src/main.rs:113:53
|
113 | let offset = Self::DEPTHS_OFFSET + 2 * self.level_mask().calc_hash_index(n as usize);
| ^^^^^^^^^^ method not found in `&HashesEntry<'a>`
error[E0599]: no method named `level_mask` found for reference `&HashesEntry<'a>` in the current scope
--> src/main.rs:121:31
|
121 | let level_mask = self.level_mask();
| ^^^^^^^^^^ method not found in `&HashesEntry<'a>`
error[E0599]: no method named `level_mask` found for reference `&HashesEntry<'a>` in the current scope
--> src/main.rs:135:31
|
135 | let level_mask = self.level_mask();
| ^^^^^^^^^^ method not found in `&HashesEntry<'a>`
For more information about this error, try `rustc --explain E0599`.
error: could not compile `issue-98932` due to 4 previous errors |
Slightly smaller example which successfully compiles on 1.61 and failed with ICE on 1.62: pub struct EntriesBuffer(Box<[[u8; HashesEntry::LEN]; 5]>);
impl EntriesBuffer {
pub fn iter_child_buffers(&mut self) -> impl Iterator<Item = &mut [u8; HashesEntry::LEN]> {
self.0.iter_mut()
}
// Compiles successfully if `'static` lifetime is specified:
//
// pub fn iter_child_buffers(&mut self) -> impl Iterator<Item = &mut [u8; HashesEntry::<'static>::LEN]> {
// self.0.iter_mut()
// }
}
pub struct HashesEntry<'a>(&'a [u8]);
impl HashesEntry<'_> {
pub const LEN: usize = 1;
} |
…r=petrochenkov Clean up HIR-based lifetime resolution Based on rust-lang#97313. Fixes rust-lang#98932. r? `@petrochenkov`
…r=petrochenkov Clean up HIR-based lifetime resolution Based on rust-lang#97313. Fixes rust-lang#98932. r? `@petrochenkov`
Code
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: