Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impl Trait with < as Trait>::Type syntax does not work in return position #59023

Open
mtak- opened this Issue Mar 8, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@mtak-
Copy link
Contributor

mtak- commented Mar 8, 2019

Using the as syntax does not work as a generic to an impl Trait in return position.

trait A { type Foo; }
impl<T> A for T { type Foo = (); }

fn foo() -> impl std::borrow::Borrow<<u8 as A>::Foo> {
    ()
}

Error

error[E0277]: the trait bound `(): std::borrow::Borrow<<u8 as A>::Foo>` is not satisfied
 --> src/lib.rs:4:13
  |
4 | fn foo() -> impl std::borrow::Borrow<<u8 as A>::Foo> {
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::borrow::Borrow<<u8 as A>::Foo>` is not implemented for `()`
  |
  = help: consider adding a `where (): std::borrow::Borrow<<u8 as A>::Foo>` bound
  = note: the return type of a function must have a statically known size

As a parameter it does work:

trait A { type Foo; }
impl<T> A for T { type Foo = (); }

fn foo(p: impl std::borrow::Borrow<<u8 as A>::Foo>) {}

fn call_foo() {
    foo(())
}

This issue looks related, but specifically calls out type equality constraints. #53984

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Mar 9, 2019

cc @nikomatsakis, is this a lazy-norm issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.