Detect existing turbofish on method calls to suppress useless suggestion#153751
Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom Mar 12, 2026
Merged
Conversation
Collaborator
|
Some changes occurred in need_type_info.rs cc @lcnr |
Collaborator
|
r? @chenyukang rustbot has assigned @chenyukang. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
eggyal
approved these changes
Mar 12, 2026
lcnr
reviewed
Mar 12, 2026
Contributor
|
r=me after CI @bors delegate+ |
Contributor
|
✌️ @arferreira, you can now approve this pull request! If @lcnr told you to " |
Contributor
|
r? lcnr |
Contributor
Author
|
@bors r=lcnr |
Contributor
juntyr
reviewed
Mar 12, 2026
| --> $DIR/useless-turbofish-suggestion.rs:19:7 | ||
| | | ||
| LL | S.f::<u32, _>(42); | ||
| | ^ cannot infer type of the type parameter `B` declared on the method `f` |
This comment was marked as duplicate.
This comment was marked as duplicate.
Sorry, something went wrong.
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Mar 12, 2026
…stion, r=lcnr Detect existing turbofish on method calls to suppress useless suggestion `expr_inferred_arg_iter` hardcoded `have_turbofish: false` for `MethodCall` expressions, while the `Path` case properly checked for existing type arguments via `segment.args`. This meant the "consider specifying the generic arguments" suggestion always fired on method calls, even when the user already had a turbofish, producing a suggestion that just rewrote user syntax into fully qualified form without resolving anything. Fixes rust-lang#153732. cc @eggyal
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 12, 2026
…uwer Rollup of 5 pull requests Successful merges: - #153751 (Detect existing turbofish on method calls to suppress useless suggestion) - #153780 (Remove `MTLock`) - #151194 (Fix wrong suggestion for returning async closure) - #151572 (Fix Hexagon ABI calling convention for small aggregates) - #153725 (Fix that `./x test --no-doc` actually keeps the same behaviour for backwards compatability)
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 12, 2026
…uwer Rollup of 5 pull requests Successful merges: - #153705 (Always generate generics in delegation that match trait in trait impl scenario) - #153751 (Detect existing turbofish on method calls to suppress useless suggestion) - #153780 (Remove `MTLock`) - #151572 (Fix Hexagon ABI calling convention for small aggregates) - #153725 (Fix that `./x test --no-doc` actually keeps the same behaviour for backwards compatability)
github-actions bot
pushed a commit
to rust-lang/rustc-dev-guide
that referenced
this pull request
Mar 16, 2026
…uwer Rollup of 5 pull requests Successful merges: - rust-lang/rust#153705 (Always generate generics in delegation that match trait in trait impl scenario) - rust-lang/rust#153751 (Detect existing turbofish on method calls to suppress useless suggestion) - rust-lang/rust#153780 (Remove `MTLock`) - rust-lang/rust#151572 (Fix Hexagon ABI calling convention for small aggregates) - rust-lang/rust#153725 (Fix that `./x test --no-doc` actually keeps the same behaviour for backwards compatability)
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Mar 17, 2026
…ent, r=Kivooeo,eggyal Point turbofish inference errors at the uninferred generic arg Follow-up to rust-lang#153751. When a method call has a turbofish with an uninferred generic argument, point the diagnostic span at the specific `_` that couldn't be inferred instead of the method name. Before: ```rust LL | S.f::<u32, _>(42); | ^ cannot infer type of the type parameter `B` ``` After: ```rust LL | S.f::<u32, _>(42); | ^ cannot infer type of the type parameter `B` ``` Path expressions (`None::<_>`, `foo::<_>()`) are not handled yet, that's a separate code path. cc @eggyal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
expr_inferred_arg_iterhardcodedhave_turbofish: falseforMethodCallexpressions, while thePathcase properly checked for existing type arguments viasegment.args. This meant the "consider specifying the generic arguments" suggestion always fired on method calls, even when the user already had a turbofish, producing a suggestion that just rewrote user syntax into fully qualified form without resolving anything.Fixes #153732.
cc @eggyal