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

Exporting a function as main does not work as expected #27640

Closed
tbu- opened this issue Aug 10, 2015 · 5 comments
Closed

Exporting a function as main does not work as expected #27640

tbu- opened this issue Aug 10, 2015 · 5 comments

Comments

@tbu-
Copy link
Contributor

tbu- commented Aug 10, 2015

mod foo {
    pub fn bar() {
    }
}
pub use foo::bar as main;

does not compile due to

error: main function not found
aborting due to previous error

The expected behaviour would be that the compiler treats the global symbol main which resolves to foo::bar as the main function.

@Aatch
Copy link
Contributor

Aatch commented Aug 11, 2015

Hmm, I'm not sure how I feel about this. I guess I'm leaning towards not supporting this, as the main function isn't really "exported" like re-exports are. Note that we do support main functions that aren't fn main() at the top level via the #[main] attribute.

@steveklabnik
Copy link
Member

@rust-lang/lang , would this need an RFC?

@nrc
Copy link
Member

nrc commented Aug 19, 2015

Yeah this should get an RFC.

Does this have a motivation that #[main] can't address?

@tbu-
Copy link
Contributor Author

tbu- commented Aug 19, 2015

@nrc Consistency. Using a main method from a library.

@steveklabnik
Copy link
Member

I also think this should go through an RFC. @tbu- , please pursue one for this.

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

4 participants