Skip to content

Commit bafd6f3

Browse files
scalexmnikomatsakis
authored andcommitted
Remove WF checks for struct fields
1 parent 7e39323 commit bafd6f3

File tree

2 files changed

+3
-51
lines changed

2 files changed

+3
-51
lines changed

src/lower/mod.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -918,13 +918,11 @@ impl ir::StructDatum {
918918
fn to_program_clauses(&self, program: &ir::Program) -> Vec<ir::ProgramClause> {
919919
// Given:
920920
//
921-
// struct Foo<T: Eq> {
922-
// field: Bar
923-
// }
921+
// struct Foo<T: Eq> { }
924922
//
925923
// we generate the following clause:
926924
//
927-
// for<?T> WF(Foo<?T>) :- WF(?T), WF(Bar), (?T: Eq), WF(?T: Eq).
925+
// for<?T> WF(Foo<?T>) :- WF(?T), (?T: Eq), WF(?T: Eq).
928926

929927
let wf = ir::ProgramClause {
930928
implication: self.binders.map_ref(|bound_datum| {
@@ -939,17 +937,12 @@ impl ir::StructDatum {
939937
.cloned()
940938
.map(|ty| ir::WellFormed::Ty(ty).cast());
941939

942-
let fields = bound_datum.fields
943-
.iter()
944-
.cloned()
945-
.map(|ty| ir::WellFormed::Ty(ty).cast());
946-
947940
let where_clauses = bound_datum.where_clauses.iter()
948941
.cloned()
949942
.flat_map(|wc| wc.expanded(program))
950943
.map(|wc| wc.cast());
951944

952-
tys.chain(fields).chain(where_clauses).collect()
945+
tys.chain(where_clauses).collect()
953946
}
954947
}
955948
}),

src/solve/test.rs

-41
Original file line numberDiff line numberDiff line change
@@ -700,47 +700,6 @@ fn struct_wf() {
700700
}
701701
}
702702

703-
#[test]
704-
fn struct_with_fields_wf() {
705-
test! {
706-
program {
707-
struct Foo { }
708-
709-
struct Bar {
710-
f: Foo
711-
}
712-
713-
trait Clone { }
714-
struct Dummy<T> where T: Clone { }
715-
impl Clone for Foo { }
716-
717-
struct Baz<T> {
718-
f: Dummy<T>
719-
}
720-
}
721-
722-
goal {
723-
WellFormed(Bar)
724-
} yields {
725-
"Unique"
726-
}
727-
728-
// `Bar` does not implement `Clone` so `Dummy<Bar>` is ill-formed
729-
goal {
730-
WellFormed(Baz<Bar>)
731-
} yields {
732-
"No possible solution"
733-
}
734-
735-
// This time `Foo` does implement `Clone`
736-
goal {
737-
WellFormed(Baz<Foo>)
738-
} yields {
739-
"Unique"
740-
}
741-
}
742-
}
743-
744703
#[test]
745704
fn generic_trait() {
746705
test! {

0 commit comments

Comments
 (0)