Repository: rust-lang/rust
File: src/tools/rust-analyzer/crates/hir-ty/src/layout/tests.rs (Rust)

Code before:
        })
        .unwrap();
    let hir_body = db.body(function_id.into());
    let b = hir_body
        .bindings()
        .find(|x| x.1.name.display_no_db(file_id.edition(&db)).to_smolstr() == "goal")
        .unwrap()
        .0;
    let infer = db.infer(function_id.into());
    let goal_ty = infer.type_of_binding[b].clone();
    salsa::attach(&db, || {
        let interner = DbInterner::new_with(&db, None, None);
        db.layout_of_ty(goal_ty.to_nextsolver(interner), db.trait_environment(function_id.into()))
    })
}

#[track_caller]
fn check_size_and_align(
    #[rust_analyzer::rust_fixture] ra_fixture: &str,
    minicore: &str,
    size: u64,
    align: u64,
) {
    let l = eval_goal(ra_fixture, minicore).unwrap();
    assert_eq!(l.size.bytes(), size, "size mismatch");
    assert_eq!(l.align.abi.bytes(), align, "align mismatch");
}

#[track_caller]
fn check_size_and_align_expr(
    #[rust_analyzer::rust_fixture] ra_fixture: &str,
    minicore: &str,
    size: u64,
    align: u64,
) {
    let l = eval_expr(ra_fixture, minicore).unwrap();
    assert_eq!(l.size.bytes(), size, "size mismatch");
    assert_eq!(l.align.abi.bytes(), align, "align mismatch");
}

#[track_caller]
fn check_fail(#[rust_analyzer::rust_fixture] ra_fixture: &str, e: LayoutError) {
    let r = eval_goal(ra_fixture, "");
    assert_eq!(r, Err(e));
}

macro_rules! size_and_align {
    (minicore: $($x:tt),*;$($t:tt)*) => {
        {
            #![allow(dead_code)]
            $($t)*

Review comment (bug):
Remark: From a review perspective it's unclear whether these rust-analyzer changes are intended/accurate (and not just a find-replace mishap), but they seem plausible and I guess CI would complain if they were broken, so it seems fine to rubber-stamp them.

Code after:
        })
        .unwrap();
    let hir_body = db.body(function_id.into());
    let b = hir_body
        .bindings()
        .find(|x| x.1.name.display_no_db(file_id.edition(&db)).to_smolstr() == "goal")
        .unwrap()
        .0;
    let infer = db.infer(function_id.into());
    let goal_ty = infer.type_of_binding[b].clone();
    salsa::attach(&db, || {
        let interner = DbInterner::new_with(&db, None, None);
        db.layout_of_ty(goal_ty.to_nextsolver(interner), db.trait_environment(function_id.into()))
    })
}

#[track_caller]
fn check_size_and_align(
    #[rust_analyzer::rust_fixture] ra_fixture: &str,
    minicore: &str,
    size: u64,
    align: u64,
) {
    let l = eval_goal(ra_fixture, minicore).unwrap();
    assert_eq!(l.size.bytes(), size, "size mismatch");
    assert_eq!(l.align.bytes(), align, "align mismatch");
}

#[track_caller]
fn check_size_and_align_expr(
    #[rust_analyzer::rust_fixture] ra_fixture: &str,
    minicore: &str,
    size: u64,
    align: u64,
) {
    let l = eval_expr(ra_fixture, minicore).unwrap();
    assert_eq!(l.size.bytes(), size, "size mismatch");
    assert_eq!(l.align.bytes(), align, "align mismatch");
}

#[track_caller]
fn check_fail(#[rust_analyzer::rust_fixture] ra_fixture: &str, e: LayoutError) {
    let r = eval_goal(ra_fixture, "");
    assert_eq!(r, Err(e));
}

macro_rules! size_and_align {
    (minicore: $($x:tt),*;$($t:tt)*) => {
        {
            #![allow(dead_code)]
            $($t)*