Skip to content

Commit 62f3343

Browse files
committed
rustc: check that type alias where clauses are well-formed.
1 parent ff6422d commit 62f3343

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/librustc_typeck/check/wfcheck.rs

+7
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def
124124
hir::ItemKind::Const(..) => {
125125
check_item_type(tcx, item);
126126
}
127+
hir::ItemKind::Ty(..) => {
128+
for_item(tcx, item).with_fcx(|fcx, _this| {
129+
let def_id = fcx.tcx.hir.local_def_id(item.id);
130+
check_where_clauses(tcx, fcx, item.span, def_id, None);
131+
vec![]
132+
});
133+
}
127134
hir::ItemKind::Struct(ref struct_def, ref ast_generics) => {
128135
check_type_defn(tcx, item, false, |fcx| {
129136
vec![fcx.non_enum_variant(struct_def)]

src/test/ui/feature-gates/feature-gate-trivial_bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ trait T where i32: Foo {} //~ ERROR
2525

2626
union U where i32: Foo { f: i32 } //~ ERROR
2727

28-
type Y where i32: Foo = (); // OK - bound is ignored
28+
type Y where i32: Foo = (); //~ ERROR
2929

3030
impl Foo for () where i32: Foo { //~ ERROR
3131
fn test(&self) {

src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr

+10-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ LL | union U where i32: Foo { f: i32 } //~ ERROR
3434
= help: see issue #48214
3535
= help: add #![feature(trivial_bounds)] to the crate attributes to enable
3636

37+
error[E0277]: the trait bound `i32: Foo` is not satisfied
38+
--> $DIR/feature-gate-trivial_bounds.rs:28:1
39+
|
40+
LL | type Y where i32: Foo = (); //~ ERROR
41+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `i32`
42+
|
43+
= help: see issue #48214
44+
= help: add #![feature(trivial_bounds)] to the crate attributes to enable
45+
3746
error[E0277]: the trait bound `i32: Foo` is not satisfied
3847
--> $DIR/feature-gate-trivial_bounds.rs:30:1
3948
|
@@ -125,6 +134,6 @@ LL | | }
125134
= help: see issue #48214
126135
= help: add #![feature(trivial_bounds)] to the crate attributes to enable
127136

128-
error: aborting due to 11 previous errors
137+
error: aborting due to 12 previous errors
129138

130139
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)