Skip to content

Commit

Permalink
rustc: check that type alias where clauses are well-formed.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Sep 19, 2018
1 parent ff6422d commit 62f3343
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def
hir::ItemKind::Const(..) => {
check_item_type(tcx, item);
}
hir::ItemKind::Ty(..) => {
for_item(tcx, item).with_fcx(|fcx, _this| {
let def_id = fcx.tcx.hir.local_def_id(item.id);
check_where_clauses(tcx, fcx, item.span, def_id, None);
vec![]
});
}
hir::ItemKind::Struct(ref struct_def, ref ast_generics) => {
check_type_defn(tcx, item, false, |fcx| {
vec![fcx.non_enum_variant(struct_def)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/feature-gates/feature-gate-trivial_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait T where i32: Foo {} //~ ERROR

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

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

impl Foo for () where i32: Foo { //~ ERROR
fn test(&self) {
Expand Down
11 changes: 10 additions & 1 deletion src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ LL | union U where i32: Foo { f: i32 } //~ ERROR
= help: see issue #48214
= help: add #![feature(trivial_bounds)] to the crate attributes to enable

error[E0277]: the trait bound `i32: Foo` is not satisfied
--> $DIR/feature-gate-trivial_bounds.rs:28:1
|
LL | type Y where i32: Foo = (); //~ ERROR
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `i32`
|
= help: see issue #48214
= help: add #![feature(trivial_bounds)] to the crate attributes to enable

error[E0277]: the trait bound `i32: Foo` is not satisfied
--> $DIR/feature-gate-trivial_bounds.rs:30:1
|
Expand Down Expand Up @@ -125,6 +134,6 @@ LL | | }
= help: see issue #48214
= help: add #![feature(trivial_bounds)] to the crate attributes to enable

error: aborting due to 11 previous errors
error: aborting due to 12 previous errors

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

0 comments on commit 62f3343

Please sign in to comment.