Skip to content

Type inference fails in unpredictable ways #33449

Closed
@notriddle

Description

@notriddle

This works

#![allow(unused)]

fn f<F>() -> Result<Option<F>, ()> {
    panic!()
}

fn g<G>() -> Option<G> {
    f().unwrap().unwrap()
}

This does not:

#![allow(unused)]

fn f<F>() -> Result<Option<F>, ()> {
    panic!()
}

fn g<G>() -> Option<G> where Option<G>: Sized { // <--
    f().unwrap().unwrap()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inferenceArea: Type inferenceC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions