Skip to content

ICE: out of range when substituting error with converting to a not object-safe trait object #21950

Closed
@mandel59

Description

@mandel59
use std::ops::Add;

fn main() {
    let x = &10 as &Add;
}

This code yields the following compile error:

% rustc addtrait.rs
addtrait.rs:4:21: 4:24 error: internal compiler error: Type parameter `Self/SelfSpace.0` (Self/SelfSpace/0) out of range when substituting (root type=Self) substs=Substs[types=[[];[];[]], regions=[[];[];[]]]
addtrait.rs:4     let x = &10 as &Add;
                                  ^~~
note: the compiler unexpectedly panicked. 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
thread 'rustc' panicked at 'Box<Any>', /Users/ryama/tree/rust/src/libsyntax/diagnostic.rs:129

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.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