Skip to content

ICE passing a trait object by reference #17322

Closed
@kmcallister

Description

@kmcallister
use std::io;

fn f(wr: &mut Writer) {
    wr.write_str("hello").ok().expect("failed");
}

fn main() {
    let mut wr = box io::stdout() as Box<Writer + 'static>;
    f(&mut wr);
}
$ rustc foo.rs  
error: internal compiler error: trying to take the sizing type of std::io::Writer, an unsized type  
note: the compiler hit an unexpected failure path. this is a bug.  
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html  
note: run with `RUST_BACKTRACE=1` for a backtrace  
task 'rustc' failed at 'Box<Any>', /home/keegan/rust/src/libsyntax/diagnostic.rs:169  

upstream Rust version: 828e075

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-DSTsArea: Dynamically-sized types (DSTs)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions