-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add RFC for new intrinsic design #8
Conversation
Seems reasonable to me FWIW. One question, the RFC mentions:
Does that mean that the #[intrinsic] attribute is implicitly #[inline(always)], #[inline(never)] or neither? |
@bnoordhuis it's |
|
||
The compiler will type check and translate intrinsics the same as today. | ||
Additionally, when trans sees a "Rust" extern tagged as an intrinsic | ||
it will not emit a function declaration to LLVM bitcode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could paragraph could mention that forced inlining is done in the front-end. That wasn't obvious (to me at least) until @brson clarified it.
Hmm, looks ok to me, but is very sparse on the details. I'd like to see intrinsics given a little more room in the language, as they are (to me at least) inherently there for bypassing the language semantics (or producing faster code, but that's just a bonus). However currently they are significantly hamstrung by the fact that the typechecker and other parts treat them the same as any other function call, meaning that you either get "type" errors in trans or an explosion of functions that shouldn't really exist. |
@brson while this looks relatively ok to me, I feel like this is missing a big part of what we discussed: in particular, didn't we intend to impose constraints on the type parameters with which transmute can be instantiated? I had hoped to address the problem of transmuting between types of different sizes this way, but also possibly to remove the possibility of "const-casts" (which are undefined behavior) so as to channel interior mutability through |
@nikomatsakis would that theoretically require a new kind like I'd guess one can use macros in those cases, especially since it seems highly likely that any generic function that |
@huonw if we wanted to enable it, then yes, something like that -- or maybe Private traits still offer a reasonable alternative. You can create a private trait like:
and replace your calls to transmute with Then you just impl that trait for each of the types you expect to use it with:
This is more-or-less what you suggested, but I am not advocating it as a public trait, just something people can use in specific cases. I'd be interested to know if there are legit use cases involving a family of types but not involving pointer indirection. (Note that the ability to transmute |
@nikomatsakis I consider the restrictions on transmute to be a seperate issue: rust-lang/rust#12898 |
@brson oh, ok, I forgot about that (even though I apparently commented) |
s/Send/Sync/
Update summary to focus on `::` semantics
Details in the commit. Transcribed from workweek minutes: https://github.com/mozilla/rust/wiki/Meeting-workweek-2014-03-03#intrinsics.