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

Judgment borrow_check_expr at crates/formality-rust/src/check/borrow_check/nll.rs:340

Signature:

borrow_check_expr(env: TypeckEnv, assumptions: Wcs, state: FlowState, expr: Expr, places_live_on_exit: LivePlaces,) => (Ty, FlowState)

The number on each rule’s conclusion is positive coverage; the number on each premise is negative coverage. Click a number to browse the tests.

assign
LineCoverageSource
353(borrow_check_expr(
env,
assumptions,
state,
expr,
Assignment(place).live_before(env, &state, places_live_on_exit),
) => (value_ty, state))
3622(borrow_check_place_expr(
env,
assumptions,
state,
place,
) => (place, state))
3701(prove_assignable(env, assumptions, state, value_ty, &place.ty) => state)
3728(access_permitted(
env,
assumptions,
state,
Access::new(AccessKind::Write, place),
places_live_on_exit,
) => state)
380N/A(let state = kill_loans(place, state))
381N/A(let state = state.with_initialized(&place.to_place_expression()))
──────── ("assign")
38313(borrow_check_expr(env, assumptions, state, Expr::Assign { place, expr }, places_live_on_exit) => (Ty::unit(), state))
call
LineCoverageSource
3883(borrow_check_expr(
env,
assumptions,
state,
callee,
args.live_before(env, &state, places_live),
) => (callee_ty, state))
397(prove_ty_is_rigid(env, assumptions, state, callee_ty) => (RigidTy { name: RigidName::FnDef(fn_id), parameters }, state))
400(let Fn { id: _, safety, binder } = env.crates().fn_named(fn_id)?)
402(ProvenSet::singleton((safety, ProofTree::leaf("safety"))) => Safety::Safe)
403(let FnBoundData { input_args, output_ty, where_clauses, body: _ } =
binder.instantiate_with(parameters)?)
407N/A(let input_tys: Vec<Ty> = input_args.iter().map(|a| a.ty.clone()).collect())
4081(if input_tys.len() == args.len())
410(for_all(i in 0..args.len()) with(state)
(borrow_check_expr_has_ty(env, assumptions, state, &args[i], &input_tys[i], places_live) => state))
413(prove_where_clauses(env, assumptions, state, where_clauses) => state)
──────── ("call")
41514(borrow_check_expr(env, assumptions, state, Expr::Call { callee, args }, places_live) => (output_ty, state))
literal
LineCoverageSource
──────── ("literal")
42048(borrow_check_expr(_env, _assumptions, state, Expr::Literal { value: _, ty }, _places_live_on_exit) => (ty, state))
true
LineCoverageSource
──────── ("true")
42513(borrow_check_expr(_env, _assumptions, state, Expr::True, _places_live_on_exit) => (ScalarId::Bool, state))
false
LineCoverageSource
──────── ("false")
4306(borrow_check_expr(_env, _assumptions, state, Expr::False, _places_live_on_exit) => (ScalarId::Bool, state))
ref
LineCoverageSource
434(borrow_check_place_expr(
env,
assumptions,
state,
place,
) => (place, state))
442N/A(let access_kind = match kind {
RefKind::Shared => AccessKind::Read,
RefKind::Mut => AccessKind::Write,
})
4461(access_permitted(
env,
assumptions,
state,
Access::new(access_kind, place),
places_live_on_exit,
) => state)
455N/A(let state = state.with_loan(Loan::new(lt, place, kind)))
456N/A(let ty = place.ty.ref_ty_of_kind(kind, lt))
──────── ("ref")
45817(borrow_check_expr(env, assumptions, state, Expr::Ref { kind, lt, place }, places_live_on_exit) => (ty, state))
place
LineCoverageSource
4622(borrow_check_place_expr(env, assumptions, state, place) => (place, state))
463(access_kind_for_place_use(env, assumptions, state, place) => (access_kind, state))
46411(access_permitted(env, assumptions, state, Access::new(access_kind, place), places_live_on_exit) => state)
465N/A(let state = if matches!(access_kind, AccessKind::Move) { state.with_uninit(&place.to_place_expression()) } else { state.clone() })
4662(prove_place_is_movable(env, assumptions, state, place) => state)
──────── ("place")
46856(borrow_check_expr(env, assumptions, state, Expr::Place(place), places_live_on_exit) => (&place.ty, state))
fn-name
LineCoverageSource
474(if let PlaceExpr::Var(id) = place)
475(if !state.has_local(id))
4761(let fn_decl = env.crates().fn_named(id)?)
4771(if fn_decl.binder.len() == 0)
478N/A(let ty = Ty::rigid(RigidName::fn_def(id), ()))
──────── ("fn-name")
4817(borrow_check_expr(env, _assumptions, state, Expr::Place(place), _places_live_on_exit) => (ty, state))
turbofish
LineCoverageSource
486(let fn_decl = env.crates().fn_named(id)?)
4871(if fn_decl.binder.len() == args.len())
488N/A(let ty = Ty::rigid(RigidName::fn_def(id), args))
──────── ("turbofish")
4918(borrow_check_expr(env, _assumptions, state, Expr::Turbofish { id, args }, _places_live_on_exit) => (ty, state))
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))