Skip to content

ICE: cannot export private function via public static variable #6464

Closed
@gifnksm

Description

@gifnksm

Following code causing ICE.
foo.rs

pub static fun: extern fn() = foo;

fn foo() {
  println("Foo");
}

main.rs

extern mod foo;

fn main() {
  (foo::fun)();
}
$  rustc --lib foo.rs
warning: missing crate link meta `name`, using `foo` as default
warning: missing crate link meta `vers`, using `0.0` as default
$ rustc main.rs -L .
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues

If foo::foo is declared as pub, the code compiles successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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