impl<'a> CollectProcMacros<'a> {
fn check_not_pub_in_root(&self, vis: &ast::Visibility, sp: Span) {
if self.is_proc_macro_crate && self.in_root && vis.node.is_pub() {
- self.handler.span_err(sp,
- "`proc-macro` crate types cannot \
- export any items other than functions \
- tagged with `#[proc_macro_derive]` currently");
+ self.handler.span_err(
+ sp,
+ "`proc-macro` crate types currently cannot export any items other \
+ than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, \
+ or `#[proc_macro_attribute]`",
+ );
}
}
for attr in &item.attrs {
if is_proc_macro_attr(&attr) {
if let Some(prev_attr) = found_attr {
- let path_str = pprust::path_to_string(&attr.path);
- let msg = if attr.path.segments[0].ident.name ==
- prev_attr.path.segments[0].ident.name {
+ let prev_item = prev_attr.get_normal_item();
+ let item = attr.get_normal_item();
+ let path_str = pprust::path_to_string(&item.path);
+ let msg = if item.path.segments[0].ident.name ==
+ prev_item.path.segments[0].ident.name {
format!(
"only one `#[{}]` attribute is allowed on any given function",
path_str,
"`#[{}]` and `#[{}]` attributes cannot both be applied
to the same function",
path_str,
- pprust::path_to_string(&prev_attr.path),
+ pprust::path_to_string(&prev_item.path),
)
};
self.handler.struct_span_err(attr.span, &msg)
- .span_note(prev_attr.span, "previous attribute here")
+ .span_label(prev_attr.span, "previous attribute here")
.emit();
return;
if !is_fn {
let msg = format!(
"the `#[{}]` attribute may only be used on bare functions",
- pprust::path_to_string(&attr.path),
+ pprust::path_to_string(&attr.get_normal_item().path),
);
self.handler.span_err(attr.span, &msg);
if !self.is_proc_macro_crate {
let msg = format!(
"the `#[{}]` attribute is only usable with crates of the `proc-macro` crate type",
- pprust::path_to_string(&attr.path),
+ pprust::path_to_string(&attr.get_normal_item().path),
);
self.handler.span_err(attr.span, &msg);