Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upIntrinsic semantics #1300
Conversation
alexcrichton
added
T-compiler
T-lang
labels
Sep 30, 2015
This comment has been minimized.
This comment has been minimized.
|
This RFC seems good, if we want intrinsics (I've not read it in super detail). However, I have been thinking of floating a proposal to remove intrinsics altogether, in fact, and simply have lang items only. This is still my preference: lang items and intrinsics overlap in purpose quite a bit, but lang items are significantly more general, and it seems like the better mechanism. |
This comment has been minimized.
This comment has been minimized.
|
Note that I think this RFC really belongs to @rust-lang/lang and not @rust-lang/compiler, so I'm going to remove the T-compiler tag. |
nikomatsakis
removed
the
T-compiler
label
Oct 1, 2015
nikomatsakis
assigned
pnkfelix
Oct 1, 2015
This comment has been minimized.
This comment has been minimized.
|
So... this RFC as written is just attempting to codify one aspect of the current intrinsic system, since it explicitly makes no changes at all? @nikomatsakis any reason to not just accept this in the short tern, since a later hypothetical RFC removing intrinsics will supercede it? (Also, won't you hit the same bike shed with the intrinsics encoded as lang items? Seems like if we want to codify this "only callable" idea, then we'd need a concept to capture that anyway |
This comment has been minimized.
This comment has been minimized.
|
Hmm, yes, I initially assumed the RFC went a bit further than it did. I am fine with it in terms of documenting existing policy. |
This comment has been minimized.
This comment has been minimized.
|
To expand on the lang item idea @nikomatsakis described somewhere else: #[lang = "intrinsic.move_val_init"]
pub unsafe fn move_val_init<T>(dst: *mut T, src: T) {
unreachable!()
}We could make the intrinsics "call themselves": #[lang = "intrinsic.move_val_init"]
pub unsafe fn move_val_init<T>(dst: *mut T, src: T) {
move_val_init(dst, src)
}While this looks like infinite recursion, remember that direct calls to intrinsics are expanded in-place. So what this definition would do is create a wrapper function for the intrinsic operation, and you can get the wrapper function by coercing Otherwise, its type is a function item type, containing the item ID allowing calls to be expanded in-place, in a more flexible way than the existing |
This comment has been minimized.
This comment has been minimized.
|
@eddyb hey, that's clever :) |
This comment has been minimized.
This comment has been minimized.
|
where have i seen that before ... ;) |
This comment has been minimized.
This comment has been minimized.
Don't our own built-in operators do the same thing? They are intrinsics too in some sense. |
This comment has been minimized.
This comment has been minimized.
|
|
nikomatsakis
added
the
final-comment-period
label
Nov 6, 2015
nikomatsakis
merged commit 40cbce9
into
rust-lang:master
Nov 16, 2015
nikomatsakis
added a commit
that referenced
this pull request
Nov 16, 2015
This comment has been minimized.
This comment has been minimized.
|
Huzzah! The language design subteam has decided to accept this RFC. |
This comment has been minimized.
This comment has been minimized.
target-san
commented
Nov 25, 2015
|
If you ask me, I'd rather use extern-like approach, with no body. Either unreachable!(), empty body or self-invocation are all confusing. Intrinsics don't have known body definable in terms of Rust language. |
This comment has been minimized.
This comment has been minimized.
|
@target-san I would argue that self-invocation is a sane definition (for the wrapper function that you would get with an indirect call to an intrinsic). |
Aatch commentedSep 29, 2015
Kinda tired of intrinsics causing so much tangential discussion. This makes the current system concrete. If you feel strongly about some other way, please, please write an RFC for that way so it can be the defined semantics.
Rendered