Skip to content

ICE when using generic newtypes cross-crate #9155

Closed
@sfackler

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.

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