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

Need more helpful warning when "pub extern" function is not exported via "pub use" #49238

Open
federicomenaquintero opened this issue Mar 21, 2018 · 5 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@federicomenaquintero
Copy link
Contributor

I'm creating a bunch of #[no_mangle] pub extern fn that will be callable from C code. Sometimes I forget to put them in my toplevel lib.rs as pub use. This is the warning I get:

warning: function is marked #[no_mangle], but not exported
   --> src/state.rs:436:1
    |
436 |   pub extern "C" fn rsvg_state_rust_parse_style_pair(
    |   ^
    |   |
    |  _help: try making it public: `pub `

At first sight, that function is already pub! The warning should say that I need to export it from the crate via pub use.

@zackmdavis
Copy link
Member

This should be fixed on nightly and in 1.25: #47479

@zackmdavis
Copy link
Member

Or rather, the bogus suggestion to add pub when it already says pub has been fixed, but we don't yet have the correct pub use suggestion.

@estebank estebank added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-diagnostics Area: Messages for errors, warnings, and lints labels Mar 21, 2018
@federicomenaquintero
Copy link
Contributor Author

I'm trying my hand at a fix for this. It's my first contribution to the compiler 😛 What would be appropriate wording for the hint - something like try exporting it in your crate's toplevel: pub use fully:qualified:id_name;?

@zackmdavis
Copy link
Member

@federicomenaquintero Sorry no one got around to answering your question back in March. A note suggesting exporting with pub use was added in 8d1cbb0, so I think this issue can be closed.

@federicomenaquintero
Copy link
Contributor Author

No problem; thanks for the notice 😄

@crlf0710 crlf0710 added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants