Skip to content

fn nested in const fn causes "Cannot create local mono-item for ..." ICE cross-crate. #53451

Closed
@eddyb

Description

@eddyb
// a.rs
#![feature(const_fn)]

pub const fn foo() -> fn() {
    fn bar() {}
    bar
}
// b.rs
extern crate a;
fn main() {
    a::foo()();
}
error: internal compiler error: librustc_mir/monomorphize/collector.rs:757:
Cannot create local mono-item for DefId(10/0:4 ~ a[8787]::foo[0]::bar[0])

Adding #[inline] to bar's definition works around the ICE.
Also, the bug doesn't trigger if foo is an #[inline] non-const fn, so it's not just that foo is inlined cross-crate, but const fn-specific behavior is also involved.

cc @oli-obk @michaelwoerister

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions