Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
eddyb opened this issue Aug 17, 2018 · 2 comments · Fixed by #56024
Closed

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

eddyb opened this issue Aug 17, 2018 · 2 comments · Fixed by #56024
Assignees
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@eddyb
Copy link
Member

eddyb commented Aug 17, 2018

// 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

@eddyb eddyb added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. labels Aug 17, 2018
@eddyb
Copy link
Member Author

eddyb commented Nov 17, 2018

Still happens on the latest nightly. cc @rust-lang/compiler
It doesn't block #49219, but the workaround in that PR is a bit ugly.

@oli-obk
Copy link
Contributor

oli-obk commented Nov 17, 2018

I have a fix in #56024

pietroalbini added a commit to pietroalbini/rust that referenced this issue Nov 25, 2018
…ichaelwoerister

Don't auto-inline const functions

fixes rust-lang#53451
tmandry added a commit to tmandry/rust that referenced this issue Oct 29, 2019
…chton

proc_macro: clean up bridge::client::__run_expand{1,2} a bit.

See commit titles/diffs for more details.

The first commit is made possible by rust-lang#53451 being fixed (almost a year ago).
The last commit should remove the need for `#[allow(improper_ctypes)]` in rust-lang#65134.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants