Skip to content

Suggest parentheses for possible range method calling #102454

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Oct 17, 2022

Conversation

chenyukang
Copy link
Member

Fixes #102396

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 29, 2022
@rust-highfive
Copy link
Contributor

r? @TaKO8Ki

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 29, 2022
@chenyukang chenyukang force-pushed the fix-102396-missing-parentheses branch from 5039d7e to 04e6dc4 Compare September 29, 2022 06:01
@chenyukang chenyukang marked this pull request as draft September 30, 2022 07:28
@rust-log-analyzer

This comment has been minimized.

@chenyukang chenyukang force-pushed the fix-102396-missing-parentheses branch from 6c0766b to 2e717c6 Compare September 30, 2022 15:35
@chenyukang chenyukang marked this pull request as ready for review September 30, 2022 15:36
@chenyukang chenyukang force-pushed the fix-102396-missing-parentheses branch 2 times, most recently from 5ee7bdb to 348d082 Compare October 1, 2022 00:58
@chenyukang chenyukang force-pushed the fix-102396-missing-parentheses branch from 348d082 to 86947ab Compare October 1, 2022 08:26
@rustbot rustbot added the A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic label Oct 1, 2022
@rustbot
Copy link
Collaborator

rustbot commented Oct 1, 2022

rustc_error_messages was changed

cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki

@bors
Copy link
Collaborator

bors commented Oct 4, 2022

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

@chenyukang chenyukang force-pushed the fix-102396-missing-parentheses branch from 17f2311 to c141b82 Compare October 4, 2022 09:32
@chenyukang chenyukang force-pushed the fix-102396-missing-parentheses branch from c141b82 to 854844e Compare October 4, 2022 09:40
@chenyukang chenyukang force-pushed the fix-102396-missing-parentheses branch from 854844e to e747201 Compare October 4, 2022 15:38
@chenyukang
Copy link
Member Author

r? @lcnr
Help me on merging it, afraid need to rebase with master again, 😁

@rust-highfive rust-highfive assigned lcnr and unassigned TaKO8Ki Oct 13, 2022
Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

some small nits, then r=me

Comment on lines 1260 to 1261
let pick =
self.lookup_probe(span, item_name, range_ty, expr, ProbeScope::AllTraits);
Copy link
Contributor

Choose a reason for hiding this comment

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

can you emit a comment for why we're using ProbeScope::AllTraits here, I remember that you mentioned the reason for that before but I forgot that again 😁

also, i think ideally we would use probe_for_name directly here with IsSuggestion(true). Not sure what IsSuggestion does but we are emitting a suggestion here, so setting that to true seems like it should be done 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems IsSuggestion only used at here:

if !self.is_suggestion.0 && !unstable_candidates.is_empty() {

Use ProbeScope::TraitsInScope can not find the pick, but ProbeScope::AllTraits will find it.

Copy link
Contributor

Choose a reason for hiding this comment

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

it seems helpful to not emit unstable_name_collision_hints while looking for diagnostics, so that should still be done.

ProbeScope::TraitsInScope that feels weird and shouldn't be the case as Iterator is in scope. Is this still the case with the current code?

Copy link
Member Author

Choose a reason for hiding this comment

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

updated the code to use probe_for_name.

ProbeScope::TraitsInScope means find with the scope of expr,

probe_cx.assemble_extension_candidates_for_traits_in_scope(scope_expr_id)

othewise try to find methods in all traits.

At this function, we are at a point of error handling of range type checking, since error happened so the Iterator is not in the scope? it's only my guess😁

@lcnr
Copy link
Contributor

lcnr commented Oct 17, 2022

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 17, 2022

📌 Commit 151001c has been approved by lcnr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 17, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 17, 2022
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#102454 (Suggest parentheses for possible range method calling)
 - rust-lang#102466 (only allow `ConstEquate` with `feature(gce)`)
 - rust-lang#102945 (Do not register placeholder `RegionOutlives` obligations when `considering_regions` is false)
 - rust-lang#103091 (rustdoc: remove unused HTML class `sidebar-title`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 66de34b into rust-lang:master Oct 17, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 17, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing parentheses for range leads to misleading help suggestion
10 participants