ronantakizawa/codereview-bench huggingface dataset:
Repository: rust-lang/rust
File: compiler/rustc_expand/src/errors.rs (Rust)

Code before:
}

#[derive(Subdiagnostic)]
#[label("argument not found")]
pub(crate) struct VarTypoSuggestionUnrepeatable {
    #[primary_span]
    pub span: Span,
}

#[derive(Subdiagnostic)]
#[label("this similarly named macro argument is unrepeatable")]
pub(crate) struct VarTypoSuggestionUnrepeatableLabel {
    #[primary_span]
    pub span: Span,
}

#[derive(Subdiagnostic)]
#[label("expected one of repeatable variables arguments: {$msg}")]
pub(crate) struct VarNoTypo {
    #[primary_span]
    pub span: Span,
    pub msg: String,
}

#[derive(Subdiagnostic)]
#[label("variable is not repeatable and there are no repeatable variable arguments")]
pub(crate) struct NoRepeatableVar {
    #[primary_span]
    pub span: Span,
}

#[derive(Diagnostic)]
#[diag("this must repeat at least once")]
pub(crate) struct MustRepeatOnce {
    #[primary_span]
    pub span: Span,
}

#[derive(Diagnostic)]
#[diag("`count` can not be placed inside the innermost repetition")]
pub(crate) struct CountRepetitionMisplaced {
    #[primary_span]
    pub span: Span,
}

#[derive(Diagnostic)]
#[diag("variable `{$ident}` is still repeating at this depth")]
pub(crate) struct MacroVarStillRepeating {
    #[primary_span]
    pub span: Span,
    pub ident: MacroRulesNormalizedIdent,

Review comment (suggestion):
```suggestion
#[label("this macro metavariable is not repeatable and there are no other repeatable metavariables")]
```

Code after:
}

#[derive(Subdiagnostic)]
#[label("argument not found")]
pub(crate) struct VarTypoSuggestionUnrepeatable {
    #[primary_span]
    pub span: Span,
}

#[derive(Subdiagnostic)]
#[label("this similarly named macro metavariable is unrepeatable")]
pub(crate) struct VarTypoSuggestionUnrepeatableLabel {
    #[primary_span]
    pub span: Span,
}

#[derive(Subdiagnostic)]
#[label("expected a repeatable metavariable: {$msg}")]
pub(crate) struct VarNoTypo {
    #[primary_span]
    pub span: Span,
    pub msg: String,
}

#[derive(Subdiagnostic)]
#[label(
    "this macro metavariable is not repeatable and there are no other repeatable metavariables"
)]
pub(crate) struct NoRepeatableVar {
    #[primary_span]
    pub span: Span,
}

#[derive(Diagnostic)]
#[diag("this must repeat at least once")]
pub(crate) struct MustRepeatOnce {
    #[primary_span]
    pub span: Span,
}

#[derive(Diagnostic)]
#[diag("`count` can not be placed inside the innermost repetition")]
pub(crate) struct CountRepetitionMisplaced {
    #[primary_span]
    pub span: Span,
}

#[derive(Diagnostic)]
#[diag("variable `{$ident}` is still repeating at this depth")]
pub(crate) struct MacroVarStillRepeating {
    #[primary_span]
Repository: rust-lang/rust
File: compiler/rustc_middle/src/query/plumbing.rs (Rust)

Code before:

    use super::{DefId, LocalDefId, OwnerId};

    /// An analogue of the `Into` trait that's intended only for certain query keys.
    ///
    /// This lets queries with `DefId` or `LocalDefId` keys be called with closely-related types
    /// without requiring an explicit conversion, as a mild conveniences for common cases.
    pub trait IntoQueryParam<P> {
        fn into_query_param(self) -> P;
    }

    // This blanket impl provides a no-op "conversion" for all non-`DefId`/`LocalDefId` types.
    impl<P> IntoQueryParam<P> for P {
        #[inline(always)]
        fn into_query_param(self) -> P {
            self
        }
    }

    #[allow(rustc::pass_by_value)]
    impl IntoQueryParam<DefId> for &DefId {
        #[inline(always)]
        fn into_query_param(self) -> DefId {
            *self
        }
    }

    impl IntoQueryParam<LocalDefId> for OwnerId {
        #[inline(always)]
        fn into_query_param(self) -> LocalDefId {
            self.def_id
        }
    }

    impl IntoQueryParam<DefId> for LocalDefId {
        #[inline(always)]
        fn into_query_param(self) -> DefId {
            self.to_def_id()
        }
    }

