-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Open
Labels
B-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).Blocker: 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 RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-extern_item_impls`#![feature(extern_item_impls)]``#![feature(extern_item_impls)]`T-langRelevant to the language teamRelevant to the language team
Description
This is a tracking issue for the lang experiment on externally implementable items. This currently covers these proposals:
- [RFC] externally implementable functions rfcs#3632
- [RFC] externally definable statics rfcs#3635
- Externally implementable traits rfcs#3645
- RFC: Existential types with external definition rfcs#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. [RFC] externally implementable functions rfcs#3632
- Alternative proposal from @m-ou-se. [RFC] externally definable statics rfcs#3635
- Alternative proposal from @Amanieu. Externally implementable traits rfcs#3645
- Alternative proposal from @tmandry. [RFC] externally implementable functions rfcs#3632 (comment)
- Pick a design for the experiment.
- Using attributes rather than new syntax: Tracking Issue for externally implementable items #125418 (comment)
- Submit project goal: Add project goal: Externally Implemtable Items (EII) rust-project-goals#198
- Approval
- Implement the experiment.
- First fix attributes so we can do name resolution in them: Attribute handling reworks compiler-team#796
- Implement externally implementable items using attributes: Externally implementable items #146348
- Check
no_mangleon EIIs is rejected properly - Hundreds of
missing stability attributeerrors with trivial Externally Implementable Item (eii) function inlibrary/std#150514- make them semiopaque compiler: Make Externally Implementable Item (eii) macros "semiopaque" #151046
- ICE: eii on impl:
expected statement#149980 - ICE: eii on generic
Instance::mono: DefId(..) has type parameters#149983 - ICE: eii: fn / macro rules
Nonein find_attr() #149981 - Busywork
- rename eii_extern_target Rename EII attributes slightly (being consistent in naming things foreign items, not extern items) #150972
- Rename extern to foreign everywhere Rename EII attributes slightly (being consistent in naming things foreign items, not extern items) #150972
- Disallow in statement position Disallow eii in statement position #150971
- Simplify expansion using ecx Simplify
#[eii]macro using methods on ecx #150906 - Compute alias symbols during codegen Store defids instead of symbol names in the aliases list #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: compiler: Forward attributes to eii-expanded macros #150913
- 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: Use the .drectve section for exporting symbols from dlls on Windows #142568, [WIP] Use weak linkage instead of compiler generated shims #134522, [WIP] Use weak aliases for the allocator shim #142366, )
- macos support (context: Externally implementable items #146348 (comment))
- Support
-Cprefer-dynamic
- Implement for Miri
- EIIs as statics
- Demonstrations:
- rewrite panic_handler in terms of EII. Should be easy, no weak symbols needed
- (WIP) on-broken-pipe Use the .drectve section for exporting symbols from dlls on Windows #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
- [RFC] externally implementable functions rfcs#3632
- [RFC] externally definable statics rfcs#3635
- Externally implementable traits rfcs#3645
- RFC: Existential types with external definition rfcs#2492
Implementation history
Enselic, Random-Scientist, lolbinarycat and boozookm-ou-se, Dirbaio, jdonszelmann, Enselic, skreborn and 4 more
Metadata
Metadata
Assignees
Labels
B-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).Blocker: 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 RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-extern_item_impls`#![feature(extern_item_impls)]``#![feature(extern_item_impls)]`T-langRelevant to the language teamRelevant to the language team
Type
Projects
Status
Exploration