Skip to content

Commit c2a8e23

Browse files
committed
put all ignored bounds into the span, not just the first
1 parent 9410a67 commit c2a8e23

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

src/librustc_lint/builtin.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1414,19 +1414,21 @@ impl IgnoredGenericBounds {
14141414
match param {
14151415
&ast::GenericParam::Lifetime(ref lifetime) => {
14161416
if !lifetime.bounds.is_empty() {
1417+
let spans : Vec<_> = lifetime.bounds.iter().map(|b| b.span).collect();
14171418
cx.span_lint(
14181419
IGNORED_GENERIC_BOUNDS,
1419-
lifetime.bounds[0].span,
1420+
spans,
14201421
format!("bounds on generic lifetime parameters are ignored in {}",
14211422
thing).as_ref()
14221423
);
14231424
}
14241425
}
14251426
&ast::GenericParam::Type(ref ty) => {
14261427
if !ty.bounds.is_empty() {
1428+
let spans : Vec<_> = ty.bounds.iter().map(|b| b.span()).collect();
14271429
cx.span_lint(
14281430
IGNORED_GENERIC_BOUNDS,
1429-
ty.bounds[0].span(),
1431+
spans,
14301432
format!("bounds on generic type parameters are ignored in {}", thing)
14311433
.as_ref()
14321434
);
@@ -1442,8 +1444,9 @@ impl EarlyLintPass for IgnoredGenericBounds {
14421444
match item.node {
14431445
ast::ItemKind::Ty(_, ref generics) => {
14441446
if !generics.where_clause.predicates.is_empty() {
1445-
cx.span_lint(IGNORED_GENERIC_BOUNDS,
1446-
generics.where_clause.predicates[0].span(),
1447+
let spans : Vec<_> = generics.where_clause.predicates.iter()
1448+
.map(|pred| pred.span()).collect();
1449+
cx.span_lint(IGNORED_GENERIC_BOUNDS, spans,
14471450
"where clauses are ignored in type aliases");
14481451
}
14491452
IgnoredGenericBounds::ensure_no_param_bounds(cx, &generics.params,

src/test/ui/param-bounds-ignored.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
use std::rc::Rc;
1515

16-
type SVec<T: Send> = Vec<T>;
16+
type SVec<T: Send+Send> = Vec<T>;
1717
//~^ WARN bounds on generic type parameters are ignored in type aliases
18-
type VVec<'b, 'a: 'b> = Vec<&'a i32>;
18+
type VVec<'b, 'a: 'b+'b> = Vec<&'a i32>;
1919
//~^ WARN bounds on generic lifetime parameters are ignored in type aliases
20-
type WVec<'b, T: 'b> = Vec<T>;
20+
type WVec<'b, T: 'b+'b> = Vec<T>;
2121
//~^ WARN bounds on generic type parameters are ignored in type aliases
22-
type W2Vec<'b, T> where T: 'b = Vec<T>;
22+
type W2Vec<'b, T> where T: 'b, T: 'b = Vec<T>;
2323
//~^ WARN where clauses are ignored in type aliases
2424

2525
fn foo<'a>(y: &'a i32) {

src/test/ui/param-bounds-ignored.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
warning: bounds on generic type parameters are ignored in type aliases
22
--> $DIR/param-bounds-ignored.rs:16:14
33
|
4-
16 | type SVec<T: Send> = Vec<T>;
5-
| ^^^^
4+
16 | type SVec<T: Send+Send> = Vec<T>;
5+
| ^^^^ ^^^^
66
|
77
= note: #[warn(ignored_generic_bounds)] on by default
88

99
warning: bounds on generic lifetime parameters are ignored in type aliases
1010
--> $DIR/param-bounds-ignored.rs:18:19
1111
|
12-
18 | type VVec<'b, 'a: 'b> = Vec<&'a i32>;
13-
| ^^
12+
18 | type VVec<'b, 'a: 'b+'b> = Vec<&'a i32>;
13+
| ^^ ^^
1414

1515
warning: bounds on generic type parameters are ignored in type aliases
1616
--> $DIR/param-bounds-ignored.rs:20:18
1717
|
18-
20 | type WVec<'b, T: 'b> = Vec<T>;
19-
| ^^
18+
20 | type WVec<'b, T: 'b+'b> = Vec<T>;
19+
| ^^ ^^
2020

2121
warning: where clauses are ignored in type aliases
2222
--> $DIR/param-bounds-ignored.rs:22:25
2323
|
24-
22 | type W2Vec<'b, T> where T: 'b = Vec<T>;
25-
| ^^^^^
24+
22 | type W2Vec<'b, T> where T: 'b, T: 'b = Vec<T>;
25+
| ^^^^^ ^^^^^
2626

2727
warning: bounds on generic lifetime parameters are ignored in higher-ranked function types (i.e., `for`)
2828
--> $DIR/param-bounds-ignored.rs:43:22

0 commit comments

Comments
 (0)