forked from AbleOS/holey-bytes
whew
This commit is contained in:
parent
499fe34f1d
commit
6de8496aa5
|
@ -7,7 +7,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
let mut generated = String::new();
|
||||
|
||||
writeln!(generated, "#![allow(dead_code)]")?;
|
||||
writeln!(
|
||||
generated,
|
||||
"#![allow(dead_code)] #![allow(clippy::upper_case_acronyms)]"
|
||||
)?;
|
||||
gen_max_size(&mut generated)?;
|
||||
gen_encodes(&mut generated)?;
|
||||
gen_structs(&mut generated)?;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(dead_code)]
|
||||
#![allow(clippy::all)]
|
||||
use std::{
|
||||
cell::{Cell, RefCell},
|
||||
ops::Range,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,24 +2,24 @@ pub type Ident = u32;
|
|||
|
||||
const LEN_BITS: u32 = 6;
|
||||
|
||||
pub fn len(ident: Ident) -> u32 {
|
||||
pub fn len(ident: u32) -> u32 {
|
||||
ident & ((1 << LEN_BITS) - 1)
|
||||
}
|
||||
|
||||
pub fn is_null(ident: Ident) -> bool {
|
||||
pub fn is_null(ident: u32) -> bool {
|
||||
(ident >> LEN_BITS) == 0
|
||||
}
|
||||
|
||||
pub fn pos(ident: Ident) -> u32 {
|
||||
pub fn pos(ident: u32) -> u32 {
|
||||
(ident >> LEN_BITS).saturating_sub(1)
|
||||
}
|
||||
|
||||
pub fn new(pos: u32, len: u32) -> Ident {
|
||||
pub fn new(pos: u32, len: u32) -> u32 {
|
||||
debug_assert!(len < (1 << LEN_BITS));
|
||||
((pos + 1) << LEN_BITS) | len
|
||||
}
|
||||
|
||||
pub fn range(ident: Ident) -> std::ops::Range<usize> {
|
||||
pub fn range(ident: u32) -> std::ops::Range<usize> {
|
||||
let (len, pos) = (len(ident) as usize, pos(ident) as usize);
|
||||
pos..pos + len
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#![feature(vec_pop_if)]
|
||||
#![feature(inline_const_pat)]
|
||||
#![feature(pattern)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(slice_partition_dedup)]
|
||||
|
@ -10,6 +11,7 @@
|
|||
#![feature(ptr_metadata)]
|
||||
#![feature(const_mut_refs)]
|
||||
#![feature(slice_ptr_get)]
|
||||
#![allow(clippy::format_collect)]
|
||||
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
|
@ -20,8 +22,6 @@ use std::{
|
|||
|
||||
use parser::Ast;
|
||||
|
||||
use crate::parser::FileId;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! run_tests {
|
||||
($runner:path: $($name:ident => $input:expr;)*) => {$(
|
||||
|
@ -286,9 +286,9 @@ pub fn parse_all(threads: usize, root: &str) -> io::Result<Vec<Ast>> {
|
|||
}
|
||||
}
|
||||
|
||||
type Task = (FileId, PathBuf, Option<std::process::Command>);
|
||||
type Task = (u32, PathBuf, Option<std::process::Command>);
|
||||
|
||||
let seen = Mutex::new(HashMap::<PathBuf, FileId>::default());
|
||||
let seen = Mutex::new(HashMap::<PathBuf, u32>::default());
|
||||
let tasks = TaskQueue::<Task>::new(threads);
|
||||
let ast = Mutex::new(Vec::<io::Result<Ast>>::new());
|
||||
|
||||
|
@ -306,7 +306,7 @@ pub fn parse_all(threads: usize, root: &str) -> io::Result<Vec<Ast>> {
|
|||
}
|
||||
std::collections::hash_map::Entry::Vacant(entry) => {
|
||||
entry.insert(len as _);
|
||||
len as FileId
|
||||
len as u32
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -533,6 +533,7 @@ macro_rules! generate_expr {
|
|||
pub fn used_bytes(&self) -> usize {
|
||||
match self {$(
|
||||
Self::$variant { $($field,)* } => {
|
||||
#[allow(clippy::size_of_ref)]
|
||||
let fields = [$(($field as *const _ as usize - self as *const _ as usize, std::mem::size_of_val($field)),)*];
|
||||
let (last, size) = fields.iter().copied().max().unwrap();
|
||||
last + size
|
||||
|
@ -905,11 +906,11 @@ impl ExprRef {
|
|||
}
|
||||
|
||||
pub fn get<'a>(&self, from: &'a Ast) -> Option<&'a Expr<'a>> {
|
||||
ArenaChunk::contains(from.mem.base, self.0.as_ptr() as _).then_some(())?;
|
||||
// SAFETY: the pointer is or was a valid reference in the past, if it points within one of
|
||||
// arenas regions, it muts be walid, since arena does not give invalid pointers to its
|
||||
// allocations
|
||||
ArenaChunk::contains(from.mem.base, self.0.as_ptr() as _)
|
||||
.then(|| unsafe { { self.0 }.as_ref() })
|
||||
Some(unsafe { { self.0 }.as_ref() })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ impl Memory for HostMemory {
|
|||
count: usize,
|
||||
) -> Result<(), StoreError> {
|
||||
debug_assert!(addr.get() != 0);
|
||||
debug_assert!(source != core::ptr::null());
|
||||
debug_assert!(!source.is_null());
|
||||
unsafe { core::ptr::copy(source, addr.get() as *mut u8, count) }
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue