Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Fix regressions after rebase
  • Loading branch information
petrochenkov committed Jul 6, 2017
1 parent 08a1d45 commit a27f8cf
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/libproc_macro/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }))
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/auxiliary/private-inferred-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -40,5 +40,5 @@ pub macro m() {
<u8 as PubTrait>::method;
PrivTupleStruct;
PubTupleStruct;
Pub(0u8).priv_metod();
Pub(0u8).priv_method();
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/private-inferred-type-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Expand Down
6 changes: 3 additions & 3 deletions src/test/compile-fail/private-inferred-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
}
Expand All @@ -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 {}
Expand Down

0 comments on commit a27f8cf

Please sign in to comment.