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

libc::Nullable should have attribute that enforces null-pointer optimization #13941

Closed
lilyball opened this issue May 5, 2014 · 1 comment
Closed
Labels
A-type-system Area: Type system

Comments

@lilyball
Copy link
Contributor

lilyball commented May 5, 2014

libc::Nullable exists as an Option-equivalent that is suitable for using with liblibc without requiring libstd. It seems the appropriate type to use for nullable function pointers, e.g. Nullable<extern "C" fn (int)>. But doing this is making the implicit assumption that Nullable benefits from the null-pointer optimization, i.e. that this type has the same size as *(). I think we should statically guarantee this by adding an attribute that guarantees that Nullable<T> can only be used with a type parameter that allows it to use the null-pointer optimization. This means I can say Nullable<extern "C" fn (int)>, but I can't say Nullable<uint>, nor Nullable<*u32> (because *u32 is already nullable, and therefore the null-pointer optimization doesn't apply).

@alexcrichton
Copy link
Member

This type no longer exists, it's now Option, so closing.

bors added a commit to rust-lang-ci/rust that referenced this issue Feb 13, 2023
internal: explain the idea behind rust-project.json
bors pushed a commit to rust-lang-ci/rust that referenced this issue Jan 28, 2025
The code should not attempt to obtain a snippet by capping the function
signature span with its identifier span without checking that they are
in the same context.

This is the only instance I could identify where placeholders were used
instead of the real snippet when running the CI lintcheck. Moreover, the
placeholders were not even used, as they snippet was obtained
prematurely.

Found in the context of rust-lang#13941

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

3 participants