Test recursive_struct_is_not_sized
Source location: tests/sized_trait.rs:436
#[test]
fn recursive_struct_is_not_sized() {
// `Sized` is inductive, so the cycle through `next` doesn't prove `List: Sized`.
// rustc rejects the struct itself (E0072), which formality doesn't check.
FormalityTest::new(crates![crate Foo {
struct List { next: List }
trait Needs<T> where T: Sized {}
impl Needs<List> for u32 {}
}])
.rustc_err(expect_test::expect![[r#"
error[E0072]: recursive type `List` has infinite size
--> lib.rs
|
1 | pub struct List {
| ^^^^^^^^^^^^^^^
2 | pub next: List,
| ---- recursive without indirection
|
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
2 | pub next: Box<List>,
| ++++ +
For more information about this error, try `rustc --explain E0072`.
error: could not compile `Foo` (lib) due to 1 previous error
"#]])
.err(expect_test::expect![[r#"
the rule "trait implied bound" at (prove_predicate.rs) failed because
expression evaluated to an empty collection: `decls.trait_invariants()`
the rule "trait implied bound" at (prove_predicate.rs) failed because
expression evaluated to an empty collection: `decls.trait_invariants()`"#]]);
}
Rules proved (0)
This test records no positive coverage.
Premises failed (8)
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.
| Judgment | Rule | Premise | All tests of this premise |
|---|---|---|---|
| check_trait_impl | check_trait_impl | scope(enter_universally(Env::default(), binder) … (line 23, blamed at line 28) | not counted by the judgment view |
| check_all_crates | check all prefixes | for_all(i in 0..crates.len()) (let program = cra… (line 52, blamed at line 54) | not counted by the judgment view |
| check_crate | check crate | for_all(item in &c.items) (check_crate_item(prog… (line 74, blamed at line 75) | not counted by the judgment view |
| check_crate_item | trait impl | check_trait_impl(program, v, crate_id) => () (line 195) | 23 tests |
| prove_after | prove_after | prove(decls, c1.env(), assumptions, goal) => c2 (line 19) | 28 tests |
| prove_predicate | positive impl | scope(enter_existentially_with_constraints(decls… (line 61, blamed at line 79) | not counted by the judgment view |
| prove_predicate | trait implied bound | ti in decls.trait_invariants() (line 115) | 28 tests |
| prove_predicate_list | some | prove_predicate(decls, env, assumptions, wc0) =>… (line 26) | 92 tests |
Proof trees
Failed proof tree
check_all_crates failedmod.rs:42args
rule "check all prefixes"mod.rs:54check_crate failedmod.rs:61args
rule "check crate"mod.rs:75check_crate_item failedmod.rs:180rule "trait impl"mod.rs:195check_trait_impl failedimpls.rs:14rule "check_trait_impl"impls.rs:28prove failedfunction.rs:250args
rulefunction.rs:250prove_predicate_list failedprove_predicate_list.rs:8args
rule "some"prove_predicate_list.rs:26prove_predicate failedprove_predicate.rs:23args
rule "positive impl"prove_predicate.rs:79prove_after failedprove_after.rs:8args
rule "prove_after"prove_after.rs:19prove failedprove_after.rs:19args
ruleprove_after.rs:19prove_predicate_list failedprove_predicate_list.rs:8args
rule "some"prove_predicate_list.rs:26prove_predicate failedprove_predicate.rs:23args
rule "trait implied bound"prove_predicate.rs:115 (failed: empty_collection)
rule "trait implied bound"prove_predicate.rs:115 (failed: empty_collection)