Rollup merge of #82296 - spastorino:pubrules, r=nikomatsakis

Support `pub` on `macro_rules`

This rebases and updates `since` version of #78166 from ``@petrochenkov``

r? ``@nikomatsakis``
This commit is contained in:
Dylan DPC 2021-02-23 16:10:23 +01:00 committed by GitHub
commit e2561c58a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 183 additions and 35 deletions

View file

@ -1475,15 +1475,7 @@ impl<'a> Parser<'a> {
let vstr = pprust::vis_to_string(vis);
let vstr = vstr.trim_end();
if macro_rules {
let msg = format!("can't qualify macro_rules invocation with `{}`", vstr);
self.struct_span_err(vis.span, &msg)
.span_suggestion(
vis.span,
"try exporting the macro",
"#[macro_export]".to_owned(),
Applicability::MaybeIncorrect, // speculative
)
.emit();
self.sess.gated_spans.gate(sym::pub_macro_rules, vis.span);
} else {
self.struct_span_err(vis.span, "can't qualify macro invocation with `pub`")
.span_suggestion(