Skip to content

Multidispatch inference failure #18019

Closed
@nikomatsakis

Description

@nikomatsakis

The following test should successfully compile but does not:

/// A trait for types that can be converted from a given error type `E`.
pub trait FromError<E> {
    /// Perform the conversion.
    fn from_error(err: E) -> Self;
}

// Any type is convertable from itself
impl<E> FromError<E> for E {
    fn from_error(err: E) -> E {
        err
    }
}

fn test() -> Result<(), ()> {
    Err(FromError::from_error(()))
}

fn main() {
    let result = (|| Err(FromError::from_error(())))();
    let foo: () = result.unwrap();
}

Fix forthcoming.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions