-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Improve RTN support (resolution + analysis; jump to definition, etc) #19303
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
How does RTN work wrt. the trait env? I mean, it needs to be part of the trait env because it can introduce bounds, but we also need the trait env to lower it (to iterate over methods) - so how do we build it? In two steps? |
@ChayimFriedman2: RTN is no different than associated types wrt lowering and resolution, except for the namespace that it resolves its associated item in, and some caveats about introducing new higher ranked lifetimes for all the generics in scope. It should use the same strategy for resolving In rustc, we don't need to lower an RTN type to iterate over methods, since we just need the list of methods and to inspect their HIR (that is, not their |
Does that means we need another kind of Chalk bound, and a way for Chalk to ask us to normalize it? |
No. Let me explain:
In Thus it ends up lowering like: |
@compiler-errors How does rustc infers the value of the implicit associated type of RTN for impls? E.g.: trait Trait {
fn foo() -> Option<impl Sized>;
}
impl Trait for () {
fn foo() -> Option<i32> { 0 }
} The implicit associated type should be (It seems rust-analyzer does not yet lower RPITIT to associated types, so I'll have to do that first). |
https://rustc-dev-guide.rust-lang.org/return-position-impl-trait-in-trait.html#the-rpitit-inference-algorithm has some info for the inference algorithm we use for RPITITs |
rust-analyzer version: rust-analyzer version: 0.3.2330-standalone (02862f5 2025-03-03)
rustc version: rustc 1.87.0-nightly (f9e0239a7 2025-03-04)
editor or extension: VSCode
relevant settings: N/A
repository link (if public, optional): N/A
code snippet to reproduce:
Hiya. r-a still lacks RTN support in resolution and presumably elsewhere in the type system, so I'm opening a tracking issue for that :) I'd be happy to mentor any technical work here to improve RTN (especially to help understand how RTN works in rustc), since I'm looking to stabilize RTN soon.
The text was updated successfully, but these errors were encountered: