Skip to content

Commit a27f8cf

Browse files
committed
Address review comments
Fix regressions after rebase
1 parent 08a1d45 commit a27f8cf

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

src/libproc_macro/quote.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl ProcMacro for Quoter {
8787
let mut info = cx.current_expansion.mark.expn_info().unwrap();
8888
info.callee.allow_internal_unstable = true;
8989
cx.current_expansion.mark.set_expn_info(info);
90-
::__internal::set_sess(cx, || quote!(::TokenStream((quote stream))))
90+
::__internal::set_sess(cx, || quote!(::TokenStream { 0: (quote stream) }))
9191
}
9292
}
9393

src/librustc_privacy/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ impl<'a, 'tcx> TypePrivacyVisitor<'a, 'tcx> {
590590
self.def_id_visibility(did).is_accessible_from(self.current_item, self.tcx)
591591
}
592592

593+
// Take node ID of an expression or pattern and check its type for privacy.
593594
fn check_expr_pat_type(&mut self, id: ast::NodeId, span: Span) -> bool {
594595
self.span = span;
595596
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> {
797798
self.tcx.sess.span_err(self.span, &msg);
798799
return true;
799800
}
801+
if let ty::TyFnDef(..) = ty.sty {
802+
if self.tcx.fn_sig(def_id).visit_with(self) {
803+
return true;
804+
}
805+
}
800806
// Inherent static methods don't have self type in substs,
801807
// we have to check it additionally.
802808
if let Some(assoc_item) = self.tcx.opt_associated_item(def_id) {

src/test/compile-fail/auxiliary/private-inferred-type.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl Pub<Priv> {
2929
pub fn static_method() {}
3030
}
3131
impl Pub<u8> {
32-
fn priv_metod(&self) {}
32+
fn priv_method(&self) {}
3333
}
3434

3535
pub macro m() {
@@ -40,5 +40,5 @@ pub macro m() {
4040
<u8 as PubTrait>::method;
4141
PrivTupleStruct;
4242
PubTupleStruct;
43-
Pub(0u8).priv_metod();
43+
Pub(0u8).priv_method();
4444
}

src/test/compile-fail/private-inferred-type-3.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// error-pattern:type `fn() {<u8 as ext::PrivTrait>::method}` is private
1616
// error-pattern:type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct::{{constructor}}}` is pr
1717
// error-pattern:type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct::{{constructor}}}` is priv
18-
// error-pattern:type `fn(&ext::Pub<u8>) {<ext::Pub<u8>>::priv_metod}` is private
18+
// error-pattern:type `fn(&ext::Pub<u8>) {<ext::Pub<u8>>::priv_method}` is private
1919

2020
#![feature(decl_macro)]
2121

src/test/compile-fail/private-inferred-type.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ mod m {
3737
pub const INHERENT_ASSOC_CONST_GENERIC_SELF: u8 = 0;
3838
}
3939
impl Pub<u8> {
40-
fn priv_metod(&self) {}
40+
fn priv_method(&self) {}
4141
pub fn method_with_substs<T>(&self) {}
4242
pub fn method_with_priv_params(&self, _: Priv) {}
4343
}
@@ -54,8 +54,8 @@ mod m {
5454
//~^ ERROR type `fn(u8) -> m::PrivTupleStruct {m::PrivTupleStruct::{{constructor}}}` is priv
5555
PubTupleStruct;
5656
//~^ ERROR type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct::{{constructor}}}` is privat
57-
Pub(0u8).priv_metod();
58-
//~^ ERROR type `fn(&m::Pub<u8>) {<m::Pub<u8>>::priv_metod}` is private
57+
Pub(0u8).priv_method();
58+
//~^ ERROR type `fn(&m::Pub<u8>) {<m::Pub<u8>>::priv_method}` is private
5959
}
6060

6161
trait Trait {}

0 commit comments

Comments
 (0)