rust-lang / rust-lang/rust

`#[inline]` affects whether consteval happens

Open
#144,460 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-const-eval C-discussion
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

fn foo<T>() {
    const { panic!() }
}

// uncommenting this line makes it compile
// #[inline]
pub fn wut() {
    foo::<i32>();
}

I expected #[inline] to not affect whether the code compiles or not. However, the code compiles with #[inline], and fails to compile without #[inline]. I'm not sure if this is a bug or not.

Discovered in https://github.com/rust-lang/rust/pull/144363

@rustbot labels +A-const-eval

Meta

Reproducible on the playground with stable rust 1.88.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the example on the Rust playground with stable Rust 1.88.0, comparing compilation with and without #[inline]. Trace the const-eval behavior involved in the const block and add a regression test showing that compilation should not depend on the inline attribute.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.