Skip to content

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

Merged
bors merged 1 commit into
rust-lang:masterfrom
dns2utf8:doc_never_expression
Sep 29, 2016
Merged

Add docs for "!" Never type (rfc 1216)#35286
bors merged 1 commit into
rust-lang:masterfrom
dns2utf8:doc_never_expression

Conversation

@dns2utf8

Copy link
Copy Markdown
Contributor

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

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @steveklabnik

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

@dns2utf8

Copy link
Copy Markdown
ContributorAuthor

r? @nikomatsakis

Comment threadsrc/doc/book/syntax-index.md Outdated

Copy link
Copy Markdown
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

petrochenkov commented Aug 4, 2016

Copy link
Copy Markdown
Contributor

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

@dns2utf8
dns2utf8force-pushed the doc_never_expression branch from 85b0966 to 0ff8841CompareAugust 4, 2016 13:18
@dns2utf8

Copy link
Copy Markdown
ContributorAuthor

Good point. Changed it

@nikomatsakis

Copy link
Copy Markdown
Contributor

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

@nikomatsakis

Copy link
Copy Markdown
Contributor

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

@dns2utf8

dns2utf8 commented Aug 5, 2016

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
dns2utf8force-pushed the doc_never_expression branch from 0ff8841 to 43b98f7CompareAugust 15, 2016 09:23
@dns2utf8

Copy link
Copy Markdown
ContributorAuthor

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

Comment threadsrc/doc/grammar.md Outdated

Copy link
Copy Markdown
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

bors commented Aug 18, 2016

Copy link
Copy Markdown
Collaborator

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

@nikomatsakis

Copy link
Copy Markdown
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
dns2utf8force-pushed the doc_never_expression branch 4 times, most recently from 0929661 to 2632691CompareAugust 20, 2016 20:03
@dns2utf8

dns2utf8 commented Aug 20, 2016

Copy link
Copy Markdown
ContributorAuthor

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
dns2utf8force-pushed the doc_never_expression branch from 2632691 to d9bd4d5CompareAugust 20, 2016 20:13
@dns2utf8dns2utf8 changed the title Add docs for "!" Never type/expression (rfc 1216)Add docs for "!" Never type (rfc 1216)Aug 21, 2016
Comment threadsrc/doc/grammar.md
```

### Never type
An empty type

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

@bors r+ rollup

@bors

bors commented Sep 28, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit d9bd4d5 has been approved by nikomatsakis

@sophiajtsophiajt mentioned this pull request Sep 29, 2016
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
@bors
bors merged commit d9bd4d5 into rust-lang:masterSep 29, 2016
@dns2utf8
dns2utf8 deleted the doc_never_expression branch September 29, 2016 11:54
Sign up for freeto 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

@dns2utf8@rust-highfive@petrochenkov@nikomatsakis@canndrew@bors@apasel422@steveklabnik