ci: ensure docs build (#1073)

Co-authored-by: xqft <estefano.bargas@fing.edu.uy>
Co-authored-by: lambdaclass-user <github@lambdaclass.com>
This commit is contained in:
Bjerg
2023-01-27 18:49:22 +01:00
committed by GitHub
parent ba44c1551c
commit 87306f2892
74 changed files with 197 additions and 159 deletions

View File

@ -1,8 +1,8 @@
//! Code generator for the [`Compact`] trait.
//! Code generator for the `Compact` trait.
use super::*;
/// Generates code to implement the [`Compact`] trait for a data type.
/// Generates code to implement the `Compact` trait for a data type.
pub fn generate_from_to(ident: &Ident, fields: &FieldList) -> TokenStream2 {
let flags = format_ident!("{ident}Flags");
@ -47,7 +47,7 @@ pub fn generate_from_to(ident: &Ident, fields: &FieldList) -> TokenStream2 {
}
}
/// Generates code to implement the [`Compact`] trait method `to_compact`.
/// Generates code to implement the `Compact` trait method `to_compact`.
fn generate_from_compact(fields: &FieldList, ident: &Ident) -> Vec<TokenStream2> {
let mut lines = vec![];
let mut known_types = vec!["H256", "H160", "Address", "Bloom", "Vec"];
@ -102,7 +102,7 @@ fn generate_from_compact(fields: &FieldList, ident: &Ident) -> Vec<TokenStream2>
lines
}
/// Generates code to implement the [`Compact`] trait method `from_compact`.
/// Generates code to implement the `Compact` trait method `from_compact`.
fn generate_to_compact(fields: &FieldList, ident: &Ident) -> Vec<TokenStream2> {
let mut lines = vec![quote! {
let mut buffer = bytes::BytesMut::new();

View File

@ -40,7 +40,7 @@ pub enum FieldTypes {
EnumUnnamedField((FieldType, UseAlternative)),
}
/// Derives the [`Compact`] trait and its from/to implementations.
/// Derives the `Compact` trait and its from/to implementations.
pub fn derive(input: TokenStream) -> TokenStream {
let mut output = quote! {};
@ -134,8 +134,9 @@ fn load_field(field: &syn::Field, fields: &mut FieldList, is_enum: bool) {
}
/// Since there's no impl specialization in rust stable atm, once we find we have a
/// Vec/Option we try to find out if it's a Vec/Option of a fixed size data type.
/// eg, Vec<H256>. If so, we use another impl to code/decode its data.
/// Vec/Option we try to find out if it's a Vec/Option of a fixed size data type, e.g. `Vec<H256>`.
///
/// If so, we use another impl to code/decode its data.
fn should_use_alt_impl(ftype: &String, segment: &syn::PathSegment) -> bool {
if *ftype == "Vec" || *ftype == "Option" {
if let syn::PathArguments::AngleBracketed(ref args) = segment.arguments {

View File

@ -134,7 +134,7 @@ pub fn derive_arbitrary(args: TokenStream, input: TokenStream) -> TokenStream {
.into()
}
/// To be used for types that implement `Arbitrary` manually. See [`derive_arbitrary`] for more.
/// To be used for types that implement `Arbitrary` manually. See [`derive_arbitrary()`] for more.
#[proc_macro_attribute]
pub fn add_arbitrary_tests(args: TokenStream, input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);

View File

@ -17,8 +17,8 @@ use revm_interpreter::{B160 as H160, B256 as H256, U256};
/// add their definitions to `get_bit_size()` or `known_types` in `generator.rs`.
///
/// Regarding the `specialized_to/from_compact` methods: Mainly used as a workaround for not being
/// able to specialize an impl over certain types like Vec<T>/Option<T> where T is a fixed size
/// array like Vec<H256>.
/// able to specialize an impl over certain types like `Vec<T>`/`Option<T>` where `T` is a fixed
/// size array like `Vec<H256>`.
pub trait Compact {
/// Takes a buffer which can be written to. *Ideally*, it returns the length written to.
fn to_compact(self, buf: &mut impl bytes::BufMut) -> usize;
@ -113,7 +113,7 @@ where
(list, buf)
}
/// To be used by fixed sized types like Vec<H256>.
/// To be used by fixed sized types like `Vec<H256>`.
fn specialized_to_compact(self, buf: &mut impl bytes::BufMut) -> usize {
buf.put_u16(self.len() as u16);
@ -123,7 +123,7 @@ where
0
}
/// To be used by fixed sized types like Vec<H256>.
/// To be used by fixed sized types like `Vec<H256>`.
fn specialized_from_compact(mut buf: &[u8], len: usize) -> (Self, &[u8]) {
let mut list = vec![];
let length = buf.get_u16();
@ -169,7 +169,7 @@ where
(Some(element), buf)
}
/// To be used by fixed sized types like Option<H256>.
/// To be used by fixed sized types like `Option<H256>`.
fn specialized_to_compact(self, buf: &mut impl bytes::BufMut) -> usize {
if let Some(element) = self {
element.to_compact(buf);
@ -178,7 +178,7 @@ where
0
}
/// To be used by fixed sized types like Option<H256>.
/// To be used by fixed sized types like `Option<H256>`.
fn specialized_from_compact(buf: &[u8], len: usize) -> (Self, &[u8]) {
if len == 0 {
return (None, buf)