Skip to content

Trait information is discarded #26564

@yongqli

Description

@yongqli

I would expect this to compile, but it doesn't. Is this intentional? It seems that M2 discards the f64: Mul<Self, Output=Self> constraint.

use std::ops::{Mul};

pub trait M: Sized where f64: Mul<Self, Output=Self> {
}

pub trait M2: M {
    fn f(self, a: f64) -> Self {
        a * self
    }
}

Error is:

error: the trait `core::ops::Mul<Self>` is not implemented for the type `f64` [E0277]
<anon>:11         a * self

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions