-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add attribute to indicate entry point, #[main] #4483
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
Conversation
Move duplicate main check from trans to resolve and change trans to use main fn indicated in session.
Attribute to allow naming the entry point something other than `main`.
Functions explicitly marked with #[main] have precedence over the regular `main` fn.
#4482 might be related |
// or multple functions marked | ||
// with #[main] | ||
self.session.span_fatal(item.span, | ||
~"multiple 'main' functions"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when functions are given in particular order like this: main - main - #[main]
I think it would print out "multiple 'main' functions" error.
https://gist.github.com/4530073
or this also would lead to similar result
https://gist.github.com/4530083
Hmm I didn't see ILyoan's work when I started working on this last night and hadn't checked before making the pull request. Also, thanks for pointing out the bugs. |
Rust became so popular that people happen to work on the same stuff all the time ;( |
The two look essentially equivalent, so I'm not going to try to pull anything out of this branch. Sorry about that @luqmana. Please let me know if you would like me to pull any specific thing. |
No worries, it's fine. I think the only major difference is that in my changes for the test driver it doesn't remove the functions from the AST but just removes the attributes while ILyoan's just removes the fn. |
#4207
Functions marked with #[main] will take precedence over 'main' if it's there.