    impl IntoQueryParam<DefId> for OwnerId {
        #[inline(always)]
        fn into_query_param(self) -> DefId {
            self.to_def_id()
        }
    }

    impl IntoQueryParam<DefId> for ModDefId {
        #[inline(always)]
        fn into_query_param(self) -> DefId {

Review comment (suggestion):
As a follow-up to this PR, I'd be in favour of adjusting all callers and getting rid of the `&DefId` impl completely.

Code after:
    use rustc_hir::def_id::{LocalModDefId, ModDefId};

    use super::{DefId, LocalDefId, OwnerId};

    /// An analogue of the `Into` trait that's intended only for query parameters.
    ///
    /// This exists to allow queries to accept either `DefId` or `LocalDefId` while requiring that the
    /// user call `to_def_id` to convert between them everywhere else.
    pub trait IntoQueryParam<P> {
        fn into_query_param(self) -> P;
    }

    impl<P> IntoQueryParam<P> for P {
        #[inline(always)]
        fn into_query_param(self) -> P {
            self
        }
    }

    impl<'a, P: Copy> IntoQueryParam<P> for &'a P {
        #[inline(always)]
        fn into_query_param(self) -> P {
            *self
        }
    }

    impl IntoQueryParam<LocalDefId> for OwnerId {
        #[inline(always)]
        fn into_query_param(self) -> LocalDefId {
            self.def_id
        }
    }

    impl IntoQueryParam<DefId> for LocalDefId {
        #[inline(always)]
        fn into_query_param(self) -> DefId {
            self.to_def_id()
        }
    }

    impl IntoQueryParam<DefId> for OwnerId {
        #[inline(always)]
        fn into_query_param(self) -> DefId {
            self.to_def_id()
        }
    }

    impl IntoQueryParam<DefId> for ModDefId {
        #[inline(always)]
        fn into_query_param(self) -> DefId {
            self.to_def_id()
Repository: rust-lang/rust
File: src/ci/docker/scripts/stage_2_test_set2.sh (Shell)

Code before:
#!/bin/bash

set -ex

# Run a subset of tests. Used to run tests in parallel in multiple jobs.

# When this job partition is run as part of PR CI, skip tidy to allow revealing more failures. The
# dedicated `tidy` job failing won't block other PR CI jobs from completing, and so tidy failures
# shouldn't inhibit revealing other failures in PR CI jobs.
if [[ -z "${PR_CI_JOB}" ]]; then
  SKIP_TIDY="--skip tidy"
else
  SKIP_TIDY=
fi

../x.py --stage 2 test \
  ${SKIP_TIDY:+"$SKIP_TIDY1"} \
  --skip tests \
  --skip coverage-map \
  --skip coverage-run \
  --skip library \
  --skip tidyselftest


Review comment (suggestion):
Remark: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Parameter-Expansion

> `${parameter:+word}`
>
> If parameter is null or unset, nothing is substituted, otherwise the expansion of word is substituted. The value of parameter is not used.

Code after:
#!/bin/bash

set -ex

# Run a subset of tests. Used to run tests in parallel in multiple jobs.

# When this job partition is run as part of PR CI, skip tidy to allow revealing more failures. The
# dedicated `tidy` job failing won't block other PR CI jobs from completing, and so tidy failures
# shouldn't inhibit revealing other failures in PR CI jobs.
if [ "$PR_CI_JOB" == "1" ]; then
  echo "PR_CI_JOB set; skipping tidy"
  SKIP_TIDY="--skip tidy"
fi

../x.py --stage 2 test \
  ${SKIP_TIDY:+$SKIP_TIDY} \
  --skip tests \
  --skip coverage-map \
  --skip coverage-run \
  --skip library \
  --skip tidyselftest
Repository: rust-lang/rust
File: tests/codegen-llvm/abi-noundef-cast.rs (Rust)

Code before:
// CHECK-SAME: i64 noundef
#[no_mangle]
pub fn arg_single_variant_enum(v: SingleVariant) -> u32 {
    match v {
        SingleVariant::Only(a) => a[0],
    }
}

// CHECK-LABEL: @arg_maybeuninit_u8x8(
// CHECK-SAME: i64 %
#[no_mangle]
pub fn arg_maybeuninit_u8x8(v: [MaybeUninit<u8>; 8]) -> MaybeUninit<u8> {
    v[0]
}

#[repr(C)]
struct HasPadding {
    x: u32,
    y: u16,
    z: u8,
}

// CHECK-LABEL: @arg_struct_with_padding(
// CHECK-SAME: i64 %
#[no_mangle]
pub fn arg_struct_with_padding(v: HasPadding) -> u32 {
    v.x
}


Review comment (suggestion):
Please add more tests for when the annotation is *not* added. That's the soundness-critical case after all! Some cases that should definitely be covered:
- `(i8, i16)`
-  `(i16, MaybeUninit<i16>)`
- `(MaybeUninit<i8>, MaybeUninit<i8>, MaybeUninit<i8>)`
- `Result<i32, i32>`

Feel free to come up with more.

Code after:
#[no_mangle]
pub fn arg_struct_undef_pair_field(v: HasUndefPairField) -> u32 {
    v.b
}

// CHECK-LABEL: @arg_triple_maybeuninit_u8(
// CHECK-SAME: i24 %
#[no_mangle]
pub fn arg_triple_maybeuninit_u8(
    v: (MaybeUninit<u8>, MaybeUninit<u8>, MaybeUninit<u8>),
) -> MaybeUninit<u8> {
    v.0
}

#[repr(C)]
struct HasTrailingPadding {
    x: u32,
    y: u16,
    z: u8,
}

// CHECK-LABEL: @arg_struct_trailing_pad(
// CHECK-SAME: i64 %
#[no_mangle]
pub fn arg_struct_trailing_pad(v: HasTrailingPadding) -> u32 {
    v.x
}

// CHECK-LABEL: @arg_tuple_i8_i16(
// CHECK-SAME: i8 noundef
// CHECK-SAME: i16 noundef
#[no_mangle]
pub fn arg_tuple_i8_i16(v: (i8, i16)) -> i8 {
    v.0
}

// CHECK-LABEL: @arg_tuple_i16_maybeuninit(
// CHECK-SAME: i16 noundef
// CHECK-SAME: i16 %
#[no_mangle]
pub fn arg_tuple_i16_maybeuninit(v: (i16, MaybeUninit<i16>)) -> i16 {
    v.0
}

// CHECK-LABEL: @arg_result_i32(
// CHECK-SAME: i32 noundef
// CHECK-SAME: i32 noundef
#[no_mangle]
pub fn arg_result_i32(v: Result<i32, i32>) -> i32 {
    match v {
        Ok(x) | Err(x) => x,
Repository: rust-lang/rust
File: library/core/src/bstr/mod.rs (Rust)

Code before:
                if !chunk.invalid().is_empty() {
                    f.write_str("\u{FFFD}")?;
                }
            }
            Ok(())
        }

        let nchars: usize = self
            .utf8_chunks()
            .map(|chunk| {
                chunk.valid().chars().count() + if chunk.invalid().is_empty() { 0 } else { 1 }
            })
            .sum();

        let padding = f.width().unwrap_or(0).saturating_sub(nchars);
        let fill = f.fill();

        let Some(align) = f.align() else {
            fmt_nopad(self, f)?;
            for _ in 0..padding {
                write!(f, "{fill}")?;
            }
            return Ok(());
        };

        let (lpad, rpad) = match align {
            fmt::Alignment::Left => (0, padding),
            fmt::Alignment::Right => (padding, 0),
            fmt::Alignment::Center => {
                let half = padding / 2;
                (half, half + padding % 2)
            }
        };
        for _ in 0..lpad {
            write!(f, "{fill}")?;
        }
        fmt_nopad(self, f)?;
        for _ in 0..rpad {
            write!(f, "{fill}")?;
        }

        Ok(())
    }
}

#[unstable(feature = "bstr", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl const AsRef<[u8]> for ByteStr {
    #[inline]
    fn as_ref(&self) -> &[u8] {
        &self.0

Review comment (suggestion):
I'd match on `f.align()` directly and merge the `else` path with the `Alignment::Left` branch. Then you can also inline `fmt_nopad` since it'll only be used below.

Code after:
                chunk.valid().chars().count() + if chunk.invalid().is_empty() { 0 } else { 1 }
            })
            .sum();

