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

treat intrinsics entirely as an implementation detail of specialized modules #10008

Closed
thestinger opened this issue Oct 21, 2013 · 6 comments
Closed
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. I-compiletime Issue: Problems and improvements with respect to compile times. P-low Low priority

Comments

@thestinger
Copy link
Contributor

Exposing all of the intrinsics in one module is much more convenient than ad hoc extern blocks all over the standard library, but is very annoying for users of low-level Rust. It would be much nicer to treat intrinsics as part of the library API, and expose them in relevant modules. The fact that the API may be an intrinsic and not a library defined function is an implementation detail. Safe intrinsics should not be exposed as both an unsafe function and a safe wrapper.

Example: https://github.com/thestinger/rust-core/blob/master/core/f64.rs

@Thiez
Copy link
Contributor

Thiez commented Oct 21, 2013

This sounds like the opposite of #3369. Or do you mean keeping the intrinsics in intrinsics.rs but making it private, and reexport them in the relevant modules?

@thestinger
Copy link
Contributor Author

It's not the opposite of #3369. We used to re-declare them whenever they were needed, rather than exporting them in a single time in a relevant module. I'm not proposing we go back to how things were before.

The rust-core library is mostly (some numerics stuff is still in intrinsics) doing it as a single export location for each intrinsic along with some of them having a wrapper to give them a saner name or mark them as safe. It makes things much simpler for users of the standard library, such as the standard library itself.

@thestinger
Copy link
Contributor Author

This provides a measurable compile-time performance improvement, and also a runtime performance improvement at --opt-level=0 and --opt-level=1 if the wrappers aren't #[inline(always)].

I think the only thing we need to do is make sure rustdoc reports exported intrinsics the same way as it does Rust functions.

@thestinger
Copy link
Contributor Author

We should also feature-gate extern "rust-intrinsic" {} and #[link_name = "llvm.*] in order to completely hide these as implementation details.

@pnkfelix
Copy link
Member

assigning to non-1.0, P-low.

@brson
Copy link
Contributor

brson commented Jan 13, 2015

Intrinsics are feature gated, the intrinsics module is unstable with no current plans to stabilize. I believe the current situation is fine.

@brson brson closed this as completed Jan 13, 2015
flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 17, 2022
Treat custom enum discriminant values as constants

fixes rust-lang#9882
changelog: All lints: Don't lint in enum discriminant values when the suggestion won't work in a const context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. I-compiletime Issue: Problems and improvements with respect to compile times. P-low Low priority
Projects
None yet
Development

No branches or pull requests

4 participants