Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Positive coverage: check_adt / check adt

check adt
LineCoverageSource
182(check_adt_variant_names_unique(adt) => ())
19N/A(let (env, bound_data) = Env::default().instantiate_universally(&adt.binder))
20N/A(let AdtBoundData { where_clauses, variants } = bound_data)
211(prove_where_clauses_well_formed(program, env, where_clauses, where_clauses) => ())
22(for_all(variant in variants)
(let Variant { fields, .. } = variant)
(for_all(field in fields)
(let Field { ty, .. } = field)
(prove_goal(program, env, where_clauses, Predicate::well_formed(ty)) => ())))
──────── ("check adt")
2845(check_adt(program, adt) => ())

45 tests exercised this rule:


Source location: tests/basic_tests.rs:209 (all coverage from this test)

#[test]
fn non_lifetime_binder_in_enum_where_clause_pass() {
    FormalityTest::new(crates![crate core {
        #![feature(non_lifetime_binders)]
        trait A<T> where T: B { }

        trait B { }

        enum E where for<U> u32: A<U> { }

        impl <T> B for T {}
    }])
    .skip_execute()
    .ok()
}
Proof tree

Source location: tests/basic_tests.rs:239 (all coverage from this test)

#[test]
fn non_lifetime_binder_in_struct_where_clause_pass() {
    FormalityTest::new(crates![crate core {
        #![feature(non_lifetime_binders)]
        trait A<T> where T: B { }

        trait B { }

        struct S<T> where for<U> u32: A<U> { }

        impl <T> B for T {}
    }])
    .skip_execute()
    .ok()
}
Proof tree

Source location: tests/basic_tests.rs:457 (all coverage from this test)

Proof tree

Source location: tests/borrowck.rs:131 (all coverage from this test)

fn foo() -> Datum {
    let x: Datum = Datum { value: 0_u32 };
    let y: Datum = x;
    x = Datum { value: 1_u32 };
    let z: Datum = x;
    return z;
}
Proof tree
… (200 of 1119 nodes shown)

Source location: tests/borrowck.rs:412 (all coverage from this test)

fn foo() -> Datum {
    let x: Pair = Pair {
        first: Datum { value: 1_u32 },
        second: Datum { value: 2_u32 },
    };
    let a: Datum = x.first;
    let b: Datum = x.second;
    return b;
}
Proof tree
… (200 of 1156 nodes shown)

Source location: tests/borrowck.rs:2158 (all coverage from this test)

fn min_problem_case_3<'a>(m: &'a mut Map) -> &'a mut Map {
    exists<'r0, 'r1> {
        let n: &'r0 mut Map = &'r0 mut *m;
        if true {
            return n;
        } else {
            let o: &'r1 mut Map = &'r1 mut *m;
            return o;
        }
    }
}
Proof tree
… (200 of 1350 nodes shown)

Source location: tests/borrowck.rs:2378 (all coverage from this test)

fn min_problem_case_3<'a>(m: &'a mut Map) -> &'a mut Map {
    exists<'r0, 'r1> {
        let n: &'r0 mut Map = &'r0 mut *m;
        if true {
        } else {
        }
        let o: &'r1 mut Map = &'r1 mut *m;
        return o;
    }
}
Proof tree
… (200 of 1321 nodes shown)

Source location: tests/borrowck.rs:2499 (all coverage from this test)

fn min_problem_case_4<'a>(list: &'a mut Map, list2: &'a mut Map) -> u32 {
    exists<'r0> {
        let num: &'r0 mut u32 = &'r0 mut (*list).value;
        list = &'a mut *list2;
        num;
        return 0_u32;
    }
}
Proof tree
… (200 of 1282 nodes shown)

Source location: tests/borrowck.rs:2960 (all coverage from this test)

fn foo<'a>(m: &'a mut Map) -> &'a mut Map {
    exists<'r0, 'r1> {
        let n: &'r0 mut Map = &'r0 mut *m;
        if false {
            return n;
        } else {
            let o: &'r1 mut Map = &'r1 mut *m;
            return o;
        }
    }
}
Proof tree
… (200 of 1350 nodes shown)

Source location: tests/borrowck.rs:3240 (all coverage from this test)

fn foo() -> u32 {
    exists<'r0, 'r1, 'r2, 'r3> {
        let p: Point = Point { x: 0_u32, y: 0_u32 };
        let b1: &'r0 mut u32 = &'r1 mut p.x;
        let b2: &'r2 mut u32 = &'r3 mut p.y;
        *b1 = 1_u32;
        *b2 = 2_u32;
        return 0_u32;
    }
}
Proof tree
… (200 of 1340 nodes shown)

Source location: tests/borrowck.rs:3808 (all coverage from this test)

fn remove_last_node_recursive<'a>(node: &'a mut List) -> u32 {
    exists<'r0> {
        let next: &'r0 mut List = next_of::<'r0>(&'r0 mut *node);
        if true {
            remove_last_node_recursive::<'r0>(next);
        } else {
            *node = List { value: 0_u32 };
        }
        return 0_u32;
    }
}

Proof trees omitted for the remaining 35 tests; each one is on its test’s page in Coverage by test.


Source location: tests/borrowck.rs:3855 (all coverage from this test)

fn remove_last_node_iterative<'a>(node: &'a mut List) -> u32 {
    exists<'r0, 'r1> {
        let cursor: &'r0 mut List = &'r0 mut *node;
        'l: loop {
            let next: &'r1 mut List = &'r1 mut *cursor;
            if true {
                cursor = next;
            } else {
                break 'l;
            }
        }
        *cursor = List { value: 0_u32 };
        return 0_u32;
    }
}

Source location: tests/borrowck.rs:3917 (all coverage from this test)

fn no_control_flow() -> u32 {
    exists<'r0, 'r1, 'r2, 'r3> {
        let b: X = X { value: 0_u32 };
        let p: &'r0 mut X = &'r1 mut b;
        'l: loop {
            let now: &'r2 mut X = &'r2 mut *p;
            if true {
                let next: &'r3 mut X = next_of::<'r3>(&'r3 mut *now);
                p = next;
            } else {
                break 'l;
            }
        }
        return 0_u32;
    }
}

Source location: tests/borrowck.rs:3967 (all coverage from this test)

fn conditional() -> u32 {
    exists<'r0, 'r1, 'r2, 'r3> {
        let b: X = X { value: 0_u32 };
        let p: &'r0 mut X = &'r1 mut b;
        'l: loop {
            let now: &'r2 mut X = &'r2 mut *p;
            if true {
                if true {
                    let next: &'r3 mut X = next_of::<'r3>(&'r3 mut *now);
                    p = next;
                } else {
                }
            } else {
                break 'l;
            }
        }
        return 0_u32;
    }
}

Source location: tests/borrowck.rs:4056 (all coverage from this test)

fn conditional_with_indirection() -> u32 {
    exists<'r0, 'r1, 'r2, 'r3> {
        let b: X = X { value: 0_u32 };
        let p: &'r0 mut X = &'r1 mut b;
        'l: loop {
            let now: &'r2 mut X = &'r2 mut *p;
            if true {
                if true {
                    let next: &'r3 mut X = next_of::<'r3>(&'r3 mut *p);
                    p = next;
                } else {
                }
            } else {
                break 'l;
            }
        }
        return 0_u32;
    }
}

Source location: tests/borrowck.rs:4108 (all coverage from this test)

fn to_refs<'a>(list: &'a mut List) -> &'a mut u32 {
    exists<'r0, 'r1> {
        let result: &'a mut u32;
        'l: loop {
            result = &'r0 mut (*list).value;
            if true {
                let n: &'r1 mut List = next_from_field::<'r1>(&'r1 mut (*list).next);
                list = n;
            } else {
                return result;
            }
        }
    }
}

Source location: tests/borrowck.rs:4143 (all coverage from this test)

fn to_refs2<'a>(list: &'a mut List) -> &'a mut u32 {
    exists<'r0, 'r1> {
        let result: &'a mut u32;
        'l: loop {
            result = &'r0 mut (*list).value;
            if true {
                let n: &'r1 mut List = next_from_field::<'r1>(&'r1 mut (*list).next);
                list = n;
            } else {
                break 'l;
            }
        }
        return result;
    }
}

Source location: tests/borrowck.rs:4190 (all coverage from this test)

fn to_refs3<'a>(list: &'a mut List) -> &'a mut u32 {
    exists<'r0, 'r1> {
        let result: &'a mut u32;
        let cursor: &'a mut List = &'a mut *list;
        'l: loop {
            result = &'r0 mut (*cursor).value;
            if true {
                let n: &'r1 mut List = next_from_field::<'r1>(&'r1 mut (*cursor).next);
                cursor = n;
            } else {
                return result;
            }
        }
    }
}

Source location: tests/borrowck.rs:4233 (all coverage from this test)

fn next<'a>(d: &'a mut Decoder) -> &'a u32 {
    exists<'r0, 'r1> {
        'l: loop {
            let buf: &'r0 u32 = fill_buf::<'r0>(&'r0 mut (*d).buf_read);
            let s: &'r1 u32 = decode::<'r1>(buf);
            if true {
                return s;
            } else {
            }
        }
    }
}

Source location: tests/borrowck.rs:4356 (all coverage from this test)

fn next<'s>(f: &'s mut Filter) -> &'s mut u32 {
    exists<'r0, 'r1, 'r2> {
        'l: loop {
            let item: &'r0 mut u32 = iter_next::<'r0>(&'r0 mut (*f).iter);
            if true {
                let keep: bool = call_predicate::<'r1, 'r2>(&'r1 mut (*f).predicate, &'r2 *item);
                if keep {
                    return item;
                } else {
                }
            } else {
                break 'l;
            }
        }
        return no_item::<'s>();
    }
}

Source location: tests/borrowck.rs:4472 (all coverage from this test)

fn use_it<'a, 'b>() -> u32 {
    exists<'r0> {
        let v: Invariant<'r0> = create_invariant::<'r0>();
        if true {
            return sink::<'a, 'r0>(v);
        } else {
            return sink::<'b, 'r0>(v);
        }
    }
}

Source location: tests/borrowck.rs:4537 (all coverage from this test)

fn use_it_but_its_the_same_region<'a, 'b>() -> u32 where 'a: 'b, 'b: 'a {
    exists<'r0> {
        let v: Invariant<'r0> = create_invariant::<'r0>();
        if true {
            return sink::<'a, 'r0>(v);
        } else {
            return sink::<'b, 'r0>(v);
        }
    }
}

Source location: tests/codegen.rs:141 (all coverage from this test)

fn main() -> () {
    let p: Pair = Pair { x: 10_i32, y: 20_i32 };
    println!(p.x);
    println!(p.y);
}

Source location: tests/codegen.rs:264 (all coverage from this test)

fn main() -> () {
    let w: Wrapper<i32> = Wrapper::<i32> { val: 42_i32 };
    println!(w.val);
}

Source location: tests/coherence_orphan.rs:85 (all coverage from this test)

#[test]
fn mirror_FooStruct() {
    FormalityTest::new(crates![crate core {
        trait CoreTrait {}

        trait Mirror {
            type Assoc : [];
        }

        impl<T> Mirror for T {
            type Assoc = T;
        }
    },
    crate foo {
        struct FooStruct {}
        impl CoreTrait for <FooStruct as Mirror>::Assoc {}
    }])
    .skip_execute()
    .ok()
}

Source location: tests/coherence_orphan.rs:99 (all coverage from this test)

#[test]
fn covered_VecT() {
    FormalityTest::new(crates![crate core {
        trait CoreTrait<T> {}
        struct Vec<T> {}
    },
    crate foo {
        struct FooStruct {}
        impl<T> CoreTrait<FooStruct> for Vec<T> {}
    }])
    .skip_execute()
    .ok()
}

Source location: tests/coherence_orphan.rs:221 (all coverage from this test)

#[test]
fn CoreTraitLocal_for_AliasToKnown_in_Foo() {
    // TODO: see comment in `orphan_check` from prev commit
    FormalityTest::new(crates![crate core {
        trait CoreTrait<T> {}

        trait Unit {
            type Assoc : [];
        }

        impl<T> Unit for T {
            type Assoc = ();
        }
    },
    crate foo {
        struct FooStruct {}
        impl CoreTrait<FooStruct> for <() as Unit>::Assoc {}
    }])
    .skip_execute()
    .ok()
}

Source location: tests/coherence_overlap.rs:148 (all coverage from this test)

#[test]
fn neg_CoreTrait_for_CoreStruct_implies_no_overlap() {
    FormalityTest::new(crates![crate core {
        #![feature(negative_impls)]
        trait CoreTrait {}
        struct CoreStruct {}
        impl !CoreTrait for CoreStruct {}
    },
    crate foo {
        trait FooTrait {}
        impl<T> FooTrait for T where T: CoreTrait {}
        impl FooTrait for CoreStruct {}
    }])
    .skip_execute()
    .ok()
}

Source location: tests/coherence_overlap.rs:308 (all coverage from this test)

#[test]
fn is_local_unknowable_trait_ref() {
    FormalityTest::new(crates![crate core {
        trait Project {
            type Assoc: [];
        }

        impl<T> Project for T {
            type Assoc = T;
        }

        trait Foo<U> { }
    },
    crate foo {
        struct LocalType {}

        trait Overlap<U> {}
        impl<T, U> Overlap<U> for T
        where
            <T as Project>::Assoc: Foo<U> {}
        impl<T> Overlap<LocalType> for () {}
    }])
    .skip_execute()
    .ok()
}

Source location: tests/drop.rs:20 (all coverage from this test)

#[test]
fn drop_impl_simple_struct() {
    FormalityTest::new(crates![
        crate Foo {
            struct MyStruct {
                value: u32,
            }

            impl Drop for MyStruct {}
        }
    ])
    .skip_execute()
    .ok()
}

