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: borrow_check_expr / struct

struct
LineCoverageSource
5111(let Struct { id: _, binder } = env.crates().struct_named(&adt_id)?)
512(if turbofish.parameters.len() == binder.len())
513(let StructBoundData { where_clauses, fields } = binder.instantiate_with(&turbofish.parameters)?)
516N/A(let expected_names: Set<&FieldName> = fields.iter().map(|f| &f.name).collect())
517N/A(let provided_names: Set<&FieldName> = field_exprs.iter().map(|fe| &fe.name).collect())
518(if expected_names == provided_names)
521(for_all(i in 0..field_exprs.len()) with(state)
(field in fields)
(if field.name == field_exprs[i].name)
(borrow_check_expr_has_ty(env, assumptions, state, &field_exprs[i].value, &field.ty, places_live_on_exit) => state))
526(prove_where_clauses(env, assumptions, state, where_clauses) => state)
528N/A(let ty = RigidTy::new(adt_id, &turbofish.parameters))
──────── ("struct")
5307(borrow_check_expr(env, assumptions, state, Expr::Struct { adt_id, turbofish, field_exprs }, places_live_on_exit) => (ty, state))

7 tests exercised this rule:


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: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 tree
… (200 of 1068 nodes shown)

Source location: tests/codegen.rs:264

fn main() -> () {
    let w: Wrapper<i32> = Wrapper::<i32> { val: 42 _ i32 };
    println!(w.val);
}
Proof tree
… (200 of 1048 nodes shown)

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;
}
Proof tree
… (200 of 1079 nodes shown)

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 };
    }
}
Proof tree
… (200 of 1082 nodes shown)