Skip to content

todo! and unimplemented! does not work with impl Trait return types #69882

Open
@neckbosov

Description

@neckbosov

This code

trait SomeTrait {
    fn some_func();
}

fn todo_impl_trait() -> impl SomeTrait { todo!() }

does not compile because
the trait SomeTrait is not implemented for ()
But such code

trait SomeTrait {
    fn some_func();
}

fn todo_impl_trait<T: SomeTrait>() -> T { todo!() }

compiles correctly. Can this problem be resolved to use both todo!() and impl Trait?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions