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

Add docs for "!" Never type (rfc 1216) #35286

Merged
merged 1 commit into from
Sep 29, 2016

Conversation

dns2utf8
Copy link
Contributor

@dns2utf8 dns2utf8 commented Aug 4, 2016

Pull Request: rust-lang/rfcs#1216
Tracking Issue: #35121

@rust-highfive
Copy link
Collaborator

r? @steveklabnik

(rust_highfive has picked a reviewer for you, use r? to override)

@dns2utf8
Copy link
Contributor Author

dns2utf8 commented Aug 4, 2016

r? @nikomatsakis

@@ -162,6 +162,7 @@
<!-- Various things involving parens and tuples -->

* `()`: empty tuple (*a.k.a.* unit), both literal and type.
* `!`: empty type (*a.k.a.* unit), both literal and type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be something other than "unit".

@petrochenkov
Copy link
Contributor

petrochenkov commented Aug 4, 2016

rust-lang/rfcs#1216 doesn't contain !-expressions.
"* !: empty type" seems to be the only change in this PR that needs to stay.

@dns2utf8 dns2utf8 force-pushed the doc_never_expression branch from 85b0966 to 0ff8841 Compare August 4, 2016 13:18
@dns2utf8
Copy link
Contributor Author

dns2utf8 commented Aug 4, 2016

Good point. Changed it

@nikomatsakis
Copy link
Contributor

Seems OK. Do we want to wait for the ! implementation to land?

@nikomatsakis
Copy link
Contributor

Also, we might want to change the grammar for fn items, which probably specifies ! explicitly.

@dns2utf8
Copy link
Contributor Author

dns2utf8 commented Aug 5, 2016

Currently it has a special entry with a link:
https://github.com/rust-lang/rust/blame/master/src/doc/book/syntax-index.md#L64

Since it is a very special case, what would you change?

@canndrew
Copy link
Contributor

canndrew commented Aug 9, 2016

I think there's some confusion here. ! is only a type, not a literal or an expression. You can't write let x = !; for example.

@nikomatsakis
Copy link
Contributor

@dns2utf8

Since it is a very special case, what would you change?

I would remove the -> ! business and just have an entry for ! itself, which is a type.

@canndrew
Copy link
Contributor

Also ! should probably be referred to as "never type" instead of "empty type" if that's the nomenclature we've decided to go with.

@dns2utf8 dns2utf8 force-pushed the doc_never_expression branch from 0ff8841 to 43b98f7 Compare August 15, 2016 09:23
@dns2utf8
Copy link
Contributor Author

I would leave the empty word in the doc because comming from type theory/haskell, I would search for empty type

### Never expressions

```antlr
never_expr : "!" ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still isn't right. ! isn't an expression, just a type (although the sections for primitive types is nothing but FIXMEs at the moment).

@bors
Copy link
Contributor

bors commented Aug 18, 2016

☔ The latest upstream changes (presumably #35769) made this pull request unmergeable. Please resolve the merge conflicts.

@nikomatsakis
Copy link
Contributor

I agree with @canndrew's edits, though if the type is called never -- isn't it? I forget -- let's just call it that.

@dns2utf8 dns2utf8 force-pushed the doc_never_expression branch 4 times, most recently from 0929661 to 2632691 Compare August 20, 2016 20:03
@dns2utf8
Copy link
Contributor Author

dns2utf8 commented Aug 20, 2016

I added the word "always" and capitalized the never to prevent the missreading @apasel422 mentioned, but I am not sure if it enhances the readability over all.

I agree with @nikomatsakis, it is no longer a special case but I kept the reference to the Diverging Functions

@dns2utf8 dns2utf8 force-pushed the doc_never_expression branch from 2632691 to d9bd4d5 Compare August 20, 2016 20:13
@dns2utf8 dns2utf8 changed the title Add docs for "!" Never type/expression (rfc 1216) Add docs for "!" Never type (rfc 1216) Aug 21, 2016
@@ -764,6 +764,13 @@ bound-list := bound | bound '+' bound-list
bound := path | lifetime
```

### Never type
An empty type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better, though I feel like we could say a lot more here. :) For example, "A type representing the result of a function which never returns -- for example because it panics or goes into an infinite loop."

@nikomatsakis
Copy link
Contributor

Well, this has been inactive for a while. I'm going to just merge it since it seems like an improvement, even if I think we could expand the text.

@nikomatsakis
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 28, 2016

📌 Commit d9bd4d5 has been approved by nikomatsakis

sophiajt pushed a commit to sophiajt/rust that referenced this pull request Sep 29, 2016
…komatsakis

Add docs for "!" Never type (rfc 1216)

Pull Request: rust-lang/rfcs#1216
Tracking Issue: rust-lang#35121
bors added a commit that referenced this pull request Sep 29, 2016
Rollup of 12 pull requests

- Successful merges: #35286, #35892, #36460, #36704, #36741, #36760, #36787, #36789, #36794, #36803, #36811, #36813
- Failed merges:
@bors bors merged commit d9bd4d5 into rust-lang:master Sep 29, 2016
@dns2utf8 dns2utf8 deleted the doc_never_expression branch September 29, 2016 11:54
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

Successfully merging this pull request may close these issues.

8 participants