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

example of public non generic library function not appearing #320

Closed
e00E opened this issue Oct 8, 2024 · 1 comment · Fixed by #321
Closed

example of public non generic library function not appearing #320

e00E opened this issue Oct 8, 2024 · 1 comment · Fixed by #321

Comments

@e00E
Copy link

e00E commented Oct 8, 2024

Consider a library crate with the following contents:

pub fn foo(a: u32) -> u8 {
    a as u8
}

This function does not show up in cargo asm, not with --everything either. I can get the function to show up by tagging it #[no_mangle] or #[inline(never)].

I'm reporting this as an issue because the Readme says this:

rustc will only generate the code for your function if it knows what type it is, including generic parameters and if it is exported (in case of a library) and not inlined (in case of a binary, example, test, etc.). If your function takes a generic parameter - try making a monomorphic wrapper around it and make it pub and #[inline(never)].

This makes it sound like this shouldn't happen.

@pacak
Copy link
Owner

pacak commented Oct 8, 2024

I appreciate the report, this is a known problem caused by rustc itself - see rust-lang/rust#116505

I forgor to update the documentation, will fix.

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 a pull request may close this issue.

2 participants