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

Closed
mtak- opened this issue Mar 8, 2019 · 3 comments
Closed

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

mtak- opened this issue Mar 8, 2019 · 3 comments

Comments

@mtak-
Copy link
Contributor

@mtak- 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
Copy link
Contributor

@Centril Centril commented Mar 9, 2019

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

@jonas-schievink
Copy link
Member

@jonas-schievink jonas-schievink commented Apr 3, 2020

This was fixed by #62221, which includes tests, so maybe this should just be closed?

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 3, 2020
Add test for rust-lang#59023

Adds a test for rust-lang#59023

Closes rust-lang#59023
@nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Apr 3, 2020

Closing per @jonas-schievink's comment

bors added a commit to rust-lang-ci/rust that referenced this issue Apr 3, 2020
Rollup of 5 pull requests

Successful merges:

 - rust-lang#69860 (Use associated numeric consts in documentation)
 - rust-lang#70640 (Hide `task_context` when lowering body)
 - rust-lang#70707 (Remove unused graphviz emitter)
 - rust-lang#70735 (Clean up E0502 explanation)
 - rust-lang#70741 (Add test for rust-lang#59023)

Failed merges:

r? @ghost
Centril added a commit to Centril/rust that referenced this issue Apr 3, 2020
Add test for rust-lang#59023

Adds a test for rust-lang#59023

Closes rust-lang#59023
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 3, 2020
Rollup of 9 pull requests

Successful merges:

 - rust-lang#69860 (Use associated numeric consts in documentation)
 - rust-lang#70576 (Update the description of the ticket to point at RFC 1721)
 - rust-lang#70597 (Fix double-free and undefined behaviour in libstd::syn::unix::Thread::new)
 - rust-lang#70640 (Hide `task_context` when lowering body)
 - rust-lang#70641 (Remove duplicated code in trait selection)
 - rust-lang#70707 (Remove unused graphviz emitter)
 - rust-lang#70720 (Place TLS initializers with relocations in .tdata)
 - rust-lang#70735 (Clean up E0502 explanation)
 - rust-lang#70741 (Add test for rust-lang#59023)

Failed merges:

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants