mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 01:47:55 +00:00
a7b45ef1d1
* codegen: Add codegen error Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use codegen error instead of aborts Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Remove `proc-macro-error` dependency Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * macro/subxt: Transform codegen error into compile_error! Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Pretty printing for `CodegenError` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update cargo.lock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Adjust testing for codegen error Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Fix documentation example Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Export `CodegenError` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use collect::<Result<_>, _>() Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Adjust comment regarding error printing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Improve error messages Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
41 lines
1016 B
Rust
41 lines
1016 B
Rust
// Copyright 2019-2022 Parity Technologies (UK) Ltd.
|
|
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
|
// see LICENSE for license details.
|
|
|
|
use crate::api::CodegenError;
|
|
use syn::token;
|
|
|
|
#[derive(Debug, PartialEq, Eq)]
|
|
pub struct ItemMod {
|
|
vis: syn::Visibility,
|
|
mod_token: token::Mod,
|
|
pub ident: syn::Ident,
|
|
brace: token::Brace,
|
|
items: Vec<syn::Item>,
|
|
}
|
|
|
|
impl TryFrom<syn::ItemMod> for ItemMod {
|
|
type Error = CodegenError;
|
|
|
|
fn try_from(module: syn::ItemMod) -> Result<Self, Self::Error> {
|
|
let (brace, items) = match module.content {
|
|
Some((brace, items)) => (brace, items),
|
|
None => return Err(CodegenError::InvalidModule(module.ident.span())),
|
|
};
|
|
|
|
Ok(Self {
|
|
vis: module.vis,
|
|
mod_token: module.mod_token,
|
|
ident: module.ident,
|
|
brace,
|
|
items,
|
|
})
|
|
}
|
|
}
|
|
|
|
impl ItemMod {
|
|
pub fn rust_items(&self) -> impl Iterator<Item = &syn::Item> {
|
|
self.items.iter()
|
|
}
|
|
}
|