mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 19:01:08 +00:00
Detect conflicting module names in construct_runtime! (#7968)
This commit is contained in:
@@ -62,6 +62,7 @@ impl Module {
|
||||
fn complete_modules(decl: impl Iterator<Item = ModuleDeclaration>) -> syn::Result<Vec<Module>> {
|
||||
let mut indices = HashMap::new();
|
||||
let mut last_index: Option<u8> = None;
|
||||
let mut names = HashMap::new();
|
||||
|
||||
decl
|
||||
.map(|module| {
|
||||
@@ -88,6 +89,14 @@ fn complete_modules(decl: impl Iterator<Item = ModuleDeclaration>) -> syn::Resul
|
||||
return Err(err);
|
||||
}
|
||||
|
||||
if let Some(used_module) = names.insert(module.name.clone(), module.name.span()) {
|
||||
let msg = "Two modules with the same name!";
|
||||
|
||||
let mut err = syn::Error::new(used_module, &msg);
|
||||
err.combine(syn::Error::new(module.name.span(), &msg));
|
||||
return Err(err);
|
||||
}
|
||||
|
||||
Ok(Module {
|
||||
name: module.name,
|
||||
index: final_index,
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
use frame_support::construct_runtime;
|
||||
|
||||
construct_runtime! {
|
||||
pub enum Runtime where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
System: system::{Module},
|
||||
Balance: balances::{Module},
|
||||
Balance: balances::{Module},
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
error: Two modules with the same name!
|
||||
--> $DIR/conflicting_module_name.rs:10:3
|
||||
|
|
||||
10 | Balance: balances::{Module},
|
||||
| ^^^^^^^
|
||||
|
||||
error: Two modules with the same name!
|
||||
--> $DIR/conflicting_module_name.rs:11:3
|
||||
|
|
||||
11 | Balance: balances::{Module},
|
||||
| ^^^^^^^
|
||||
Reference in New Issue
Block a user