From 2b3ff8b4c44d22bbf5e080ddf980dba19890a5b0 Mon Sep 17 00:00:00 2001 From: playX18 Date: Fri, 23 Aug 2024 17:30:24 +0700 Subject: [PATCH] allow missing_docs in generated code --- core/src/gas_metering/schedule.rs | 94 +------------------------------ utils/weight-diff/src/main.rs | 28 ++------- 2 files changed, 7 insertions(+), 115 deletions(-) diff --git a/core/src/gas_metering/schedule.rs b/core/src/gas_metering/schedule.rs index 2b4b3a2a58f..2676a1a892b 100644 --- a/core/src/gas_metering/schedule.rs +++ b/core/src/gas_metering/schedule.rs @@ -20,7 +20,7 @@ #![doc = r" `pallets/gear/src/schedule.rs`."] #![doc = r""] #![doc = r" See `./scripts/weight-dump.sh` if you want to update it."] -#![allow(rustdoc::broken_intra_doc_links)] +#![allow(rustdoc::broken_intra_doc_links, missing_docs)] use crate::costs::*; #[derive(Debug, Clone)] @@ -194,179 +194,92 @@ pub struct InstructionWeights { #[doc = " Changes to other parts of the schedule should not increment the version in"] #[doc = " order to avoid unnecessary re-instrumentations."] pub version: u32, - #[allow(missing_docs)] pub i64const: u32, - #[allow(missing_docs)] pub i64load: u32, - #[allow(missing_docs)] pub i32load: u32, - #[allow(missing_docs)] pub i64store: u32, - #[allow(missing_docs)] pub i32store: u32, - #[allow(missing_docs)] pub select: u32, - #[allow(missing_docs)] pub r#if: u32, - #[allow(missing_docs)] pub br: u32, - #[allow(missing_docs)] pub br_if: u32, - #[allow(missing_docs)] pub br_table: u32, - #[allow(missing_docs)] pub br_table_per_entry: u32, - #[allow(missing_docs)] pub call: u32, - #[allow(missing_docs)] pub call_indirect: u32, - #[allow(missing_docs)] pub call_indirect_per_param: u32, - #[allow(missing_docs)] pub call_per_local: u32, - #[allow(missing_docs)] pub local_get: u32, - #[allow(missing_docs)] pub local_set: u32, - #[allow(missing_docs)] pub local_tee: u32, - #[allow(missing_docs)] pub global_get: u32, - #[allow(missing_docs)] pub global_set: u32, - #[allow(missing_docs)] pub memory_current: u32, - #[allow(missing_docs)] pub i64clz: u32, - #[allow(missing_docs)] pub i32clz: u32, - #[allow(missing_docs)] pub i64ctz: u32, - #[allow(missing_docs)] pub i32ctz: u32, - #[allow(missing_docs)] pub i64popcnt: u32, - #[allow(missing_docs)] pub i32popcnt: u32, - #[allow(missing_docs)] pub i64eqz: u32, - #[allow(missing_docs)] pub i32eqz: u32, - #[allow(missing_docs)] pub i32extend8s: u32, - #[allow(missing_docs)] pub i32extend16s: u32, - #[allow(missing_docs)] pub i64extend8s: u32, - #[allow(missing_docs)] pub i64extend16s: u32, - #[allow(missing_docs)] pub i64extend32s: u32, - #[allow(missing_docs)] pub i64extendsi32: u32, - #[allow(missing_docs)] pub i64extendui32: u32, - #[allow(missing_docs)] pub i32wrapi64: u32, - #[allow(missing_docs)] pub i64eq: u32, - #[allow(missing_docs)] pub i32eq: u32, - #[allow(missing_docs)] pub i64ne: u32, - #[allow(missing_docs)] pub i32ne: u32, - #[allow(missing_docs)] pub i64lts: u32, - #[allow(missing_docs)] pub i32lts: u32, - #[allow(missing_docs)] pub i64ltu: u32, - #[allow(missing_docs)] pub i32ltu: u32, - #[allow(missing_docs)] pub i64gts: u32, - #[allow(missing_docs)] pub i32gts: u32, - #[allow(missing_docs)] pub i64gtu: u32, - #[allow(missing_docs)] pub i32gtu: u32, - #[allow(missing_docs)] pub i64les: u32, - #[allow(missing_docs)] pub i32les: u32, - #[allow(missing_docs)] pub i64leu: u32, - #[allow(missing_docs)] pub i32leu: u32, - #[allow(missing_docs)] pub i64ges: u32, - #[allow(missing_docs)] pub i32ges: u32, - #[allow(missing_docs)] pub i64geu: u32, - #[allow(missing_docs)] pub i32geu: u32, - #[allow(missing_docs)] pub i64add: u32, - #[allow(missing_docs)] pub i32add: u32, - #[allow(missing_docs)] pub i64sub: u32, - #[allow(missing_docs)] pub i32sub: u32, - #[allow(missing_docs)] pub i64mul: u32, - #[allow(missing_docs)] pub i32mul: u32, - #[allow(missing_docs)] pub i64divs: u32, - #[allow(missing_docs)] pub i32divs: u32, - #[allow(missing_docs)] pub i64divu: u32, - #[allow(missing_docs)] pub i32divu: u32, - #[allow(missing_docs)] pub i64rems: u32, - #[allow(missing_docs)] pub i32rems: u32, - #[allow(missing_docs)] pub i64remu: u32, - #[allow(missing_docs)] pub i32remu: u32, - #[allow(missing_docs)] pub i64and: u32, - #[allow(missing_docs)] pub i32and: u32, - #[allow(missing_docs)] pub i64or: u32, - #[allow(missing_docs)] pub i32or: u32, - #[allow(missing_docs)] pub i64xor: u32, - #[allow(missing_docs)] pub i32xor: u32, - #[allow(missing_docs)] pub i64shl: u32, - #[allow(missing_docs)] pub i32shl: u32, - #[allow(missing_docs)] pub i64shrs: u32, - #[allow(missing_docs)] pub i32shrs: u32, - #[allow(missing_docs)] pub i64shru: u32, - #[allow(missing_docs)] pub i32shru: u32, - #[allow(missing_docs)] pub i64rotl: u32, - #[allow(missing_docs)] pub i32rotl: u32, - #[allow(missing_docs)] pub i64rotr: u32, - #[allow(missing_docs)] pub i32rotr: u32, } @@ -1071,13 +984,9 @@ impl Default for RentWeights { #[derive(Debug, Clone)] #[doc = " Describes DB access weights."] pub struct DbWeights { - #[allow(missing_docs)] pub read: Weight, - #[allow(missing_docs)] pub read_per_byte: Weight, - #[allow(missing_docs)] pub write: Weight, - #[allow(missing_docs)] pub write_per_byte: Weight, } @@ -1271,7 +1180,6 @@ impl From for InstantiationCosts { } impl Schedule { - #[allow(missing_docs)] pub fn process_costs(&self) -> ProcessCosts { ProcessCosts { ext: ExtCosts { diff --git a/utils/weight-diff/src/main.rs b/utils/weight-diff/src/main.rs index 14bf4e37f91..482d02e03cf 100644 --- a/utils/weight-diff/src/main.rs +++ b/utils/weight-diff/src/main.rs @@ -33,7 +33,6 @@ use serde_json::Value; use std::{fs, path::PathBuf, str::FromStr}; use syn::{ ext::IdentExt, - parse_quote, visit::{self, Visit}, AngleBracketedGenericArguments, Fields, FnArg, GenericArgument, Generics, ImplItem, Item, ItemImpl, ItemStruct, Path, PathArguments, PathSegment, Type, TypePath, @@ -266,18 +265,9 @@ impl<'ast> Visit<'ast> for StructuresVisitor { } } } - let mut has_doc = false; - - field.attrs.retain(|attr| { - let ident = &attr.path().segments.first().unwrap().ident; - let res = ident == "doc"; - has_doc |= res; - res - }); - - if !has_doc { - field.attrs.push(parse_quote!(#[allow(missing_docs)])); - } + field + .attrs + .retain(|attr| attr.path().segments.first().unwrap().ident == "doc"); } self.structures.insert(structure_name, structure); @@ -376,14 +366,8 @@ impl ImplementationVisitor { if *ident == "Schedule" { // only leave process_costs method implementation.items.retain_mut(|item| match item { - ImplItem::Fn(func) => { - if func.sig.ident == "process_costs" { - func.attrs.push(parse_quote!(#[allow(missing_docs)])); - true - } else { - false - } - } + ImplItem::Fn(func) => func.sig.ident == "process_costs", + _ => false, }); @@ -517,7 +501,7 @@ fn main() { }]; declarations.push(quote! { - #![allow(rustdoc::broken_intra_doc_links)] + #![allow(rustdoc::broken_intra_doc_links, missing_docs)] use crate::costs::*; });