Skip to content

Seg-fault when not providing associated type #20712

@engstad

Description

@engstad

This code:

#![feature(globs)]
use std::ops::Add;
struct MyInt { a : int }
impl Add for MyInt {
    fn add(self, rhs:Self) -> Self { MyInt { a : self.a + rhs.a } }
}

fn main(){}

Causes seg-fault:

<anon>:7:1: 9:2 error: internal compiler error: impl `VtableImpl(impl_def_id=DefId { krate: 0, node: 10 }:MyInt.Add, substs=Substs[types=[[];[];[]], regions=[[];[];[]]], nested=[[];[];[]])` did not contain projection for `Obligation(predicate=<MyInt as TraitRef(MyInt, core::ops::Add)>::Output,depth=0)`
<anon>:7 impl Add for MyInt {
<anon>:8     fn add(self, rhs:Self) -> Self { MyInt { a : self.a + rhs.a } }
<anon>:9 }
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>', /build/rust-git/src/rust/src/libsyntax/diagnostic.rs:123

See http://is.gd/1lKWYa

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)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