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

Negative coverage: check_safety_matches / safety matches / premise if trait_decl.safety == trait_impl.safety

Premise at line 84. Observed failure causes: if_false.

safety matches
LineCoverageSource
842(if trait_decl.safety == trait_impl.safety)
──────── ("safety matches")
86127(check_safety_matches(trait_decl, trait_impl) => ())

2 tests failed proving this premise:


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

#[test]
fn unsafe_trait_mismatch() {
    FormalityTest::new(crates![crate baguette {
        unsafe trait Foo {}
        impl Foo for u32 {}
    }])
    .rustc_err(expect_test::expect![[r#"
        error[E0200]: the trait `Foo` requires an `unsafe impl` declaration
         --> lib.rs
          |
        3 | impl Foo for u32 {}
          | ^^^^^^^^^^^^^^^^
          |
          = note: the trait `Foo` enforces invariants that the compiler can't check. Review the trait documentation and make sure this implementation upholds those invariants before adding the `unsafe` keyword
        help: add `unsafe` to this trait implementation
          |
        3 | unsafe impl Foo for u32 {}
          | ++++++

        For more information about this error, try `rustc --explain E0200`.
        error: could not compile `baguette` (lib) due to 1 previous error
    "#]])
    .err(expect_test::expect![[r#"
            the rule "safety matches" at (impls.rs) failed because
              condition evaluated to false: `trait_decl.safety == trait_impl.safety`"#]])
}
Failed proof tree

Source location: tests/decl_safety.rs:138 (all coverage from this test)

#[test]
fn safe_trait_mismatch() {
    FormalityTest::new(crates![crate baguette {
        trait Foo {}
        unsafe impl Foo for u32 {}
    }])
    .rustc_err(expect_test::expect![[r#"
        error[E0199]: implementing the trait `Foo` is not unsafe
         --> lib.rs
          |
        3 | unsafe impl Foo for u32 {}
          | ^^^^^^^^^^^^^^^^^^^^^^^
          |
        help: remove `unsafe` from this trait implementation
          |
        3 - unsafe impl Foo for u32 {}
        3 + impl Foo for u32 {}
          |

        For more information about this error, try `rustc --explain E0199`.
        error: could not compile `baguette` (lib) due to 1 previous error
    "#]])
    .err(expect_test::expect![[r#"
            the rule "safety matches" at (impls.rs) failed because
              condition evaluated to false: `trait_decl.safety == trait_impl.safety`"#]])
}
Failed proof tree