Files
rust/tests/ui/coroutine/avoid-query-cycle-in-ctfe.rs
Alan Egerton 55509a9fe4 Do not deduce parameter attributes during CTFE
`fn_abi_of_instance` can look at function bodies to deduce codegen
optimization attributes (namely `ArgAttribute::ReadOnly` and
`ArgAttribute::CapturesNone`) of indirectly-passed parameters.  This can
lead to cycles when performed during typeck, when such attributes are
irrelevant.

This patch breaks a subquery out from `fn_abi_of_instance`,
`fn_abi_of_instance_no_deduced_attrs`, which returns the ABI before such
parameter attributes are deduced; and that new subquery is used in CTFE
instead.
2026-03-04 16:38:36 +00:00

19 lines
569 B
Rust

//! Items whose type depends on CTFE (such as the async closure/coroutine beneath, whose type
//! depends upon evaluating `do_nothing`) should not cause a query cycle owing to the deduction of
//! the function's parameter attributes, which are only required for codegen and not for CTFE.
//!
//! Regression test for https://github.com/rust-lang/rust/issues/151748
//@ compile-flags: -O
//@ edition: 2018
//@ check-pass
fn main() {
let _ = async || {
let COMPLEX_CONSTANT = ();
};
}
const fn do_nothing() {}
const COMPLEX_CONSTANT: () = do_nothing();