about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSeo Sanghyeon <sanxiyn@gmail.com>2014-12-17 23:23:20 +0900
committerSeo Sanghyeon <sanxiyn@gmail.com>2014-12-17 23:23:20 +0900
commit3e0cdb63391af29ef83050f1b08a4232911f81f3 (patch)
treef59e70af5d3851364dfdb7b83996d5cf8d25de86 /src
parent126db549b038c84269a1e4fe46f051b2c15d6970 (diff)
downloadrust-3e0cdb63391af29ef83050f1b08a4232911f81f3.tar.gz
rust-3e0cdb63391af29ef83050f1b08a4232911f81f3.zip
Correct span in privacy error
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/privacy.rs10
-rw-r--r--src/test/compile-fail/visible-private-types-generics.rs19
-rw-r--r--src/test/compile-fail/visible-private-types-supertrait.rs3
3 files changed, 14 insertions, 18 deletions
diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs
index 8cce1321d72..2ec65424163 100644
--- a/src/librustc/middle/privacy.rs
+++ b/src/librustc/middle/privacy.rs
@@ -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) => {
diff --git a/src/test/compile-fail/visible-private-types-generics.rs b/src/test/compile-fail/visible-private-types-generics.rs
index 740848e93cb..397ac5373bb 100644
--- a/src/test/compile-fail/visible-private-types-generics.rs
+++ b/src/test/compile-fail/visible-private-types-generics.rs
@@ -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() {}
-
diff --git a/src/test/compile-fail/visible-private-types-supertrait.rs b/src/test/compile-fail/visible-private-types-supertrait.rs
index c4457aaf1e1..dc6d446154a 100644
--- a/src/test/compile-fail/visible-private-types-supertrait.rs
+++ b/src/test/compile-fail/visible-private-types-supertrait.rs
@@ -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() {}
-