parent
08a1d45818
commit
a27f8cf8a3
|
@ -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) }))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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)]
|
||||
|
||||
|
|
|
@ -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 {}
|
||||
|
|
Loading…
Reference in New Issue