        let padding = f.width().unwrap_or(0).saturating_sub(nchars);
        let fill = f.fill();

        let (lpad, rpad) = match f.align() {
            Some(fmt::Alignment::Right) => (padding, 0),
            Some(fmt::Alignment::Center) => {
                let half = padding / 2;
                (half, half + padding % 2)
            }
            // Either alignment is not specified or it's left aligned
            // which behaves the same with padding
            _ => (0, padding),
        };

        for _ in 0..lpad {
            write!(f, "{fill}")?;
        }

        for chunk in self.utf8_chunks() {
            f.write_str(chunk.valid())?;
            if !chunk.invalid().is_empty() {
                f.write_str("\u{FFFD}")?;
            }
        }

        for _ in 0..rpad {
            write!(f, "{fill}")?;
        }

        Ok(())
    }
}

#[unstable(feature = "bstr", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl const AsRef<[u8]> for ByteStr {
    #[inline]
    fn as_ref(&self) -> &[u8] {
        &self.0
    }
}

#[unstable(feature = "bstr", issue = "134915")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl const AsRef<ByteStr> for ByteStr {
    #[inline]
    fn as_ref(&self) -> &ByteStr {
Repository: rust-lang/rust
File: src/tools/tidy/src/diagnostics.rs (Rust)

Code before:
}

