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

Test main

Source location: tests/mir_typeck.rs:1394

fn main() -> () { require_marker::<S>; }
}])
tc_err(expect_test::expect![[r#"
error[E0277]: the trait bound `S: Marker` is not satisfied
  --> lib.rs
   |
13 |     require_marker::<S>;
   |                      ^ unsatisfied trait bound
   |
help: the trait `Marker` is not implemented for `S`
  --> lib.rs
   |
 3 | pub struct S {}
   | ^^^^^^^^^^^^
help: this trait has no implementations, consider adding one
  --> lib.rs
   |
 1 | pub trait Marker {}
   | ^^^^^^^^^^^^^^^^
note: required by a bound in `require_marker`
  --> lib.rs
   |
 5 | pub fn require_marker<T00>() -> ()
   |        -------------- required by a bound in this function
 6 | where
 7 |     T00: Marker,
   |          ^^^^^^ required by this bound in `require_marker`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `test` (lib) due to 1 previous error
)
(expect_test::expect![[r#"
the rule "trait implied bound" at (prove_predicate.rs) failed because
  expression evaluated to an empty collection: `decls.trait_invariants()`"#]]);
}

ing the same function is still rejected. The where-clauses are now
ked both for the function name and by the call.
#[test]
generic_fn_call_with_unsatisfied_where_clause() {
alityTest::new(crates![crate test {
trait Marker {}
struct S {}
fn require_marker<T>() -> () where T: Marker { trusted }
fn main() -> () { require_marker::<S>(); }
}])
tc_err(expect_test::expect![[r#"
error[E0277]: the trait bound `S: Marker` is not satisfied
  --> lib.rs
   |
13 |     require_marker::<S>();
   |                      ^ unsatisfied trait bound
   |
help: the trait `Marker` is not implemented for `S`
  --> lib.rs
   |
 3 | pub struct S {}
   | ^^^^^^^^^^^^
help: this trait has no implementations, consider adding one
  --> lib.rs
   |
 1 | pub trait Marker {}
   | ^^^^^^^^^^^^^^^^
note: required by a bound in `require_marker`
  --> lib.rs
   |
 5 | pub fn require_marker<T00>() -> ()
   |        -------------- required by a bound in this function
 6 | where
 7 |     T00: Marker,
   |          ^^^^^^ required by this bound in `require_marker`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `test` (lib) due to 1 previous error
)
(expect_test::expect![[r#"
the rule "trait implied bound" at (prove_predicate.rs) failed because
  expression evaluated to an empty collection: `decls.trait_invariants()`"#]]);
}

ng the function with a type that implements `Marker` is accepted.
#[test]
generic_fn_value_with_satisfied_where_clause() {
alityTest::new(crates![crate test {
trait Marker {}
impl Marker for u32 {}
fn require_marker<T>() -> () where T: Marker {}
fn main() -> () { require_marker::<u32>; }
}])
tc_ok()
);
}

#[test]
fn_value_with_forwarded_trait_bound() {
alityTest::new(crates![crate Foo {
trait Marker {}
impl Marker for u32 {}
fn require<T>() -> () where T: Marker {}
fn outer<T>() -> () where T: Marker { require::<T>; }
fn main() -> () { outer::<u32>(); }
}])
tc_ok()
);
}

#[test]
bare_fn_value_with_satisfied_where_clause() {
alityTest::new(crates![crate Foo {
trait Marker {}
impl Marker for u32 {}
fn require() -> () where u32: Marker {}
fn main() -> () { require; }
}])
tc_ok()
);
}

#[test]
fn_value_with_forwarded_lifetime_bound() {
alityTest::new(crates![crate Foo {
fn require<'a, 'b>() -> () where 'a: 'b {}
fn outer<'a, 'b>() -> () where 'a: 'b { require::<'a, 'b>; }
fn main() -> () { outer::<'static, 'static>(); }
}])
tc_ok()
);
}

#[test]
fn_value_with_unsatisfied_lifetime_bound() {
alityTest::new(crates![crate Foo {
fn require<'a, 'b>() -> () where 'a: 'b {}
fn outer<'a, 'b>() -> () { require::<'a, 'b>; }
fn main() -> () {}
}])
tc_err(expect_test::expect![[r#"
error: lifetime may not live long enough
 --> lib.rs
  |
7 | pub fn outer<'a00, 'a01>() -> () {
  |              ----  ---- lifetime `'a01` defined here
  |              |
  |              lifetime `'a00` defined here
8 |     require::<'a00, 'a01>;
  |     ^^^^^^^^^^^^^^^^^^^^^ requires that `'a00` must outlive `'a01`
  |
  = help: consider adding the following bound: `'a00: 'a01`

error: could not compile `Foo` (lib) due to 1 previous error
)
(expect_test::expect!["crates/formality-rust/src/prove/prove_outlives.rs:8:1: no applicable rules for prove_outlives { a: !lt_0, b: !lt_1, assumptions: {}, env: Env { variables: [!lt_0, !lt_1], bias: Soundness, pending: [], allow_pending_outlives: false } }"]);
}

ound assignment of an integer of a different type should fail.
#[test]
compound_add_mismatched_int_types() {
alityTest::new(crates![crate Foo {
fn foo() -> () {
    let x: u32 = 1_u32;
    x += 2_u8;
}

Rules proved (0)

This test records no positive coverage.

Premises failed (13)

The last column links to the premise’s page when the judgment view counts this failure against that premise. It does not when the premise is read as infallible, or when the failure was blamed inside a multi-line premise that carries no record on its own first line.

JudgmentRulePremiseAll tests of this premise
borrow_checkborrow_checkborrow_check_block(env, assumptions, state, bloc… (line 135)79 tests
borrow_check_blockbasic blockfor_all(i in 0..stmts.len()) with(env, state) (b… (line 156, blamed at line 157)not counted by the judgment view
borrow_check_statementexprborrow_check_expr( env, assumptions, state, expr… (line 232)26 tests
borrow_check_exprturbofishborrow_check_fn_ref(env, assumptions, state, id,… (line 566)6 tests
borrow_check_fn_reffn-refprove_where_clauses(env, assumptions, state, whe… (line 632)5 tests
check_free_fncheck free fncheck_fn(program, Env::default(), Predicates::t(… (line 24)81 tests
check_fncheck fnscope(enter_universally(env, &f.binder) => (env,… (line 48, blamed at line 54)not counted by the judgment view
check_fn_bodyexpr fn bodyborrow_check(typeck_env, assumptions, initial_st… (line 89)79 tests
check_all_cratescheck all prefixesfor_all(i in 0..crates.len()) (let program = cra… (line 52, blamed at line 54)not counted by the judgment view
check_cratecheck cratefor_all(item in &c.items) (check_crate_item(prog… (line 73, blamed at line 74)not counted by the judgment view
check_crate_itemfree fncheck_free_fn(program, f, crate_id) => () (line 207)81 tests
prove_predicatetrait implied boundti in decls.trait_invariants() (line 106)19 tests
prove_predicate_listsomeprove_predicate(decls, env, assumptions, wc0) =>… (line 26)67 tests

Proof trees

Failed proof tree

How to read this page