Skip to content

Commit 2c04475

Browse files
Rollup merge of #39149 - circuitfox:E0122-type-def-trait-bounds-where-clause, r=arielb1
E0122 should apply with where clauses Fixes #39122
2 parents 4603c0e + 5c58653 commit 2c04475

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

src/librustc_typeck/collect.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,16 @@ fn ensure_no_ty_param_bounds(ccx: &CrateCtxt,
716716
}
717717
}
718718

719+
for predicate in generics.where_clause.predicates.iter() {
720+
match *predicate {
721+
hir::WherePredicate::BoundPredicate(..) => {
722+
warn = true;
723+
}
724+
hir::WherePredicate::RegionPredicate(..) => { }
725+
hir::WherePredicate::EqPredicate(..) => { }
726+
}
727+
}
728+
719729
if warn {
720730
// According to accepted RFC #XXX, we should
721731
// eventually accept these, but it will not be

src/test/compile-fail/issue-17994.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
// except according to those terms.
1010

1111
trait Tr {}
12-
type Huh<T> where T: Tr = isize; //~ ERROR type parameter `T` is unused
12+
type Huh<T> where T: Tr = isize; //~ ERROR type parameter `T` is unused
13+
//~| WARNING E0122
1314
fn main() {}

src/test/compile-fail/issue-39122.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
type Foo<T: std::ops::Add> = T; //~ WARNING E0122
12+
13+
type Bar<T> where T: std::ops::Add = T; //~ WARNING E0122

src/test/compile-fail/private-in-public-warn.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ mod traits_where {
8989
pub type Alias<T> where T: PrivTr = T;
9090
//~^ ERROR private trait `traits_where::PrivTr` in public interface
9191
//~| WARNING hard error
92+
//~| WARNING E0122
9293
pub trait Tr2<T> where T: PrivTr {}
9394
//~^ ERROR private trait `traits_where::PrivTr` in public interface
9495
//~| WARNING hard error

0 commit comments

Comments
 (0)