Skip to content

Commit ef22d54

Browse files
committed
Address comments on intrinsic RFC
1 parent 3cdd30e commit ef22d54

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

active/0000-new-intrinsics.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ directly as part of the public API.
4141
have the "Rust" ABI then the problem is solved.
4242

4343
Under this scheme intrinsics will be declared as `extern "Rust"` functions
44-
and identified as intrinsics with the `#[intrinsic]` attribute:
44+
and identified as intrinsics with the `#[lang = "..."]` attribute:
4545

4646
```
4747
extern "Rust" {
48-
#[intrinsic]
48+
#[lang = "transmute"]
4949
fn transmute<T, U>(T) -> U;
5050
}
5151
```
@@ -54,13 +54,24 @@ The compiler will type check and translate intrinsics the same as today.
5454
Additionally, when trans sees a "Rust" extern tagged as an intrinsic
5555
it will not emit a function declaration to LLVM bitcode.
5656

57+
Because intrinsics will be lang items, they can no longer be redeclared
58+
arbitrary number of times. This will require a small amount of existing
59+
library code to be refactored, and all intrinsics to be exposed through public
60+
abstractions.
61+
62+
Currently, "Rust" foreign functions may not be generic; this change
63+
will require a special case that allows intrinsics to be generic.
64+
5765
# Alternatives
5866

59-
1. Instead of the new `#[intrinsic]` attribute we could make intrinsics
60-
lang items. This would require either forcing them to be 'singletons'
61-
or create a new type of lang item that can be multiply-declared.
67+
1. Instead of making intrinsics lang items we could create a slightly
68+
different mechanism, like an `#[intrinsic]` attribute, that would
69+
continue letting intrinsics to be redeclared.
70+
71+
2. While using lang items to identify intrinsics, intrinsic lang items
72+
*could* be allowed to be redeclared.
6273

63-
2. We could also make "rust-intrinsic" coerce or otherwise be the same
74+
3. We could also make "rust-intrinsic" coerce or otherwise be the same
6475
as "Rust" externs and normal Rust functions.
6576

6677
# Unresolved questions

0 commit comments

Comments
 (0)