mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 22:21:07 +00:00
Remove warning and make __PhantomItem unconstructable (#2000)
* Remove warning and make `__PhantomItem` unconstructable * Switch to unreachable
This commit is contained in:
@@ -27,6 +27,9 @@ pub use srml_metadata::{
|
||||
FunctionArgumentMetadata, OuterDispatchMetadata, OuterDispatchCall
|
||||
};
|
||||
|
||||
/// A type that can not be instantiated.
|
||||
pub enum Never {}
|
||||
|
||||
/// Result of a module function call; either nothing (functions are only called for "side efeects")
|
||||
/// or an error message.
|
||||
pub type Result = result::Result<(), &'static str>;
|
||||
@@ -615,7 +618,7 @@ macro_rules! decl_module {
|
||||
$(#[$attr])*
|
||||
pub enum $call_type<$trait_instance: $trait_name> {
|
||||
#[doc(hidden)]
|
||||
__PhantomItem(::std::marker::PhantomData<$trait_instance>),
|
||||
__PhantomItem(::std::marker::PhantomData<$trait_instance>, $crate::dispatch::Never),
|
||||
$(
|
||||
#[allow(non_camel_case_types)]
|
||||
$(#[doc = $doc_attr])*
|
||||
@@ -627,7 +630,7 @@ macro_rules! decl_module {
|
||||
$(#[$attr])*
|
||||
pub enum $call_type<$trait_instance: $trait_name> {
|
||||
#[doc(hidden)]
|
||||
__PhantomItem(::core::marker::PhantomData<$trait_instance>),
|
||||
__PhantomItem(::core::marker::PhantomData<$trait_instance>, $crate::dispatch::Never),
|
||||
$(
|
||||
#[allow(non_camel_case_types)]
|
||||
$(#[doc = $doc_attr])*
|
||||
@@ -662,7 +665,7 @@ macro_rules! decl_module {
|
||||
self_params == ( $( $param_name, )* )
|
||||
} else {
|
||||
match *_other {
|
||||
$call_type::__PhantomItem(_) => unreachable!(),
|
||||
$call_type::__PhantomItem(_, _) => unreachable!(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -704,7 +707,6 @@ macro_rules! decl_module {
|
||||
impl<$trait_instance: $trait_name> $crate::dispatch::Encode for $call_type<$trait_instance> {
|
||||
fn encode_to<W: $crate::dispatch::Output>(&self, _dest: &mut W) {
|
||||
$crate::__impl_encode!(_dest; *self; 0; $call_type; $( fn $fn_name( $( $(#[$codec_attr on type $param])* $param_name ),* ); )*);
|
||||
if let $call_type::__PhantomItem(_) = *self { unreachable!() }
|
||||
}
|
||||
}
|
||||
impl<$trait_instance: $trait_name> $crate::dispatch::Dispatchable
|
||||
@@ -723,7 +725,7 @@ macro_rules! decl_module {
|
||||
)
|
||||
},
|
||||
)*
|
||||
$call_type::__PhantomItem(_) => { panic!("__PhantomItem should never be used.") },
|
||||
$call_type::__PhantomItem(_, _) => { unreachable!("__PhantomItem should never be used.") },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user