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

ICE with class in polymorphic impl function in crate #3136

Closed
bblum opened this issue Aug 7, 2012 · 4 comments
Closed

ICE with class in polymorphic impl function in crate #3136

bblum opened this issue Aug 7, 2012 · 4 comments
Labels
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 Aug 7, 2012

x.rs:

enum x = (); 
impl x for x { 
    fn use_x<T>() {
        struct foo {
            i: (); 
            new(i: ()) { self.i = i; }
        }   
    }   
}

x.rc:

#[crate_type = "lib"];

The code works if:

  • it is not polymorphic.
  • the struct is moved outside of the impl, or the impl is removed and the struct is inside the function.
  • a fn main is added and compiled as not-a-crate.
  • a fn main is added and compiled as a crate but the #[crate_type = "lib"] is removed.

It still ICEs if the type parameter is moved up to impl x<T> for x .

Backtrace:

#1  0x00007ffff66d2087 in diagnostic::codemap_handler::meth541::fatal ()
#2  0x00007ffff66d23fb in diagnostic::codemap_handler::meth551::bug ()
#3  0x00007ffff6069b23 in metadata::encoder::encode_symbol ()
#4  0x00007ffff606cc62 in metadata::encoder::encode_info_for_fn ()
#5  0x00007ffff60728de in metadata::encoder::encode_info_for_items::anon ()
#6  0x00007ffff5cc684a in visit::visit_block6832 ()
#7  0x00007ffff5ccdc44 in visit::visit_fn7049 ()
#8  0x00007ffff5ccce7a in visit::visit_method_helper7014 ()
#9  0x00007ffff5cccca2 in visit::visit_item7001 ()
#10 0x00007ffff606f22c in metadata::encoder::encode_info_for_items::anon ()
#11 0x00007ffff60d09b0 in __morestack ()
#12 0x00007ffff5ccc474 in visit::default_visitor6990::anon ()
#13 0x00007ffff5d02949 in metadata::encoder::encode_metadata ()
#14 0x00007ffff5cfe4d1 in middle::trans::base::write_metadata ()

Possibly related to #2733.

@ghost ghost assigned catamorphism Aug 7, 2012
@bblum
Copy link
Contributor Author

bblum commented Aug 9, 2012

I had to work around this here: f2ca549#L1R94

@catamorphism
Copy link
Contributor

This doesn't typecheck now, because x isn't a trait. Do you have another program that does implement a trait, but shows the same bug?

@bblum
Copy link
Contributor Author

bblum commented Aug 16, 2012

Um, it lets me write a non-trait impl as long as the type is owned by the module, which is what enum x is for. All the code in std::sync and std::arc is like this...

But here's a more traitorous version:

trait x {
    fn use_x<T>();
}
enum y = (); 
impl y:x { 
    fn use_x<T>() {
        struct foo {
            i: (); 
            new(i: ()) { self.i = i; }
        }   
    }   
}

@catamorphism
Copy link
Contributor

This appears to be fixed as of a477c5a, though I had to rewrite it to not use an old-style constructor. Perhaps that's the reason. In any case, I'll check in a test case once the tree reopens.

catamorphism added a commit to catamorphism/rust that referenced this issue Oct 8, 2012
RalfJung pushed a commit to RalfJung/rust that referenced this issue Oct 25, 2023
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
mdbook-graphviz has released 0.1.7, which has updated dependencies.

Resolves: rust-lang#3005
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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