diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2021-03-31 15:43:33 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2021-04-23 10:40:32 -0300 |
| commit | 0e4d2fd447602f8cc9cf2eb9851cdfddfbcd6f3d (patch) | |
| tree | 6e5549a1d04acb5a99655b1e6076d7e60c45379e /compiler | |
| parent | 5f1aeb52c22e3784928765e34be6dc0d17a350b4 (diff) | |
| download | rust-0e4d2fd447602f8cc9cf2eb9851cdfddfbcd6f3d.tar.gz rust-0e4d2fd447602f8cc9cf2eb9851cdfddfbcd6f3d.zip | |
Revert "Rollup merge of #82296 - spastorino:pubrules, r=nikomatsakis"
This reverts commit e2561c58a41023a14e0e583113dcf55e1ecb236a, reversing changes made to 2982ba50fc4bb629b8fe4108a81cb2f9b053510b.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_ast_passes/src/feature_gate.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_feature/src/active.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/build_reduced_graph.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_span/src/symbol.rs | 1 |
5 files changed, 11 insertions, 13 deletions
diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index c803c8a83b1..c73c6a80798 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -691,7 +691,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) { // involved, so we only emit errors where there are no other parsing errors. gate_all!(destructuring_assignment, "destructuring assignments are unstable"); } - gate_all!(pub_macro_rules, "`pub` on `macro_rules` items is unstable"); // All uses of `gate_all!` below this point were added in #65742, // and subsequently disabled (with the non-early gating readded). diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index a410826d3fd..f9bc2e86618 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -624,9 +624,6 @@ declare_features! ( /// Allows macro attributes to observe output of `#[derive]`. (active, macro_attributes_in_derive_output, "1.51.0", Some(81119), None), - /// Allows `pub` on `macro_rules` items. - (active, pub_macro_rules, "1.52.0", Some(78855), None), - /// Allows the use of type alias impl trait in function return positions (active, min_type_alias_impl_trait, "1.52.0", Some(63063), None), diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 299b9a959c5..acf3867cf89 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1478,7 +1478,15 @@ impl<'a> Parser<'a> { let vstr = pprust::vis_to_string(vis); let vstr = vstr.trim_end(); if macro_rules { - self.sess.gated_spans.gate(sym::pub_macro_rules, vis.span); + 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(); } else { self.struct_span_err(vis.span, "can't qualify macro invocation with `pub`") .span_suggestion( diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index d77022a65e4..b5c95cfcb29 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -1230,13 +1230,13 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { }; let res = Res::Def(DefKind::Macro(ext.macro_kind()), def_id.to_def_id()); - let is_macro_export = self.r.session.contains_name(&item.attrs, sym::macro_export); self.r.macro_map.insert(def_id.to_def_id(), ext); self.r.local_macro_def_scopes.insert(def_id, parent_scope.module); - if macro_rules && matches!(item.vis.kind, ast::VisibilityKind::Inherited) { + if macro_rules { let ident = ident.normalize_to_macros_2_0(); self.r.macro_names.insert(ident); + let is_macro_export = self.r.session.contains_name(&item.attrs, sym::macro_export); let vis = if is_macro_export { ty::Visibility::Public } else { @@ -1261,11 +1261,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { }), )) } else { - if is_macro_export { - let what = if macro_rules { "`macro_rules` with `pub`" } else { "`macro` items" }; - let msg = format!("`#[macro_export]` cannot be used on {what}"); - self.r.session.span_err(item.span, &msg); - } let module = parent_scope.module; let vis = match item.kind { // Visibilities must not be resolved non-speculatively twice diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 52270f0e627..681206dfb6a 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -903,7 +903,6 @@ symbols! { ptr_null, ptr_null_mut, ptr_offset_from, - pub_macro_rules, pub_restricted, pure, pushpop_unsafe, |
