Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] rustc: check that type alias where clauses are well-formed. #54352

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
@@ -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)]
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
@@ -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) {
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
@@ -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
|
@@ -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`.