Skip to content

Circular trait bounds causes stack overflow in rustc #12644

Closed
@mikejsavage

Description

@mikejsavage

overflow.rs:

pub struct Deg { d : f64 }
pub trait Angle : Equiv< Self > { }

impl Angle for Deg { }

impl< T : Angle > Equiv< T > for T {
        fn equiv( &self, other : &T ) -> bool {
                return true;
        }
}

pub fn main() { }

compiling:

$ rustc -v
rustc 0.9
host: x86_64-unknown-linux-gnu
$ rustc overflow.rs 
overflow.rs:9:1: 13:2 error: cannot provide an extension implementation where both trait and type are not defined in this crate
overflow.rs:9 impl< T : Angle > Equiv< T > for T {
overflow.rs:10  fn equiv( &self, other : &T ) -> bool {
overflow.rs:11          return self.normalize() == other.normalize();
overflow.rs:12  }
overflow.rs:13 }
task 'rustc' has overflowed its stack
Illegal instruction (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    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