Tracking Issue for externally implementable items
@jdonszelmann is already working on this.
Since Dec 18, 2025.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
This is a tracking issue for the lang experiment on externally implementable items. This currently covers these proposals:
- https://github.com/rust-lang/rfcs/pull/3632
- https://github.com/rust-lang/rfcs/pull/3635
- https://github.com/rust-lang/rfcs/pull/3645
- https://github.com/rust-lang/rfcs/pull/2492
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
- Get alternate proposals.
- Original proposal from @m-ou-se. https://github.com/rust-lang/rfcs/pull/3632
- Alternative proposal from @m-ou-se. https://github.com/rust-lang/rfcs/pull/3635
- Alternative proposal from @Amanieu. https://github.com/rust-lang/rfcs/pull/3645
- Alternative proposal from @tmandry. https://github.com/rust-lang/rfcs/pull/3632#issuecomment-2125972702
- Pick a design for the experiment.
- Using attributes rather than new syntax: https://github.com/rust-lang/rust/issues/125418#issuecomment-2360542039
- Submit project goal: https://github.com/rust-lang/rust-project-goals/pull/198
- Approval
- Implement the experiment.
- First fix attributes so we can do name resolution in them: https://github.com/rust-lang/compiler-team/issues/796
- Implement externally implementable items using attributes: https://github.com/rust-lang/rust/pull/146348
- Check
no_mangleon EIIs is rejected properly - https://github.com/rust-lang/rust/issues/150514
- make them semiopaque https://github.com/rust-lang/rust/pull/151046
- https://github.com/rust-lang/rust/issues/149980
- https://github.com/rust-lang/rust/issues/149983
- https://github.com/rust-lang/rust/issues/149981
- Busywork
- rename eii_extern_target https://github.com/rust-lang/rust/pull/150972
- Rename extern to foreign everywhere https://github.com/rust-lang/rust/pull/150972
- Disallow in statement position https://github.com/rust-lang/rust/pull/150971
- Simplify expansion using ecx https://github.com/rust-lang/rust/pull/150906
- Compute alias symbols during codegen https://github.com/rust-lang/rust/pull/150811
- Reduce encoding time: remove extern target from encoded decl (it's duplicated)
- Similar for the encoded EiiImpl
- Track caller on the declaration
- Look at attribute forwarding
-
For now: fwd everything: https://github.com/rust-lang/rust/pull/150913 - reject all but a few https://github.com/rust-lang/rust/pull/157312
-
- Test resolving to a proc (attribute) macro
- Platform support:
- Implement for codegen_gcc (needs support for aliases)
- Implement for windows
- mingw needs a trick similar to how alloc handlers are currently generated
- msvc needs us to implement /export inside the linker flags (see: https://github.com/rust-lang/rust/pull/142568, https://github.com/rust-lang/rust/pull/134522, https://github.com/rust-lang/rust/pull/142366, )
- macos support https://github.com/rust-lang/rust/pull/151733
- Support
-Cprefer-dynamic
- Implement for Miri https://github.com/rust-lang/miri/issues/5247
- EIIs as statics https://github.com/rust-lang/rust/pull/154193
- Demonstrations:
- rewrite panic_handler in terms of EII. Should be easy, no weak symbols needed
- (WIP) on-broken-pipe https://github.com/rust-lang/rust/pull/142568
- rewrite alloc_handler in terms of EII. Harder because it requires defaults
- Verify proposals are consistent with:
- Write/update RFC based on experiment.
- Accept an RFC.
- Add documentation to the dev guide.
- See the instructions.
- Add documentation to the reference.
- See the instructions.
- Add formatting for new syntax to the style guide.
- See the nightly style procedure.
Unresolved Questions
- Which exact alternative or alternatives should we adopt?
Related
- https://github.com/rust-lang/rfcs/pull/3632
- https://github.com/rust-lang/rfcs/pull/3635
- https://github.com/rust-lang/rfcs/pull/3645
- https://github.com/rust-lang/rfcs/pull/2492
Implementation history
cc @m-ou-se @Amanieu @tmandry @joshtriplett
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.