Skip to content

Conversation

@WaffleLapkin
Copy link
Member

In examples like this, where we have a projection type, which is the only associated item with its name in a trait that is in scope:

trait Trait {
    type Assoc;

    fn f(self) -> Self::Assoc;
}

fn f<T: Trait>(x: T) {
    let y /*here*/ = x.f();
    _ = y;
}

Show T::Assoc instead of <T as Trait>::Assoc.

Rationale: making inlay hints less verbose is generally good, Trait is not that useful there.


I'm not sure if the implementation is good and correct, but it seems to be working at least 😅

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 23, 2022
Copy link
Contributor

@lowr lowr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I understand the motivation and the logic looks correct, I'm a bit concerned about the performance here; iterating through every associated item of every trait in scope sounds a bit expensive especially for large files. I guess it's okay for typical codebases as it's fairly rare to show projection types, but we might want to assess the effect or add a configuration to opt it out.

Another thing is that it might be somewhat confusing unless the self type of the projection is either placeholder type or ADT. T::Assoc and Vec<i32>::Assoc seem nice, but (T, U)::Assoc, impl Trait + Clone::Assoc, and &dyn Trait + Send::Assoc look foreign to me. Also, <&T as Trait>::Assoc would be displayed as &T::Assoc, which is indistinguishable from &<T as Trait>::Assoc.

@bors
Copy link
Contributor

bors commented Jan 8, 2023

☔ The latest upstream changes (presumably #13860) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-cloud-vms rust-cloud-vms bot force-pushed the shorten_projections branch from e7ccf34 to 3a97175 Compare January 9, 2023 15:14
@bors
Copy link
Contributor

bors commented Jan 14, 2023

☔ The latest upstream changes (presumably #13946) made this pull request unmergeable. Please resolve the merge conflicts.

@Veykril
Copy link
Member

Veykril commented Mar 15, 2023

I agree with lowr's comment here, this does seem like a performance pitfall and the ambiguity cases mentioned aren't too nice either. So I am inclined to close this for now.

@Veykril Veykril closed this Mar 15, 2023
@WaffleLapkin
Copy link
Member Author

Just to be clear: is this an issue of "the implementation is not good enough, needs more work" or "this looks hard/impossible to do in a good way in general"?

@Veykril
Copy link
Member

Veykril commented Mar 17, 2023

I would say, more work required. I do think having this wouldn't be too bad, but I also don't know if this can be done in a way that is not too performance heavy (inlay hints already take way too long to calculate as is). So unfortunately I can only give a vague answer here :)

@WaffleLapkin
Copy link
Member Author

Okay, I don't have enough time/energy to work on this, but hopefully I'll eventually try to revive this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants