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

Tracking Issue for externally implementable items #125418

Open
6 of 15 tasks
traviscross opened this issue May 22, 2024 · 3 comments
Open
6 of 15 tasks

Tracking Issue for externally implementable items #125418

traviscross opened this issue May 22, 2024 · 3 comments
Labels
B-experimental Blocker: In-tree experiment; RFC pending or unneeded. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-extern_item_impls `#![feature(extern_item_impls)]` T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@traviscross
Copy link
Contributor

traviscross commented May 22, 2024

This is a tracking issue for the lang experiment on externally implementable items. This currently covers these proposals:

The feature gate for the issue is #![feature(extern_item_impls)].

About tracking issues

Tracking issues are used to record the overall progress of implementation. They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions. A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature. Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

Unresolved Questions

  • Which exact alternative or alternatives should we adopt?

Related

Implementation history

TODO.

cc @m-ou-se @Amanieu @tmandry @joshtriplett

@traviscross traviscross added T-lang Relevant to the language team, which will review and decide on the PR/issue. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. B-experimental Blocker: In-tree experiment; RFC pending or unneeded. F-extern_item_impls `#![feature(extern_item_impls)]` labels May 22, 2024
@traviscross traviscross added the I-lang-nominated Nominated for discussion during a lang team meeting. label May 22, 2024
@m-ou-se
Copy link
Member

m-ou-se commented Sep 19, 2024

@jdonszelmann and I are currently implementing this, with a different syntax. Instead of using new syntax (e.g. extern impl fn ...) as in the RFC draft, we're using attributes instead:

#[externally_implementable(thing_handler)]
fn do_thing();
#[thing_handler]
fn my_thing_handler() {
    ..;
}

This has a number of advantages. #[thing_handler] could be replaced by a proc_macro in semver-compatible versions of the crate, so we don't need to worry about providing conversion/upgrade mechanisms. It also makes it look identical to #[panic_handler] and #[global_allocator] attributes. It clarifies the naming and visibility issue: do_thing is the function to call, and #[thing_handler] is the attribute to override it, so they each have their own name and visibility. And it allows us to place unsafe in the attribute itself, to separate "unsafe to implement" and "unsafe to call".

More updates soon!

@m-ou-se m-ou-se removed the I-lang-nominated Nominated for discussion during a lang team meeting. label Sep 19, 2024
@Amanieu
Copy link
Member

Amanieu commented Oct 1, 2024

Does this introduce a new global namespace for thing_handler? I would prefer if this was a proper path to an item within a crate since that properly takes care of things like multiple instances of the same crate with different major versions.

@m-ou-se
Copy link
Member

m-ou-se commented Oct 24, 2024

Does this introduce a new global namespace for thing_handler?

Nope! It behaves the same as any other attribute (macro), as an item with a path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-experimental Blocker: In-tree experiment; RFC pending or unneeded. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-extern_item_impls `#![feature(extern_item_impls)]` T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants