Skip to content

Commit 3e0cdb6

Browse files
committed
Correct span in privacy error
1 parent 126db54 commit 3e0cdb6

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

src/librustc/middle/privacy.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,13 +1261,13 @@ impl<'a, 'tcx> VisiblePrivateTypesVisitor<'a, 'tcx> {
12611261
}
12621262

12631263
fn check_ty_param_bound(&self,
1264-
span: Span,
12651264
ty_param_bound: &ast::TyParamBound) {
12661265
if let ast::TraitTyParamBound(ref trait_ref) = *ty_param_bound {
12671266
if !self.tcx.sess.features.borrow().visible_private_types &&
12681267
self.path_is_private_type(trait_ref.trait_ref.ref_id) {
1268+
let span = trait_ref.trait_ref.path.span;
12691269
self.tcx.sess.span_err(span,
1270-
"private type in exported type \
1270+
"private trait in exported type \
12711271
parameter bound");
12721272
}
12731273
}
@@ -1311,7 +1311,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
13111311
}
13121312

13131313
for bound in bounds.iter() {
1314-
self.check_ty_param_bound(item.span, bound)
1314+
self.check_ty_param_bound(bound)
13151315
}
13161316
}
13171317

@@ -1449,14 +1449,14 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
14491449
fn visit_generics(&mut self, generics: &ast::Generics) {
14501450
for ty_param in generics.ty_params.iter() {
14511451
for bound in ty_param.bounds.iter() {
1452-
self.check_ty_param_bound(ty_param.span, bound)
1452+
self.check_ty_param_bound(bound)
14531453
}
14541454
}
14551455
for predicate in generics.where_clause.predicates.iter() {
14561456
match predicate {
14571457
&ast::WherePredicate::BoundPredicate(ref bound_pred) => {
14581458
for bound in bound_pred.bounds.iter() {
1459-
self.check_ty_param_bound(bound_pred.span, bound)
1459+
self.check_ty_param_bound(bound)
14601460
}
14611461
}
14621462
&ast::WherePredicate::EqPredicate(ref eq_pred) => {

src/test/compile-fail/visible-private-types-generics.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@
1010

1111
trait Foo {}
1212

13-
pub fn f<T:Foo>() {} //~ ERROR private type in exported type
13+
pub fn f<
14+
T
15+
: Foo //~ ERROR private trait in exported type parameter bound
16+
>() {}
1417

15-
pub fn g<T>() where T: Foo {} //~ ERROR private type in exported type
16-
17-
pub struct H<T:Foo> { //~ ERROR private type in exported type
18-
x: T,
19-
}
20-
21-
pub struct I<T> where T: Foo { //~ ERROR private type in exported type
22-
x: T,
23-
}
18+
pub fn g<T>() where
19+
T
20+
: Foo //~ ERROR private trait in exported type parameter bound
21+
{}
2422

2523
fn main() {}
26-

src/test/compile-fail/visible-private-types-supertrait.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
trait Foo {}
1212

13-
pub trait Bar : Foo {} //~ ERROR private type in exported type
13+
pub trait Bar : Foo {} //~ ERROR private trait in exported type
1414

1515
fn main() {}
16-

0 commit comments

Comments
 (0)