/// Collects diagnostics from all tidy steps, and contains shared information
/// that determines how should message and logs be presented.
///
/// Since checks are executed in parallel, the context is internally synchronized, to avoid
/// all checks to lock it explicitly.
#[derive(Clone)]
pub struct TidyCtx {
    tidy_flags: TidyFlags,
    diag_ctx: Arc<Mutex<DiagCtxInner>>,
    ci_env: CiEnv,
    pub base_commit: Option<String>,
}

impl TidyCtx {
    pub fn new(
        root_path: &Path,
        verbose: bool,
        ci_flag: Option<bool>,
        tidy_flags: TidyFlags,
    ) -> Self {
        let ci_env = match ci_flag {
            Some(true) => CiEnv::GitHubActions,
            Some(false) => CiEnv::None,
            None => CiEnv::None,
        };

        let mut tidy_ctx = Self {
            diag_ctx: Arc::new(Mutex::new(DiagCtxInner {
                running_checks: Default::default(),
                finished_checks: Default::default(),
                root_path: root_path.to_path_buf(),
                verbose,
            })),
            tidy_flags,
            ci_env,
            base_commit: None,
        };
        tidy_ctx.base_commit();

        tidy_ctx
    }

    fn base_commit(&mut self) {
        let mut check = self.start_check("CI history");

        let stage0 = parse_stage0_file();
        let Stage0Config { nightly_branch, git_merge_commit_email, .. } = stage0.config;

        let base_commit = match get_closest_upstream_commit(

Review comment (suggestion):
```suggestion
            None => CiEnv::current(),
```
Not that we would run tidy manually on CI, but it should auto detect if the flag is not passed.

Code after:
}

/// Collects diagnostics from all tidy steps, and contains shared information
/// that determines how should message and logs be presented.
///
/// Since checks are executed in parallel, the context is internally synchronized, to avoid
/// all checks to lock it explicitly.
#[derive(Clone)]
pub struct TidyCtx {
    tidy_flags: TidyFlags,
    diag_ctx: Arc<Mutex<DiagCtxInner>>,
    ci_env: CiEnv,
    pub base_commit: Option<String>,
}

impl TidyCtx {
    pub fn new(
        root_path: &Path,
        verbose: bool,
        ci_flag: Option<bool>,
        tidy_flags: TidyFlags,
    ) -> Self {
        let ci_env = match ci_flag {
            Some(true) => CiEnv::GitHubActions,
            Some(false) => CiEnv::None,
            None => CiEnv::current(),
        };

        let mut tidy_ctx = Self {
            diag_ctx: Arc::new(Mutex::new(DiagCtxInner {
                running_checks: Default::default(),
                finished_checks: Default::default(),
                root_path: root_path.to_path_buf(),
                verbose,
            })),
            tidy_flags,
            ci_env,
            base_commit: None,
        };
        tidy_ctx.base_commit = find_base_commit(&tidy_ctx);

        tidy_ctx
    }

    pub fn is_bless_enabled(&self) -> bool {
        self.tidy_flags.bless
    }

    pub fn is_running_on_ci(&self) -> bool {
        self.ci_env.is_running_in_ci()
    }
Repository: rust-lang/rust
File: tests/ui/imports/unused-cross-crate-import.rs (Rust)

Code before:
// issue: rust-lang/rust#12612
// Test that unused `use` declarations involving multiple external crates are handled properly.
//@ run-pass
#![allow(unused_imports)]
//@ aux-build:unused-cross-crate-import-aux-1.rs
//@ aux-build:unused-cross-crate-import-aux-2.rs

extern crate unused_cross_crate_import_aux_1 as foo;
extern crate unused_cross_crate_import_aux_2 as bar;

mod test {
    use bar::baz;
}

fn main() {}


Review comment (suggestion):
but what I'll ask to fix is links. Can you replace all of this with actual links to issues 

< https://github.com/rust-lang/rust/issues/number >

Code after:
// issue: <https://github.com/rust-lang/rust/issues/12612>
// Test that unused `use` declarations involving multiple external crates are handled properly.
//@ run-pass
#![allow(unused_imports)]
//@ aux-build:unused-cross-crate-import-aux-1.rs
//@ aux-build:unused-cross-crate-import-aux-2.rs

extern crate unused_cross_crate_import_aux_1 as foo;
extern crate unused_cross_crate_import_aux_2 as bar;

mod test {
    use bar::baz;
}

fn main() {}
Repository: rust-lang/rust
File: compiler/rustc_infer/src/infer/lexical_region_resolve/indexed_edges.rs (Rust)

Code before:
use rustc_index::IndexVec;
use rustc_type_ir::RegionVid;

use crate::infer::SubregionOrigin;
use crate::infer::region_constraints::{Constraint, ConstraintKind, RegionConstraintData};

/// Selects either out-edges or in-edges for [`IndexedConstraintEdges::adjacent_edges`].
#[derive(Clone, Copy, Debug)]
pub(crate) enum EdgeDirection {
    Out,
    In,
}

pub(crate) type ConstraintPair<'tcx> = (Constraint<'tcx>, SubregionOrigin<'tcx>);

/// An index from region variables to their corresponding constraint edges,
/// used on some error paths.
pub(crate) struct IndexedConstraintEdges<'data, 'tcx> {
    out_edges: IndexVec<RegionVid, Vec<&'data ConstraintPair<'tcx>>>,
    in_edges: IndexVec<RegionVid, Vec<&'data ConstraintPair<'tcx>>>,
}

impl<'data, 'tcx> IndexedConstraintEdges<'data, 'tcx> {
    pub(crate) fn build_index(num_vars: usize, data: &'data RegionConstraintData<'tcx>) -> Self {
        let mut out_edges = IndexVec::from_fn_n(|_| vec![], num_vars);
        let mut in_edges = IndexVec::from_fn_n(|_| vec![], num_vars);

        for pair @ (c, _) in data.constraints.iter() {
            let mut push_in_edge = || out_edges[c.sub.as_var()].push(pair);
            // Only push out-edges if the source is a var.
            match c.kind {
                ConstraintKind::VarSubVar => push_in_edge(),
                ConstraintKind::RegSubVar => {}
                ConstraintKind::VarSubReg => push_in_edge(),

Review comment (suggestion):
```suggestion
pub(super) enum EdgeDirection {
```
Same applies to other `pub(crate)`s.

Code after:
use rustc_index::IndexVec;
use rustc_type_ir::RegionVid;

use crate::infer::SubregionOrigin;
use crate::infer::region_constraints::{Constraint, ConstraintKind, RegionConstraintData};

/// Selects either out-edges or in-edges for [`IndexedConstraintEdges::adjacent_edges`].
#[derive(Clone, Copy, Debug)]
pub(super) enum EdgeDirection {
    Out,
    In,
}

/// Type alias for the pairs stored in [`RegionConstraintData::constraints`],
/// which we are indexing.
type ConstraintPair<'tcx> = (Constraint<'tcx>, SubregionOrigin<'tcx>);

/// An index from region variables to their corresponding constraint edges,
/// used on some error paths.
pub(super) struct IndexedConstraintEdges<'data, 'tcx> {
    out_edges: IndexVec<RegionVid, Vec<&'data ConstraintPair<'tcx>>>,
    in_edges: IndexVec<RegionVid, Vec<&'data ConstraintPair<'tcx>>>,
}

impl<'data, 'tcx> IndexedConstraintEdges<'data, 'tcx> {
    pub(super) fn build_index(num_vars: usize, data: &'data RegionConstraintData<'tcx>) -> Self {
        let mut out_edges = IndexVec::from_fn_n(|_| vec![], num_vars);
        let mut in_edges = IndexVec::from_fn_n(|_| vec![], num_vars);

        for pair @ (c, _) in &data.constraints {
            // Only push a var out-edge for `VarSub...` constraints.
            match c.kind {
                ConstraintKind::VarSubVar | ConstraintKind::VarSubReg => {
                    out_edges[c.sub.as_var()].push(pair)
Repository: rust-lang/rust
File: compiler/rustc_middle/src/queries.rs (Rust)

Code before:
    }

    /// Returns a list of all `externally implementable items` crate.
    query externally_implementable_items(cnum: CrateNum) -> &'tcx FxIndexMap<DefId, (EiiDecl, FxIndexMap<DefId, EiiImpl>)> {
        arena_cache
        desc { "looking up the externally implementable items of a crate" }
        cache_on_disk_if { *cnum == LOCAL_CRATE }
        separate_provide_extern
    }

    //-----------------------------------------------------------------------------
    // "Non-queries" are special dep kinds that are not queries.
    //-----------------------------------------------------------------------------

    /// We use this for most things when incr. comp. is turned off.
    non_query Null

    /// We use this to create a forever-red node.
    non_query Red

    /// We use this to create a side effect node.
    non_query SideEffect

    /// We use this to create the anon node with zero dependencies.
    non_query AnonZeroDeps

    non_query TraitSelect

    non_query CompileCodegenUnit

    non_query CompileMonoItem

    non_query Metadata
}

rustc_with_all_queries! { define_callbacks! }


Review comment (suggestion):
Suggestion: Personally I would remove the empty lines here, so that the non-queries form a single clump that's easier to skim past in the common case that the person reading only cares about queries. But I'm not too fussed either way.

Code after:
    }

    /// Returns a list of all `externally implementable items` crate.
    query externally_implementable_items(cnum: CrateNum) -> &'tcx FxIndexMap<DefId, (EiiDecl, FxIndexMap<DefId, EiiImpl>)> {
        arena_cache
        desc { "looking up the externally implementable items of a crate" }
        cache_on_disk_if { *cnum == LOCAL_CRATE }
        separate_provide_extern
    }

    //-----------------------------------------------------------------------------
    // "Non-queries" are special dep kinds that are not queries.
    //-----------------------------------------------------------------------------

    /// We use this for most things when incr. comp. is turned off.
    non_query Null
    /// We use this to create a forever-red node.
    non_query Red
    /// We use this to create a side effect node.
    non_query SideEffect
    /// We use this to create the anon node with zero dependencies.
    non_query AnonZeroDeps
    non_query TraitSelect
    non_query CompileCodegenUnit
    non_query CompileMonoItem
    non_query Metadata
}

rustc_with_all_queries! { define_callbacks! }
Repository: rust-lang/rust
File: tests/codegen-llvm/riscv-abi/call-llvm-intrinsics.rs (Rust)

Code before:
//@ add-minicore
//@ compile-flags: -C no-prepopulate-passes
//@ needs-llvm-components: riscv
//@ only-riscv64

#![feature(link_llvm_intrinsics)]
#![crate_type = "lib"]

struct A;

impl Drop for A {
    fn drop(&mut self) {
        println!("A");
    }
}

extern "C" {
    #[link_name = "llvm.sqrt.f32"]
    fn sqrt(x: f32) -> f32;
}

pub fn do_call() {
    let _a = A;

    unsafe {
        // Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them
        // CHECK: call float @llvm.sqrt.f32(float 4.000000e+00)
        sqrt(4.0);
    }

Review comment (suggestion):
I suspect you'll also need `//@ min-llvm-version: 22`, because earlier LLVM versions (that we run in CI) would still produce the old IR that won't match the new `CHECK`s.

Code after:
//@ add-minicore
//@ compile-flags: -C no-prepopulate-passes
//@ revisions: riscv32gc riscv64gc
//@ [riscv32gc] compile-flags: --target riscv32gc-unknown-linux-gnu
//@ [riscv32gc] needs-llvm-components: riscv
//@ [riscv64gc] compile-flags: --target riscv64gc-unknown-linux-gnu
//@ [riscv64gc] needs-llvm-components: riscv
//@ min-llvm-version: 21

#![feature(link_llvm_intrinsics)]
#![feature(no_core, lang_items)]
#![no_std]
#![no_core]
#![crate_type = "lib"]

extern crate minicore;
use minicore::*;

extern "C" {
    #[link_name = "llvm.sqrt.f32"]
    fn sqrt(x: f32) -> f32;
}

pub fn do_call() {
    unsafe {
        // Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them
        // CHECK: call float @llvm.sqrt.f32(float 4.000000e+00)
        sqrt(4.0);
    }