Skip to content

Unexported ifaces should export metadata anyway for cross-crate monomorphisation #2733

Closed

Description

@bblum

Spent too long figuring out an ICE: "'lookup_item: id not found: 51905', /home/bblum/rust/src/rustc/metadata/decoder.rs:96".

Turns out I had defined an iface in libcore/task.rs to use in a polymorphic function. I had exported the function, but not the iface. Then when attempting to compile a program that linked against libcore, this failure arose from type_of() in trans/type_of.rs when trying to #debug-print the type, called from monomorphic_fn() in trans/base.rs.

As a workaround, exporting the iface makes the metadata lookup go through.

Maybe all enums need this treatment too?

Activity

  1. catamorphism commented on Jun 28, 2012

    @catamorphism
    Contributor

    Offhand it looks like a reachability bug, but I'll investigate.

  2. catamorphism commented on Jul 11, 2012

    @catamorphism
    Contributor

    @bblum Do you have a test case for reproducing this?

  3. catamorphism commented on Jul 11, 2012

    @catamorphism
    Contributor

    Closing due to lack of test case; reopen if you have one.

  4. bblum commented on Jul 18, 2012

    @bblum
    ContributorAuthor

    foo.rs:

    export foo;
    iface local_data { }
    impl <T> of local_data for @T { }
    
    fn foo<T>(t: @T) -> local_data {
        t as local_data
    }

    foo.rc:

    #[link(name = "foo", vers="0.0")];
    #[crate_type = "lib"];

    bar.rs:

    import foo;
    fn main() { foo::foo(@5); }

    bar.rc:

    use foo;

    run rustc foo.rc; rustc -L . bar.rc

    The ICE goes away if:

    • foo is made to return unit
    • foo is not polymorphic
  5. reopened this on Jul 18, 2012
  6. bblum commented on Jul 18, 2012

    @bblum
    ContributorAuthor

    Arguably the above should refuse to compile, because foo has in its signature a nonexported type.

    Here is a variation that still crashes:

    trait face { fn x() -> int; }
    impl <T> of face for @T { fn x() -> int { 5 } }
    
    fn foo<T>(t: @T) -> int {
        (t as face).x()
    }
  7. bblum commented on Jul 18, 2012

    @bblum
    ContributorAuthor

    Doesn't seem to happen with enums. This works fine:

    export foo;
    impl x<T> for face<T> { fn x() -> int { 5 } }
    enum face<T> = @T;
    
    fn foo<T>(t: @T) -> int {
        face(t).x()
    }
    
  8. bblum commented on Jul 18, 2012

    @bblum
    ContributorAuthor

    related #2313?

  9. catamorphism commented on Jul 20, 2012

    @catamorphism
    Contributor

    Seems like the fix for #2945 should fix this too, but I'll still check.

  10. bblum commented on Jul 23, 2012

    @bblum
    ContributorAuthor

    pretty sure 1528256 fixed this. the bug is gone, anyway.

  11. added a commit that references this issue on Jan 29, 2026
  12. added 2 commits that reference this issue on Aug 21, 2026
    8e88db9
    7e5cfcd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)A-linkageArea: linking into static, shared libraries and binariesI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions