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: prove_wc / trait well formed

trait well formed
LineCoverageSource
1391(for_all(decls, env, assumptions, &trait_ref.parameters, &prove_wf) => c)
140N/A(let t = decls.trait_decl(&trait_ref.trait_id))
141N/A(let t = t.binder.instantiate_with(&trait_ref.parameters).unwrap())
1422(prove_after(decls, c, assumptions, &t.where_clause) => c)
──────── ("trait well formed")
14419(prove_wc(decls, env, assumptions, Predicate::WellFormedTraitRef(trait_ref)) => c)

19 tests exercised this rule:


Source location: tests/basic_tests.rs:58

#[test]
fn hello_world() {
    FormalityTest::new(crates![crate Foo {
        trait Foo<T> where T: Bar<Self>, Self: Baz {}

        trait Bar<T> where T: Baz {}

        trait Baz {}

        impl Baz for u32 {}

        impl Bar<u32> for u32 {}
        impl<T> Bar<T> for () where T: Baz {}
    }])
    .skip_execute()
    .ok()
}
Proof tree
… (200 of 1245 nodes shown)

Source location: tests/basic_tests.rs:74

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

        trait B { }

        trait WellFormed where for<T> u32: A<T> { }

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

Source location: tests/basic_tests.rs:121

fn foo() -> () where for<T> u32: A<T> { trusted }

impl <T> B for T {}
}])
p_execute()
)
}

#[test]
ifetime_binder_in_fn_where_clause_fail() {
alityTest::new(crates![crate core {
trait A<T> where T: B { }

trait B { }

fn foo() -> () where for<T> u32: A<T> { trusted }
}])
(expect_test::expect![[r#"
the rule "check crate" at (mod.rs) failed because
  non lifetime binders require #![feature(non_lifetime_binders)]"#]])
}

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

trait B { }

impl<T> B for T where for<U> u32: A<U> { }
}])
p_execute()
)
}

#[test]
ifetime_binder_in_trait_impl_where_clause_fail() {
alityTest::new(crates![crate core {
trait A<T> where T: B { }

trait B { }

impl<T> B for T where for<U> u32: A<U> { }
}])
(expect_test::expect![[r#"
the rule "check crate" at (mod.rs) failed because
  non lifetime binders require #![feature(non_lifetime_binders)]"#]])
}

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

trait B { }

impl<T> !A<T> for u32 where for<U> u32: A<U> { }

impl <T> B for T {}
}])
p_execute()
)
}

#[test]
ifetime_binder_in_neg_trait_impl_where_clause_fail() {
alityTest::new(crates![crate core {
trait A<T> where T: B { }

trait B { }

impl<T> !A<T> for u32 where for<U> u32: A<U> { }
}])
(expect_test::expect![[r#"
the rule "check crate" at (mod.rs) failed because
  non lifetime binders require #![feature(non_lifetime_binders)]"#]])
}

#[test]
ifetime_binder_in_enum_where_clause_pass() {
alityTest::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 {}
}])
p_execute()
)
}

#[test]
ifetime_binder_in_enum_where_clause_fail() {
alityTest::new(crates![crate core {
trait A<T> where T: B { }

trait B { }

enum E where for<U> u32: A<U> { }
}])
(expect_test::expect![[r#"
the rule "check crate" at (mod.rs) failed because
  non lifetime binders require #![feature(non_lifetime_binders)]"#]])
}

#[test]
ifetime_binder_in_struct_where_clause_pass() {
alityTest::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 {}
}])
p_execute()
)
}

#[test]
ifetime_binder_in_struct_where_clause_fail() {
alityTest::new(crates![crate core {
trait A<T> where T: B { }

trait B { }

struct S<T> where for<U> u32: A<U> { }
}])
(expect_test::expect![[r#"
the rule "check crate" at (mod.rs) failed because
  non lifetime binders require #![feature(non_lifetime_binders)]"#]])
}

#[test]
ime_binder_in_where_clause_without_feature_pass() {
alityTest::new(crates![crate core {
trait A<'b> { }

impl<'b> A<'b> for u32 { }

trait WellFormed where for<'b> u32: A<'b> { }
}])
p_execute()
)
}

#[test]
_adt_variant_dup() {
alityTest::new(crates![crate Foo {
enum Bar {
    Baz{},
    Baz{},
}
Proof tree

Source location: tests/basic_tests.rs:149

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

        trait B { }

        impl<T> B for T where for<U> u32: A<U> { }
    }])
    .skip_execute()
    .ok()
}
Proof tree

Source location: tests/basic_tests.rs:179

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

        trait B { }

        impl<T> !A<T> for u32 where for<U> u32: A<U> { }

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

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

#[test]
fn lifetime_binder_in_where_clause_without_feature_pass() {
    FormalityTest::new(crates![crate core {
        trait A<'b> { }

        impl<'b> A<'b> for u32 { }

        trait WellFormed where for<'b> u32: A<'b> { }
    }])
    .skip_execute()
    .ok()
}
Proof tree

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()
}
Proof tree

Source location: tests/coherence_overlap.rs:206

#[test]
fn u32_T_where_T_Not_impls() {
    FormalityTest::new(crates![crate core {
        trait Foo {}
        impl Foo for u32 {}
        impl<T> Foo for T where T: Not {}

        trait Not {}
    }])
    .skip_execute()
    .ok()
}
Proof tree

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

Proof trees omitted for the remaining 9 tests.


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: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/mir_typeck.rs:729

fn foo<'a, T>(v1: &'a T) -> T
where
    T: Copy,
    T: 'a,
{
    exists<'r0> {
        let v2: T = *v1;
        return v2;
    }
}

Source location: tests/references.rs:36


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