Skip to content

Rename fn to main_js in guide/src/reference/attributes/on-rust-exports/start.md #2207

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

Closed

Conversation

Urhengulas
Copy link

Because the tests fail, when a function annotated with #[wasm_bindgen(start)] is named main, this PR changes the name in the example in the wasm_bindgen book to main_js and says, that it can't be named main.

The information that it can't be named main is from rust-gamedev/wg#51, and solved #2206.

Changes

  • rename function from main to main_js
  • add hint that function can't be named main

Changes:
* rename function from main to main_js
* add hint that function can't be named main
@alexcrichton
Copy link
Contributor

Thanks for the PR! I don't think this is quite right though. You can indeed have a function called main. Is it perhaps specific to the context of the gamedev area that they've already got a symbol called main somewhere else? It may be the case that a different crate you're using already defines main, which means you can't define main yourself when using that crate.

@Urhengulas
Copy link
Author

Urhengulas commented Jun 16, 2020

If you say so that is probably true and in my experience it is also for the wasm-pack build.

But it doesn‘t work for wasm-pack test --node (or browser) and the only dev-dependency I am having is wasm-bindgen-test = "0.3.13".

My main dependency https://github.com/xiph/rav1e is defining a lib and a bin crate, but I am only „using“ the lib.

@17cupsofcoffee
Copy link

17cupsofcoffee commented Jun 17, 2020

The information that it can't be named main is from rust-gamedev/wg#51

To add some context: I raised that issue before #1630 was created/merged, so the info in the first post of rust-gamedev/wg#51 is now outdated. I was referring to the fact that you previously had to wrap your existing main in a #[wasm_bindgen(start)] annotated function in order to get a binary crate running on WASM, but that's no longer the case.

I've updated my issue to reflect this, sorry for the confusion!

@Urhengulas
Copy link
Author

Thank you @17cupsofcoffee for clarifying.

So it seems I had some weird edge-case problem, which accidentally could be resolved with this outdated information. Nice 😎

I am a bit worried other people might also encounter this, but I am going to close the issue.

Thanks everyone :)

@Urhengulas Urhengulas closed this Jun 17, 2020
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.

3 participants