fix: Auto completion should use fully qualified syntax in case of ambiguity #18895 #21306
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix #18895
Updated the completion renderer to detect when a trait method is being completed via a type path and rewrite the edit to the UFCS form (
<Ty as Trait>::method) before emitting the completion item, including the new UfcsData/CallSnippetRewrite plumbing and trait-container detection in render_fn so both plain inserts and call-paren snippets respect the wider replacement range.Extended add_call_parens to accept the optional rewrite data, build snippets using the qualified call head, and emit a TextEdit that spans the entire qualifier when necessary.
Added helper utilities to compute the qualifier text/range, render the trait path, and decide when UFCS rewriting is appropriate so the logic stays isolated and testable.
Added a regression test that exercises completing Dog:: when only a trait implementation exists to ensure the completion now expands to
<Dog as Animal>::baby_name().