Source location: tests/drop.rs:38 (all coverage from this test)

#[test]
fn drop_impl_generic_struct() {
    FormalityTest::new(crates![
        crate Foo {
            trait Clone {}

            struct MyStruct<T> where T: Clone {
                value: T,
            }

            impl<T> Drop for MyStruct<T> where T: Clone {}
        }
    ])
    .skip_execute()
    .ok()
}

Source location: tests/drop.rs:54 (all coverage from this test)

#[test]
fn drop_impl_generic_no_where_clauses() {
    FormalityTest::new(crates![
        crate Foo {
            struct Wrapper<T> {
                value: T,
            }

            impl<T> Drop for Wrapper<T> {}
        }
    ])
    .skip_execute()
    .ok()
}

Source location: tests/drop.rs:78 (all coverage from this test)

#[test]
fn drop_impl_subset_where_clauses() {
    FormalityTest::new(crates![
        crate Foo {
            trait Clone {}
            trait Debug {}

            struct MyStruct<T> where T: Clone, T: Debug {
                value: T,
            }

            // Impl has no where-clauses — but the struct requires them.
            impl<T> Drop for MyStruct<T> {}
        }
    ])
    .skip_execute()
    .ok()
}

Source location: tests/drop.rs:94 (all coverage from this test)

#[test]
fn drop_impl_enum() {
    FormalityTest::new(crates![
        crate Foo {
            enum MyEnum {
                Variant{},
            }

            impl Drop for MyEnum {}
        }
    ])
    .skip_execute()
    .ok()
}

Source location: tests/drop.rs:111 (all coverage from this test)

#[test]
fn drop_impl_cross_crate_local() {
    FormalityTest::new(crates![
        crate a {
            struct MyStruct {
                value: u32,
            }

            impl Drop for MyStruct {}
        },
        crate b {}
    ])
    .skip_execute()
    .ok()
}

Source location: tests/field_projections.rs:17 (all coverage from this test)

fn test(ptr: Ptr) -> () {
    let x: () = *ptr;
}

Source location: tests/mir_typeck.rs:259 (all coverage from this test)

fn foo (v1: u32) -> u32 {
    let v2: Dummy = Dummy { value: 1_u32, is_true: false };
    v2.value = 2_u32;
    return v1;
}

Source location: tests/mir_typeck.rs:276 (all coverage from this test)

fn foo() -> () {
    let s1: S1<u8>;
}

Source location: tests/mir_typeck.rs:1116 (all coverage from this test)

fn foo<'a>(v1: &'a Pair) -> u32 {
    exists<'r0> {
        let v2: u32 = (*v1).value;
        return v2;
    }
}

Source location: tests/references.rs:36 (all coverage from this test)


Source location: tests/well_formed_struct.rs:17 (all coverage from this test)

fn main() -> () {
    exists<'y> {
        let a: u32 = 22_u32;
        let f: Foo<'y> = Foo::<'y> { y: &'y a };
    }
}

Source location: tests/well_formed_trait_ref.rs:19 (all coverage from this test)

#[test]
fn dependent_where_clause() {
    FormalityTest::new(crates![crate foo {
        trait Trait1 {}

        trait Trait2 {}

        struct S1<T> where T: Trait1 {
            dummy: T,
        }

        struct S2<T> where T: Trait1, S1<T> : Trait2 {
            dummy: T,
        }
    }])
    .skip_execute()
    .ok()
}

Source location: tests/well_formed_trait_ref.rs:56 (all coverage from this test)

#[test]
fn lifetime_param() {
    FormalityTest::new(crates![crate foo {
        trait Trait1<'a> {}

        struct S1 {}

        struct S2<'a> where S1: Trait1<'a> {}
    }])
    .skip_execute()
    .ok()
}

Source location: tests/well_formed_trait_ref.rs:71 (all coverage from this test)

#[test]
fn static_lifetime_param() {
    FormalityTest::new(crates![crate foo {
        trait Trait1<'a> {}

        struct S1 {}

        impl Trait1<'static> for S1 {}

        struct S2 where S1: Trait1<'static> {}
    }])
    .skip_execute()
    .ok()
}

Source location: tests/well_formed_trait_ref.rs:86 (all coverage from this test)

#[test]
fn const_param() {
    FormalityTest::new(crates![crate foo {
        trait Trait1<const C> where type_of_const C is u32 {}

        struct S1 {}

        impl Trait1<u32(3)> for S1 {}

        struct S2 where S1: Trait1<u32(3)> {}
    }])
    .skip_execute()
    .ok()
}