about summary refs log tree commit diff
diff options
context:
space:
mode:
authorpetrochenkov <vadim.petrochenkov@gmail.com>2017-06-29 16:06:24 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2017-07-07 01:22:48 +0300
commita27f8cf8a36f3d69267ed25602504144fab1d896 (patch)
tree21b67433bf37f7da873bbd97bdd24b43a9ae96c6
parent08a1d45818d022095d597919aa0d50ee7be2a0c6 (diff)
downloadrust-a27f8cf8a36f3d69267ed25602504144fab1d896.tar.gz
rust-a27f8cf8a36f3d69267ed25602504144fab1d896.zip
Address review comments
Fix regressions after rebase
-rw-r--r--src/libproc_macro/quote.rs2
-rw-r--r--src/librustc_privacy/lib.rs6
-rw-r--r--src/test/compile-fail/auxiliary/private-inferred-type.rs4
-rw-r--r--src/test/compile-fail/private-inferred-type-3.rs2
-rw-r--r--src/test/compile-fail/private-inferred-type.rs6
5 files changed, 13 insertions, 7 deletions
diff --git a/src/libproc_macro/quote.rs b/src/libproc_macro/quote.rs
index bee2c1e0eb6..0db2b86b15f 100644
--- a/src/libproc_macro/quote.rs
+++ b/src/libproc_macro/quote.rs
@@ -87,7 +87,7 @@ impl ProcMacro for Quoter {
         let mut info = cx.current_expansion.mark.expn_info().unwrap();
         info.callee.allow_internal_unstable = true;
         cx.current_expansion.mark.set_expn_info(info);
-        ::__internal::set_sess(cx, || quote!(::TokenStream((quote stream))))
+        ::__internal::set_sess(cx, || quote!(::TokenStream { 0: (quote stream) }))
     }
 }
 
diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs
index 54f693a5a81..051b89219c1 100644
--- a/src/librustc_privacy/lib.rs
+++ b/src/librustc_privacy/lib.rs
@@ -590,6 +590,7 @@ impl<'a, 'tcx> TypePrivacyVisitor<'a, 'tcx> {
         self.def_id_visibility(did).is_accessible_from(self.current_item, self.tcx)
     }
 
+    // Take node ID of an expression or pattern and check its type for privacy.
     fn check_expr_pat_type(&mut self, id: ast::NodeId, span: Span) -> bool {
         self.span = span;
         if let Some(ty) = self.tables.node_id_to_type_opt(id) {
@@ -797,6 +798,11 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
                     self.tcx.sess.span_err(self.span, &msg);
                     return true;
                 }
+                if let ty::TyFnDef(..) = ty.sty {
+                    if self.tcx.fn_sig(def_id).visit_with(self) {
+                        return true;
+                    }
+                }
                 // Inherent static methods don't have self type in substs,
                 // we have to check it additionally.
                 if let Some(assoc_item) = self.tcx.opt_associated_item(def_id) {
diff --git a/src/test/compile-fail/auxiliary/private-inferred-type.rs b/src/test/compile-fail/auxiliary/private-inferred-type.rs
index 28bf9e08157..7627f5dc0cd 100644
--- a/src/test/compile-fail/auxiliary/private-inferred-type.rs
+++ b/src/test/compile-fail/auxiliary/private-inferred-type.rs
@@ -29,7 +29,7 @@ impl Pub<Priv> {
     pub fn static_method() {}
 }
 impl Pub<u8> {
-    fn priv_metod(&self) {}
+    fn priv_method(&self) {}
 }
 
 pub macro m() {
@@ -40,5 +40,5 @@ pub macro m() {
     <u8 as PubTrait>::method;
     PrivTupleStruct;
     PubTupleStruct;
-    Pub(0u8).priv_metod();
+    Pub(0u8).priv_method();
 }
diff --git a/src/test/compile-fail/private-inferred-type-3.rs b/src/test/compile-fail/private-inferred-type-3.rs
index 438dd5e1933..fdd9166ef29 100644
--- a/src/test/compile-fail/private-inferred-type-3.rs
+++ b/src/test/compile-fail/private-inferred-type-3.rs
@@ -15,7 +15,7 @@
 // error-pattern:type `fn() {<u8 as ext::PrivTrait>::method}` is private
 // error-pattern:type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct::{{constructor}}}` is pr
 // error-pattern:type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct::{{constructor}}}` is priv
-// error-pattern:type `fn(&ext::Pub<u8>) {<ext::Pub<u8>>::priv_metod}` is private
+// error-pattern:type `fn(&ext::Pub<u8>) {<ext::Pub<u8>>::priv_method}` is private
 
 #![feature(decl_macro)]
 
diff --git a/src/test/compile-fail/private-inferred-type.rs b/src/test/compile-fail/private-inferred-type.rs
index c00bfe5e574..140891027d5 100644
--- a/src/test/compile-fail/private-inferred-type.rs
+++ b/src/test/compile-fail/private-inferred-type.rs
@@ -37,7 +37,7 @@ mod m {
         pub const INHERENT_ASSOC_CONST_GENERIC_SELF: u8 = 0;
     }
     impl Pub<u8> {
-        fn priv_metod(&self) {}
+        fn priv_method(&self) {}
         pub fn method_with_substs<T>(&self) {}
         pub fn method_with_priv_params(&self, _: Priv) {}
     }
@@ -54,8 +54,8 @@ mod m {
         //~^ ERROR type `fn(u8) -> m::PrivTupleStruct {m::PrivTupleStruct::{{constructor}}}` is priv
         PubTupleStruct;
         //~^ ERROR type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct::{{constructor}}}` is privat
-        Pub(0u8).priv_metod();
-        //~^ ERROR type `fn(&m::Pub<u8>) {<m::Pub<u8>>::priv_metod}` is private
+        Pub(0u8).priv_method();
+        //~^ ERROR type `fn(&m::Pub<u8>) {<m::Pub<u8>>::priv_method}` is private
     }
 
     trait Trait {}