Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

Aatch
Copy link
Contributor

@Aatch Aatch commented Sep 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

@alexcrichton alexcrichton added T-compiler Relevant to the compiler team, which will review and decide on the RFC. T-lang Relevant to the language team, which will review and decide on the RFC. labels Sep 30, 2015
@nikomatsakis
Copy link
Contributor

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.

@nikomatsakis
Copy link
Contributor

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 nikomatsakis removed the T-compiler Relevant to the compiler team, which will review and decide on the RFC. label Oct 1, 2015
@pnkfelix
Copy link
Contributor

pnkfelix commented Oct 7, 2015

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

@nikomatsakis
Copy link
Contributor

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.

@eddyb
Copy link
Member

eddyb commented Oct 9, 2015

To expand on the lang item idea @nikomatsakis described somewhere else:
Instead of having a dummy body such as:

#[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 move_val_init to a fn pointer type.

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 ExprPath-based logic in trans.

@nikomatsakis
Copy link
Contributor

@eddyb hey, that's clever :)

@pnkfelix
Copy link
Contributor

pnkfelix commented Oct 9, 2015

where have i seen that before ... ;)

@petrochenkov
Copy link
Contributor

where have i seen that before ... ;)

Don't our own built-in operators do the same thing? They are intrinsics too in some sense.
https://github.com/rust-lang/rust/blob/master/src/libcore/ops.rs#L616

@nikomatsakis
Copy link
Contributor

🎺 Hear ye, hear ye! 🎺 This RFC is entering final comment period.

@nikomatsakis nikomatsakis added the final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. label Nov 6, 2015
@nikomatsakis nikomatsakis merged commit 40cbce9 into rust-lang:master Nov 16, 2015
nikomatsakis added a commit that referenced this pull request Nov 16, 2015
@nikomatsakis
Copy link
Contributor

Huzzah! The language design subteam has decided to accept this RFC.

@target-san
Copy link

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.

@eddyb
Copy link
Member

eddyb commented Nov 25, 2015

@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).

@Centril Centril added A-machine Proposals relating to Rust's abstract machine. A-intrinsic Proposals relating to intrinsics. labels Nov 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-intrinsic Proposals relating to intrinsics. A-machine Proposals relating to Rust's abstract machine. final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. T-lang Relevant to the language team, which will review and decide on the RFC.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.