Skip to content

Fix error message about exported symbols from proc-macro crates #66278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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