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

Cannot express never returning closure (FnOnce() -> !) #25325

Closed
diwic opened this issue May 12, 2015 · 3 comments
Closed

Cannot express never returning closure (FnOnce() -> !) #25325

diwic opened this issue May 12, 2015 · 3 comments

Comments

@diwic
Copy link
Contributor

diwic commented May 12, 2015

Here's a minimal example that shows the problem:

fn never_return<F: FnOnce() -> !>(f: F) -> ! {
    f();
}

which fails with:

error: expected type, found `!`
     fn never_return<F: FnOnce() -> !>(f: F) -> ! {

...AFAICS, there's no good reason this syntax is not allowed.

@pnkfelix
Copy link
Member

The reason is the combination of :

  • F(A, B) -> T is shorthand for F <(A, B), T>
  • ! is itself not a type; it cannot be plugged into the A B nor T above.

If we were to readd it as a type (and note that some effort did go into removing it), that would probably require an RFC. (And also, I'd want a ?Marker on such type parameter analogous to ?Sized; something like ?Converge...)

@pnkfelix
Copy link
Member

(Alternatively we could make a special case for the F(A, B) -> T shorthand where F(A, B) -> ! would expand in some entirely different way -- but again, that would require an RFC.)

@steveklabnik
Copy link
Member

Agreed with @pnkfelix .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants