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

Nested main causes build error #511

Closed
joshlf opened this issue Jul 8, 2019 · 3 comments
Closed

Nested main causes build error #511

joshlf opened this issue Jul 8, 2019 · 3 comments
Labels
enhancement Something new the playground could do help wanted Not immediately going to be prioritized — ask for mentoring instructions!

Comments

@joshlf
Copy link

joshlf commented Jul 8, 2019

The following code snippets seem to cause the playground to interpret the file as a binary (including changing the "build" button to say "run"), but then rustc can't find a crate-level main function, and so fails compilation:

mod foo {
    fn main() {}
}
fn foo() {
    fn main() {}
}

IMO, only main functions at the crate level should cause this behavior.

@shepmaster shepmaster added enhancement Something new the playground could do help wanted Not immediately going to be prioritized — ask for mentoring instructions! labels Jul 9, 2019
@shepmaster
Copy link
Member

Yep!

The automatic selection is done via simple regexes.

If you’d like to fix this, you are welcome to explore an alternate regex or parsing mechanism to make the decision.

In the meantime, you can always override the automatically-selected mode:

image

@joshlf
Copy link
Author

joshlf commented Jul 9, 2019

Ah, seems like a much more involved fix. Maybe eventually we'll want to wasm-ify the Rust parser, but I think for the time being this is probably a small enough wart that it can be ignored. Thanks for the quick reply!

@joshlf joshlf closed this as completed Jul 9, 2019
@shepmaster
Copy link
Member

wasm-ify the Rust parser

It’s possible (see #357), but one important thing to continue to preserve is the ability to handle malformed Rust code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something new the playground could do help wanted Not immediately going to be prioritized — ask for mentoring instructions!
Projects
None yet
Development

No branches or pull requests

2 participants