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

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

Closed
bblum opened this issue Jun 27, 2012 · 9 comments
Closed
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-linkage Area: linking into static, shared libraries and binaries I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@bblum
Copy link
Contributor

bblum commented Jun 27, 2012

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?

@catamorphism
Copy link
Contributor

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

@ghost ghost assigned catamorphism Jun 28, 2012
@catamorphism
Copy link
Contributor

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

@catamorphism
Copy link
Contributor

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

@bblum
Copy link
Contributor Author

bblum commented Jul 18, 2012

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

@bblum bblum reopened this Jul 18, 2012
@bblum
Copy link
Contributor Author

bblum commented Jul 18, 2012

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()
}

@bblum
Copy link
Contributor Author

bblum commented Jul 18, 2012

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()
}

@bblum
Copy link
Contributor Author

bblum commented Jul 18, 2012

related #2313?

@catamorphism
Copy link
Contributor

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

@bblum
Copy link
Contributor Author

bblum commented Jul 23, 2012

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-linkage Area: linking into static, shared libraries and binaries I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants