Skip to content

rustc hangs on a recursive function marked with #[inline] #100476

Closed
@yvt

Description

@yvt

I tried this code with -Copt-level=3 --crate-type=lib (Playground, Godbolt; minimized and modified from r3_core's failing code):

#![feature(decl_macro)]

macro emit($($m:ident)*) {$(
    // Randomize `def_path_hash` by defining them under a module with
    // different names
    pub mod $m {
        pub trait Tr {
            type Next: Tr;
        }

        pub fn hoge<const N: usize, T: Tr>() {
            inner::<N, T>();
        }

        #[inline(always)]
        fn inner<const N: usize, T: Tr>() {
            inner::<N, T::Next>();
        }
    }
)*}

// Increase the chance of triggering the bug
emit!(
    m00 m01 m02 m03 m04 m05 m06 m07 m08 m09
    m10 m11 m12 m13 m14 m15 m16 m17 m18 m19
);

I expected to see this happen: Successful compilation

Instead, this happened: Compiler hangup

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (f8588549c 2022-07-18)
binary: rustc
commit-hash: f8588549c3c3d45c32b404210cada01e2a45def3
commit-date: 2022-07-18
host: aarch64-apple-darwin
release: 1.64.0-nightly
LLVM version: 14.0.6
Backtrace

Captured by a backtrace command in GDB: gdb.txt

Metadata

Metadata

Assignees

Labels

A-mir-optArea: MIR optimizationsC-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions