Skip to content

type_alias_impl_trait fails to correctly resolve bounds.  #101572

Closed
@MichaelMauderer

Description

@MichaelMauderer

Code

I tried this code:

#![feature(type_alias_impl_trait)]

pub type OnFrameClosure<OnFrame> = impl FnMut();

pub fn on_frame_closure<OnFrame>() -> OnFrameClosure<OnFrame>
where
    OnFrame: FnMut(),
{
    move || {
        unimplemented!();
    }
}

This produces the following error:

error[E0277]: expected a `FnMut<()>` closure, found `OnFrame`
  --> src/lib.rs:9:5
   |
9  | /     move || {
10 | |         unimplemented!();
11 | |     }
   | |_____^ expected an `FnMut<()>` closure, found `OnFrame`
   |
   = note: wrap the `OnFrame` in a closure with no arguments: `|| { /* code */ }`
note: required by a bound in `on_frame_closure`
  --> src/lib.rs:7:18
   |
5  | pub fn on_frame_closure<OnFrame>() -> OnFrameClosure<OnFrame>
   |        ---------------- required by a bound in this
6  |     where
7  |         OnFrame: FnMut(),
   |                  ^^^^^^^ required by this bound in `on_frame_closure`
help: consider restricting type parameter `OnFrame`
   |
3  | pub type OnFrameClosure<OnFrame: std::ops::FnMut<()>> = impl FnMut();
   |                                +++++++++++++++++++++

For more information about this error, try `rustc --explain E0277`.
error: could not compile `tyoe_alias_bug_test` due to previous error

Version it worked on

It most recently worked on nightly-2022-05-14.

Version with regression

The first failing version is nightly-2022-05-15.

cargo-bisect-rustc points to a7d6408 regressed commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`

    Type

    No type

    Projects

    Status

    Wontfix

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions