Correct span in privacy error

This commit is contained in:
Seo Sanghyeon 2014-12-17 23:23:20 +09:00
parent 126db549b0
commit 3e0cdb6339
3 changed files with 14 additions and 18 deletions

View File

@ -1261,13 +1261,13 @@ impl<'a, 'tcx> VisiblePrivateTypesVisitor<'a, 'tcx> {
}
fn check_ty_param_bound(&self,
span: Span,
ty_param_bound: &ast::TyParamBound) {
if let ast::TraitTyParamBound(ref trait_ref) = *ty_param_bound {
if !self.tcx.sess.features.borrow().visible_private_types &&
self.path_is_private_type(trait_ref.trait_ref.ref_id) {
let span = trait_ref.trait_ref.path.span;
self.tcx.sess.span_err(span,
"private type in exported type \
"private trait in exported type \
parameter bound");
}
}
@ -1311,7 +1311,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
}
for bound in bounds.iter() {
self.check_ty_param_bound(item.span, bound)
self.check_ty_param_bound(bound)
}
}
@ -1449,14 +1449,14 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
fn visit_generics(&mut self, generics: &ast::Generics) {
for ty_param in generics.ty_params.iter() {
for bound in ty_param.bounds.iter() {
self.check_ty_param_bound(ty_param.span, bound)
self.check_ty_param_bound(bound)
}
}
for predicate in generics.where_clause.predicates.iter() {
match predicate {
&ast::WherePredicate::BoundPredicate(ref bound_pred) => {
for bound in bound_pred.bounds.iter() {
self.check_ty_param_bound(bound_pred.span, bound)
self.check_ty_param_bound(bound)
}
}
&ast::WherePredicate::EqPredicate(ref eq_pred) => {

View File

@ -10,17 +10,14 @@
trait Foo {}
pub fn f<T:Foo>() {} //~ ERROR private type in exported type
pub fn f<
T
: Foo //~ ERROR private trait in exported type parameter bound
>() {}
pub fn g<T>() where T: Foo {} //~ ERROR private type in exported type
pub struct H<T:Foo> { //~ ERROR private type in exported type
x: T,
}
pub struct I<T> where T: Foo { //~ ERROR private type in exported type
x: T,
}
pub fn g<T>() where
T
: Foo //~ ERROR private trait in exported type parameter bound
{}
fn main() {}

View File

@ -10,7 +10,6 @@
trait Foo {}
pub trait Bar : Foo {} //~ ERROR private type in exported type
pub trait Bar : Foo {} //~ ERROR private trait in exported type
fn main() {}