Skip to content

Compiler crash when implementing a trait with unmet supertrait bound #4493

Description

@Anonymous1-design

Code

trait UnitValue: NewTrait {
    fn value(&self) -> i32;
}
impl UnitValue for i32 {
    fn value(&self) -> i32 {
        *self
    }
}
trait UnitExt: UnitValue {
    fn double_value(&self) -> i32 {
        self.value() + self.value()
    }
}
impl<T: UnitValue> UnitExt for T {}
pub fn main() {
    let _x = 42;
    let _y = test().double_value();
}
fn test() -> impl UnitValue {
    100
}
trait NewTrait<const N: usize> {}

Meta

1a91028

Error output

bug.rs:9:6: error: the trait bound ‘i32: NewTrait’ is not satisfied [E0277]
    6 | trait UnitValue: NewTrait {
      |                          required by this bound in: UnitValue
......
    9 | impl UnitValue for i32 {
      |      ^~~~~~~~~
      |               the trait NewTrait is not implemented for i32
bug.rs:19:20: error: the trait bound ‘T: NewTrait’ is not satisfied [E0277]
    6 | trait UnitValue: NewTrait {
      |                          required by this bound in: UnitValue
......
   19 | impl<T: UnitValue> UnitExt for T {}
      |                    ^~~~~~~
      |                           the trait NewTrait is not implemented for T

Segmentation fault (core dumped)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions