Improve diagnostics for duplicated names

This commit is contained in:
J Henry Waugh
2020-08-27 22:26:05 -05:00
parent a50da4bb8c
commit 525ffe6f5a
9 changed files with 189 additions and 1 deletions

View File

@@ -177,7 +177,17 @@ pub(crate) fn check_rename_collisions(fns: &Vec<ExportedFn>) -> Result<(), syn::
}
} else {
let ident = itemfn.name();
names.insert(ident.to_string(), ident.span());
if let Some(other_span) = names.insert(ident.to_string(), ident.span()) {
let mut err = syn::Error::new(
ident.span(),
format!("duplicate function '{}'", ident.to_string()),
);
err.combine(syn::Error::new(
other_span,
format!("duplicated function '{}'", ident.to_string()),
));
return Err(err);
}
}
}
for (new_name, attr_span) in renames.drain() {