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, Relation::well_formed(ty)) => ())))
──────── ("check adt")
2831(check_adt(program, adt) => ())

31 tests exercised this rule:


Source location: tests/basic_tests.rs:209

#[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

#[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:426

Proof tree

Source location: tests/borrowck.rs:113

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 1117 nodes shown)

Source location: tests/borrowck.rs:253

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 1154 nodes shown)

Source location: tests/borrowck.rs:1968

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

Source location: tests/borrowck.rs:2156

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

Source location: tests/borrowck.rs:2277

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

Source location: tests/borrowck.rs:2733

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

Source location: tests/borrowck.rs:2976

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

Source location: tests/codegen.rs:141

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

Proof trees omitted for the remaining 21 tests.


Source location: tests/codegen.rs:264

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

Source location: tests/coherence_orphan.rs:84

#[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:98

#[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:196

#[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:147

#[test]
fn neg_CoreTrait_for_CoreStruct_implies_no_overlap() {
    FormalityTest::new(crates![crate core {
        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:307

#[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

#[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

#[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

#[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

#[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/field_projections.rs:17

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

Source location: tests/mir_typeck.rs:234

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:250

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

Source location: tests/mir_typeck.rs:857

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

Source location: tests/references.rs:36


Source location: tests/well_formed_struct.rs:17

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

#[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

#[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

#[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

#[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()
}