-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Tracking issue for inherent associated types #8995
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
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I'd just like to say thank you to you three for working on this feature! I know it's not simple, but it's something a lot of people will appreciate when it's eventually completed. |
=== stdout === === stderr === error[E0261]: use of undeclared lifetime name `'d` --> /home/runner/work/glacier/glacier/ices/109299.rs:10:21 | 10 | impl<'cursor> Lexer<'d> { | - ^^ undeclared lifetime | | | help: consider introducing lifetime `'d` here: `'d,` error[E0412]: cannot find type `DocCursorImpl` in this scope --> /home/runner/work/glacier/glacier/ices/109299.rs:11:23 | 11 | type Cursor<'a> = DocCursorImpl<'a>; | ^^^^^^^^^^^^^ not found in this scope error[E0658]: inherent associated types are unstable --> /home/runner/work/glacier/glacier/ices/109299.rs:11:5 | 11 | type Cursor<'a> = DocCursorImpl<'a>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #8995 <rust-lang/rust#8995> for more information = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable error: aborting due to 3 previous errors Some errors have detailed explanations: E0261, E0412, E0658. For more information about an error, try `rustc --explain E0261`. ==============
=== stdout === === stderr === error[E0637]: `&` without an explicit lifetime name cannot be used here --> /home/runner/work/glacier/glacier/ices/109071.rs:4:17 | 4 | type Item = &[T]; | ^ explicit lifetime name needed here error[E0601]: `main` function not found in crate `109071` --> /home/runner/work/glacier/glacier/ices/109071.rs:11:2 | 11 | } | ^ consider adding a `main` function to `/home/runner/work/glacier/glacier/ices/109071.rs` error[E0107]: missing generics for struct `Windows` --> /home/runner/work/glacier/glacier/ices/109071.rs:3:9 | 3 | impl<T> Windows { | ^^^^^^^ expected 1 generic argument | note: struct defined here, with 1 generic parameter: `T` --> /home/runner/work/glacier/glacier/ices/109071.rs:1:8 | 1 | struct Windows<T> {} | ^^^^^^^ - help: add missing generic argument | 3 | impl<T> Windows<T> { | +++ error[E0658]: inherent associated types are unstable --> /home/runner/work/glacier/glacier/ices/109071.rs:4:5 | 4 | type Item = &[T]; | ^^^^^^^^^^^^^^^^^ | = note: see issue #8995 <rust-lang/rust#8995> for more information = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable error: aborting due to 4 previous errors Some errors have detailed explanations: E0107, E0601, E0637, E0658. For more information about an error, try `rustc --explain E0107`. ==============
=== stdout === === stderr === warning: the feature `inherent_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes --> /home/runner/work/glacier/glacier/ices/109790.rs:1:12 | 1 | #![feature(inherent_associated_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #8995 <rust-lang/rust#8995> for more information = note: `#[warn(incomplete_features)]` on by default warning: struct `Foo` is never constructed --> /home/runner/work/glacier/glacier/ices/109790.rs:3:8 | 3 | struct Foo<T>(T); | ^^^ | = note: `#[warn(dead_code)]` on by default warning: associated type `Assoc` is never used --> /home/runner/work/glacier/glacier/ices/109790.rs:6:10 | 5 | impl<'a> Foo<fn(&'a ())> { | ------------------------ associated type in this implementation 6 | type Assoc = &'a (); | ^^^^^ warning: function `bar` is never used --> /home/runner/work/glacier/glacier/ices/109790.rs:12:4 | 12 | fn bar(_: for<'a> fn(Foo<fn(&'a ())>::Assoc)) {} | ^^^ warning: 4 warnings emitted ==============
This seems particularly important for resolving 'clippy::type_complexity' when using large types inside parameterized types with multiple arguments. Normally we'd use a Keep to hear more about blockers :) |
The most recent major blocker is fixing #108491 which is not easy it seems. Basically, you cannot use inherent associated types inside of structs, enums, unions or where clauses (as opposed to function bodies, constants and type aliases) and some function signatures without encountering a cycle error first. According to my current understanding this is due to architectural limitations in the compiler (see this semi-related Zulip topic, cc #22519 the equivalent for trait assoc tys). Since #109410 got merged, I'm investigating approaches to solve this in a proper way without too much rework. |
…ypes, r=jsha rustdoc: render visibility on associated types This should only affect inherent associated types (rust-lang#8995).
feat: resolve inherent and implemented associated items in docs This partially fixes #9694. Supported: - Trait methods and constants. * Due to resolution differences pointed out during the review of the PR, trait associated types are _not_ supported. - Inherent methods, constants and associated types. * Inherent associated types are a [nightly feature](rust-lang/rust#8995), and are supported with no additional work in this PR. Screenshot of VS Code running with the change: <img width="513" alt="image" src="https://github.com/rust-lang/rust-analyzer/assets/7189784/c37ed8b7-b572-4684-8e81-2a817b0027c4"> You can see that the items are resolved (excl. trait associated types) since they are semantically highlighted in the doc comment.
Uh oh!
There was an error while loading. Please reload this page.
This is a tracking issue for the "inherent associate type" part of "inherent associated items" part of the RFC 195 "associated items"
Original description for historic preservation
When developing a type-parametric impl, I found myself writing code somewhat like this:
I cannot make a
type
definition forHashMap<NT, ~[Prod<T,NT>]>
outside of theimpl
because it then those free references toNT
andT
would be unbound.And I cannot put a
type
definition within the impl, even an impl for a struct such as this (it simply does not parse with the current grammar).(Being able to put type definitions within impls will probably arise naturally from #5033, when we get around to that. But that is nonetheless a separate issue from this: Associated Types (and Associated Items) are about enabling certain patterns for the user of a trait, while this ticket describes a convenience for the implementor of a struct.)
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
None
Implementation history
AliasKind::Inherent
for inherent associated types #109410The text was updated successfully, but these errors were encountered: