Skip to content

monomorphization fails with generic methods on impls #1944

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

Closed
nikomatsakis opened this issue Mar 8, 2012 · 4 comments
Closed

monomorphization fails with generic methods on impls #1944

nikomatsakis opened this issue Mar 8, 2012 · 4 comments

Comments

@nikomatsakis
Copy link
Contributor

This test case:

impl foo for uint {
    fn with<A:copy>(a: A) -> (uint, A) {
        (self, a)
    }
}

fn main() {
    let pair = 3u.with("hi");
    assert pair == (3u, "hi");
}

yields an assertion failure:

rust: upcall fail 'Assertion did.crate != ast::local_crate failed', ../src/rustc/middle/ty.rs:2294

@pcwalton I believe this is why the --monomorphize'd version of rustc did not work.

@nikomatsakis
Copy link
Contributor Author

just for reference, this works fine:

fn with<A:copy,B:copy>(a: A, b: B) -> (A, B) {
    (a, b)
}

fn main() {
    let pair = with(3u, "hi");
    assert pair == (3u, "hi");
}

@pcwalton
Copy link
Contributor

pcwalton commented Mar 8, 2012

Yes, this is the error message I saw. Paging @marijnh.

@marijnh
Copy link
Contributor

marijnh commented Mar 8, 2012

You'll notice that #1736 is still open. The problem is the way def_self works in inlined methods. I'll iron this out, along with a whole bunch of other breakages of the inliner and monomorphizer, as part of that bug.

@marijnh marijnh closed this as completed Mar 8, 2012
marijnh added a commit that referenced this issue Mar 8, 2012
This makes it possible to move them between crates without confusion,
and to instantiate them at a point where the monomorphizing
substitutions are known.

Issue #1944
marijnh added a commit that referenced this issue Mar 9, 2012
marijnh added a commit that referenced this issue Mar 11, 2012
@Dretch
Copy link
Contributor

Dretch commented Mar 25, 2012

I have a test case that produces a very similar assertion failure message, so I am noting it here:

fn mk () -> io::FILE_res {
    fail "doesnt seem to matter how its made"
}

fn main () {
    let _x = mk();
}

This produces (code from latest master, linux64):

rust: upcall fail 'Assertion did.crate == ast::local_crate failed', ../src/rustc/middle/trans/base.rs:698
error: internal compiler error unexpected failure

celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants