Skip to content

ICE when using generic newtypes cross-crate #9155

Description

@sfackler

Turns out it's impossible to use generic newtypes across crates:

test.rs:

pub struct Foo<T>(T);

impl<T> Foo<T> {
    pub fn new(t: T) -> Foo<T> {
        Foo(t)
    }
}

test2.rs:

extern mod test;

use test::{Foo};

struct Baz;

fn main() {
    Foo::new(Baz);
}
~ ❯ env RUST_LOG=rustc=1 rustc -L. test2.rs
task <unnamed> failed at 'assertion failed: `(left == right) && (right == left)` (left: `2`, right: `0`)', /build/rust-git/src/rust/src/librustc/middle/trans/callee.rs:385
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 to get further details and report the results to github.com/mozilla/rust/issues
task <unnamed> failed at 'explicit failure', /build/rust-git/src/rust/src/librustc/rustc.rs:377

This makes it impossible to use std::rt::io::buffered::BufferedStream.

Activity

  1. huonw commented on Sep 13, 2013

    @huonw
    Contributor

    Related to #7899 (but not identical).

  2. bluss commented on Oct 2, 2013

    @bluss
    Contributor

    This particular case seems to be fixed by the PR #9560 by pcwalton!

    However, there are compiler errors on trying to use the test::Foo constructor directly..

  3. alexcrichton commented on Oct 2, 2013

    @alexcrichton
    Member

    Flagging as needstest.

  4. added a commit that references this issue on Oct 3, 2013
  5. added a commit that references this issue on Oct 3, 2013
  6. added a commit that references this issue on Jun 30, 2023
    cc8ead2
  7. added a commit that references this issue on Aug 21, 2026
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

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions