about summary refs log tree commit diff
path: root/src/libsyntax/feature_gate.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-04-16 16:21:09 -0700
committerbors <bors@rust-lang.org>2016-04-16 16:21:09 -0700
commitae33aa74f4e03b11a9a82e10dbf7369c3ae6bd04 (patch)
tree285c01dd08e9c3f426d99beeacba4e1e288297b1 /src/libsyntax/feature_gate.rs
parenta7c3a294bf33880d27fc7c3f662a981b1625c0bb (diff)
parente14504a113b55c09686a5986c51bbdd6ae9c5da4 (diff)
downloadrust-ae33aa74f4e03b11a9a82e10dbf7369c3ae6bd04.tar.gz
rust-ae33aa74f4e03b11a9a82e10dbf7369c3ae6bd04.zip
Auto merge of #32875 - jseyfried:1422_implementation, r=nikomatsakis
Implement `pub(restricted)` privacy (RFC 1422)

This implements `pub(restricted)` privacy from RFC 1422 (cc #32409) behind a feature gate.

`pub(restricted)` paths currently cannot use re-exported modules both for simplicity of implementation and for future compatibility with RFC 1560 (cf #31783).

r? @nikomatsakis
Diffstat (limited to 'src/libsyntax/feature_gate.rs')
-rw-r--r--src/libsyntax/feature_gate.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index 24a62a3dc2a..d8352430eb9 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -256,6 +256,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Option<u32>, Status
 
     // impl specialization (RFC 1210)
     ("specialization", "1.7.0", Some(31844), Active),
+
+    // pub(restricted) visibilities (RFC 1422)
+    ("pub_restricted", "1.9.0", Some(32409), Active),
 ];
 // (changing above list without updating src/doc/reference.md makes @cmr sad)
 
@@ -608,6 +611,7 @@ pub struct Features {
     pub deprecated: bool,
     pub question_mark: bool,
     pub specialization: bool,
+    pub pub_restricted: bool,
 }
 
 impl Features {
@@ -644,6 +648,7 @@ impl Features {
             deprecated: false,
             question_mark: false,
             specialization: false,
+            pub_restricted: false,
         }
     }
 }
@@ -1159,6 +1164,15 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
         }
         visit::walk_impl_item(self, ii);
     }
+
+    fn visit_vis(&mut self, vis: &'v ast::Visibility) {
+        let span = match *vis {
+            ast::Visibility::Crate(span) => span,
+            ast::Visibility::Restricted { ref path, .. } => path.span,
+            _ => return,
+        };
+        self.gate_feature("pub_restricted", span, "`pub(restricted)` syntax is experimental");
+    }
 }
 
 fn check_crate_inner<F>(cm: &CodeMap, span_handler: &Handler,
@@ -1256,6 +1270,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &Handler,
         deprecated: cx.has_feature("deprecated"),
         question_mark: cx.has_feature("question_mark"),
         specialization: cx.has_feature("specialization"),
+        pub_restricted: cx.has_feature("pub_restricted"),
     }
 }