Skip to content

Tracking Issue for externally implementable items #125418

Open
@traviscross

Description

@traviscross
Contributor

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

  • Get alternate proposals.
  • Pick a design for the experiment.
    • Approval
  • Implement the experiment.
  • Verify proposals are consistent with:
  • Write/update RFC based on experiment.
    Accept an RFC.
  • Add documentation to the dev guide.
  • Add documentation to the reference.
  • Add formatting for new syntax to the style guide.

Unresolved Questions

  • Which exact alternative or alternatives should we adopt?

Related

Implementation history

TODO.

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

Activity

added
T-langRelevant to the language team
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
B-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).
on May 22, 2024
m-ou-se

m-ou-se commented on Sep 19, 2024

@m-ou-se
Member

@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!

removed
I-lang-nominatedNominated for discussion during a lang team meeting.
on Sep 19, 2024
Amanieu

Amanieu commented on Oct 1, 2024

@Amanieu
Member

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

m-ou-se commented on Oct 24, 2024

@m-ou-se
Member

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.

18 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

B-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-extern_item_impls`#![feature(extern_item_impls)]`T-langRelevant to the language team

Type

No type

Projects

Status

Exploration

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @Enselic@nikomatsakis@Amanieu@LegNeato@m-ou-se

      Issue actions

        Tracking Issue for externally implementable items · Issue #125418 · rust-lang/rust