Skip to content

Tracking Issue for externally implementable items #125418

Description

@traviscross

View all comments

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

Example of how to use what's implemented now

#![feature(extern_item_impls)]

#[eii(eii1)]
pub fn decl1(x: u64) 
// body optional (it's the default)
{
    println!("default {x}");
}

// in another crate, maybe
#[eii1]
pub fn decl2(x: u64) {
    println!("explicit {x}");
}

fn main() {
    decl1(4);
}

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

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

Activity

  1. 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).
    I-lang-nominatedNominated for discussion during a lang team meeting.
    on May 22, 2024
  2. 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!

  3. removed
    I-lang-nominatedNominated for discussion during a lang team meeting.
    on Sep 19, 2024
  4. 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.

  5. 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.

  6. self-assigned this
    on Feb 21, 2025
  7. nikomatsakis commented on Feb 21, 2025

    @nikomatsakis
  8. 84 remaining items

  9. added a commit that references this issue on Jul 15, 2026
  10. added 5 commits that reference this issue on Jul 25, 2026
  11. added a commit that references this issue on Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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 teamT-typesRelevant to the types team, which will review and decide on the PR/issue.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions