Skip to content

Commit

Permalink
Rollup merge of rust-lang#66278 - LukasKalbertodt:fix-proc-macro-erro…
Browse files Browse the repository at this point in the history
…r, r=Centril

Fix error message about exported symbols from proc-macro crates

Someone forgot to update the error message after `#[proc_macro]` and
`#[proc_macro_attribute]` were stabilized.
  • Loading branch information
JohnTitor authored Nov 12, 2019
2 parents dfd1122 + 696ac95 commit 8e0265c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/libsyntax_ext/proc_macro_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ pub fn inject(sess: &ParseSess,
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]`",
);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/proc-macro/exports.stderr
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
error: `proc-macro` crate types cannot export any items other than functions tagged with `#[proc_macro_derive]` currently
error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
--> $DIR/exports.rs:7:1
|
LL | pub fn a() {}
| ^^^^^^^^^^^^^

error: `proc-macro` crate types cannot export any items other than functions tagged with `#[proc_macro_derive]` currently
error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
--> $DIR/exports.rs:8:1
|
LL | pub struct B;
| ^^^^^^^^^^^^^

error: `proc-macro` crate types cannot export any items other than functions tagged with `#[proc_macro_derive]` currently
error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
--> $DIR/exports.rs:9:1
|
LL | pub enum C {}
| ^^^^^^^^^^^^^

error: `proc-macro` crate types cannot export any items other than functions tagged with `#[proc_macro_derive]` currently
error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
--> $DIR/exports.rs:10:1
|
LL | pub mod d {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/proc-macro/pub-at-crate-root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

extern crate proc_macro;

pub mod a { //~ `proc-macro` crate types cannot export any items
pub mod a { //~ `proc-macro` crate types currently cannot export any items
use proc_macro::TokenStream;

#[proc_macro_derive(B)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/proc-macro/pub-at-crate-root.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: `proc-macro` crate types cannot export any items other than functions tagged with `#[proc_macro_derive]` currently
error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
--> $DIR/pub-at-crate-root.rs:8:1
|
LL | / pub mod a {
Expand Down

0 comments on commit 8e0265c

Please sign in to comment.