-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Tracking Issue for RFC 3591: use
ing a function from a trait
#134691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Might be worth noting that there is an orthogonal implementation of using a trait function through the unstable #![feature(fn_delegation)]
reuse Default::default;
fn main() {
let s: i32 = default();
dbg!(s);
} Although my understanding is that this is just some kind of experiment, and will not be stabilized? |
…sociated_functions, r=oli-obk Implement `use` associated items of traits This PR implements rust-lang#134691.
…sociated_functions, r=oli-obk Implement `use` associated items of traits This PR implements rust-lang#134691.
Rollup merge of rust-lang#134754 - frank-king:feature/import_trait_associated_functions, r=oli-obk Implement `use` associated items of traits This PR implements rust-lang#134691.
unstable book: document import_trait_associated_functions Documents rust-lang#134691 which was implemented in rust-lang#134754
unstable book: document import_trait_associated_functions Documents rust-lang#134691 which was implemented in rust-lang#134754
Rollup merge of rust-lang#139149 - mejrs:itaf, r=ehuss unstable book: document import_trait_associated_functions Documents rust-lang#134691 which was implemented in rust-lang#134754
We were discussing this feature in a @rust-lang/libs-api meeting. We were wondering if the infrastructure that enables this feature would make it straightforward to provide a (separate) feature allowing |
Also, separately from that: what's the status of this feature? Are there any blockers that aren't in the (currently empty) list at the top of this tracking issue? If not, could @rust-lang/lang get a stabilization report, please? |
We have the open PR #138712 that will slightly relax the feature and make it deviate from the RFC. All that's left is another review, then I'll likely approve it (as a T-compiler member). Details can be found over there. |
Not in the slightest. The feature whose development is being tracked here is solely powered by name resolution and its impl basically only needed to lift some artificial restrictions. Referencing a specific inherent associated item on the other hand always requires type checking routines (namely, type unification) because they are first identified by their self type which can be arbitrary and contain aliases that'd need to be normalized first (which requires type checking routines). Don't forget about bounds & where clauses on impls themselves which would need to be checked by the trait solver to weed out impls and to normalize aliases. Furthermore, the current This is T-types territory. Even then, it's incredibly hard to support for the same reason why inherent associated types haven't been implemented for more than a decade — which we can likely only support in a more limited form via HACKs: See #140247 most recently. Note that we also have the feature |
Unlike in |
As long as you have |
This is a tracking issue for the RFC "Add support for
use Trait::func
" (rust-lang/rfcs#3591).The feature gate for the issue is
#![feature(import_trait_associated_functions)]
.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.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.
Steps
use
associated items of traits #134754Unresolved Questions
Implementation history
The text was updated successfully, but these errors were encountered: