Skip to content

Document restrictions of the main function #345

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

Merged
merged 3 commits into from
May 24, 2018

Conversation

Havvy
Copy link
Contributor

@Havvy Havvy commented May 22, 2018

Also updated a link for attributes and changed the first paragraph to a note.

@Havvy Havvy changed the title Document multiple return types in main Document restrictions of the main function May 24, 2018
@Havvy
Copy link
Contributor Author

Havvy commented May 24, 2018

This now also documents that trait and lifetime parameters aren't allowed and the newly added restriction of no where clauses.

@Havvy Havvy requested a review from matthewjasper May 24, 2018 08:01
Copy link
Contributor

@matthewjasper matthewjasper left a comment

Choose a reason for hiding this comment

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

Couple of small things.


* `()`
* `bool`
* `i32`
Copy link
Contributor

Choose a reason for hiding this comment

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

Bool and i32 don't implement Termination at the moment.

A crate that contains a `main` function can be compiled to an executable. If a
`main` function is present, its return type must be `()`
("[unit]") and it must take no arguments.
A crate that contains a `main` [function] can be compiled to an executable. If a
Copy link
Contributor

Choose a reason for hiding this comment

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

Not from this PR, but binary crates are determined by the crate type, not the presence of main.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a lot on that page I don't like, but I wanted to keep this change self-contained.

<!-- `!` -->
* `Result<T, E> where T: on this list, E: Error`

> Note: The implementation of which return types is allowed is the unstable
Copy link
Contributor

Choose a reason for hiding this comment

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

Are allowed.
'Is determined by'?

@matthewjasper
Copy link
Contributor

Thanks!

@matthewjasper matthewjasper merged commit e713055 into rust-lang:master May 24, 2018
@Havvy Havvy deleted the try-in-main branch May 25, 2018 03:40
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.

2 participants