-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Permit trait object types where all (non-generic) associated constants are specified (via assoc item bindings) #130300
Copy link
Copy link
Closed
Labels
A-dyn-compatibilityArea: Dyn compatibility (formerly: object safety)Area: Dyn compatibility (formerly: object safety)A-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.F-associated_const_equality`#![feature(associated_const_equality)]``#![feature(associated_const_equality)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Metadata
Metadata
Assignees
Labels
A-dyn-compatibilityArea: Dyn compatibility (formerly: object safety)Area: Dyn compatibility (formerly: object safety)A-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.F-associated_const_equality`#![feature(associated_const_equality)]``#![feature(associated_const_equality)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
Done
We permit trait object types where all 'active'1 non-generic associated types are specified (via assoc item bindings). We should extend this to cover 'active' non-generic2 associated constants, too.
Note that I haven't spent much time thinking about soundness yet. I still need to iron out the exact rules. Implementation-wise, I'm almost certain that any advances are blocked by #120905 (more precisely, its underlying issue) which I presume we would need to fix first for correctness.
Minimal & contrived example of something that would start compiling:
Presently, this gets rejected and we emit E0038 (cannot be made into an object).
Lastly, lest I forget, we should emit the lint
unused_associated_type_bounds3 (#112319) for assoc const bindings where the corresp. assoc const is 'disabled' viawhere Self: Sizedwhich is only possible to write undergeneric_const_items(#113521).Footnotes
I.e., not 'made inactive' / 'disabled' via
where Self: Sized(Don't require associated types with Self: Sized bounds indyn Traitobjects #112319). ↩This might or might not be a temporary restriction. For context, we don't (yet) permit GAT bindings in trait object types either on stable, due to soundness concerns. See
generic_associated_types_extended(Tracking Issue for extended generic associated types #95451). Also note that generic assoc consts (GACs) are only available undergeneric_const_items(Tracking issue for generic const items #113521). ↩Indeed, the name would no longer be accurate. Ideally, we would rename the lint when generalizing it. ↩