Skip to content

Conversation

@rperier
Copy link
Contributor

@rperier rperier commented Nov 7, 2025

As discussed on zulip with @lcnr, this is a proposal for refactorizing this method.

See #t-compiler/help > (PR #144674) Merge multiple suggestions into a single @ 💬

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 7, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 7, 2025

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rperier
Copy link
Contributor Author

rperier commented Nov 7, 2025

r? @lcnr

@rustbot rustbot assigned lcnr and unassigned wesleywiser Nov 7, 2025
@rperier rperier force-pushed the report_no_match_method_error-refactoring branch from 9a8910e to 177bb33 Compare November 7, 2025 15:25
@rust-log-analyzer

This comment has been minimized.

@lcnr lcnr changed the title Cleanup and refactorize FnCtxt::report_no_match_method_error Cleanup and refactor FnCtxt::report_no_match_method_error Nov 7, 2025
@lcnr
Copy link
Contributor

lcnr commented Nov 7, 2025

For changes which move a bunch of code around it's really helpful to split it into individual commits, e.g. if you have "move things into a whatever_its_called sub-fn" this is a lot nicer to review as a separate commit. Think this is fine for now, but please do so in future PRs

) {
let mut find_candidate_for_method = false;

if should_label_not_found && !custom_span_label {
Copy link
Contributor

Choose a reason for hiding this comment

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

do this in the caller and only have a single bool argument?

Comment on lines 1165 to 1157
let mut restrict_type_params = false;
let mut suggested_derive = false;
let mut unsatisfied_bounds = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

these 3 bools are very ☠️ would be nice to look into how to make them unnecessary or somehow unify their intended impact

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mhhhh Some of theses errors are mutually exclusive : restrict_type_params and suggested_derive. So an enum perhaps... what do you think ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This enum might be returned by the function suggest_unsatisfied_ty_or_trait

Copy link
Contributor

Choose a reason for hiding this comment

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

so I think there's "what's the current behavior" and "what should it be". As in, should these errors be exclusive or would it be fine to simplify the control flow here.

I think if you want to keep this as a purely structural change, having 3 bools isn#t the worst thing in the world.

Idk how I feel about an enum, it might be slightly cleaner, but my issue is mainly that we have this mangled controlflow in the first place :>

@rperier rperier force-pushed the report_no_match_method_error-refactoring branch from 177bb33 to 2057779 Compare November 19, 2025 16:39
@rustbot

This comment has been minimized.

@rperier
Copy link
Contributor Author

rperier commented Nov 19, 2025

I have splitted the changes into severals commits, it will be easier to review. I have included most of the requested changes already.

@rperier
Copy link
Contributor Author

rperier commented Nov 19, 2025

The conversations I kept opened are still unclear to me, but at least we can discuss on a sound basis (and reviewable)

…od_error

Currently this method is quiet long and complex, this commit
refactors it and improves its readability by adding sub-fn
…thod_error

Currently this method is quiet long and complex, this commit
refactors it and improves its readability by adding sub-fn
…hod_error

Currently this method is quiet long and complex, this commit
refactors it and improves its readability by adding sub-fn
…d_error

Currently this method is quiet long and complex, this commit
refactors it and improves its readability by adding sub-fn
…o_match_method_error

Currently this method is quiet long and complex, this commit
refactors it and improves its readability by adding sub-fn
…t_no_match_method_error

Currently this method is quiet long and complex, this commit
refactors it and improves its readability by adding sub-fn
…eport_no_match_method_error

Currently this method is quiet long and complex, this commit
refactors it and improves its readability by adding sub-fn
Currently this method is quiet long and complex, this commit
improves its readability, refactor and cleanup few things
@rperier rperier force-pushed the report_no_match_method_error-refactoring branch from 2057779 to 4c952eb Compare November 22, 2025 18:45
@rustbot
Copy link
Collaborator

rustbot commented Nov 22, 2025

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@lcnr
Copy link
Contributor

lcnr commented Nov 24, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Nov 24, 2025

📌 Commit 4c952eb 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 Nov 24, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 24, 2025
…or-refactoring, r=lcnr

Cleanup and refactor FnCtxt::report_no_match_method_error

As discussed on zulip with `@lcnr,` this is a proposal for refactorizing this method.

See [#t-compiler/help > (PR rust-lang#144674) Merge multiple suggestions into a single @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.28PR.20.23144674.29.20Merge.20multiple.20suggestions.20into.20a.20single/near/539991695)
bors added a commit that referenced this pull request Nov 24, 2025
Rollup of 3 pull requests

Successful merges:

 - #148652 (Cleanup and refactor FnCtxt::report_no_match_method_error)
 - #149200 (Add test for derive helper compat collisions)
 - #149274 (Fix invalid link generation for type alias methods)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 25, 2025
…or-refactoring, r=lcnr

Cleanup and refactor FnCtxt::report_no_match_method_error

As discussed on zulip with ``@lcnr,`` this is a proposal for refactorizing this method.

See [#t-compiler/help > (PR rust-lang#144674) Merge multiple suggestions into a single @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.28PR.20.23144674.29.20Merge.20multiple.20suggestions.20into.20a.20single/near/539991695)
bors added a commit that referenced this pull request Nov 25, 2025
Rollup of 3 pull requests

Successful merges:

 - #148652 (Cleanup and refactor FnCtxt::report_no_match_method_error)
 - #149268 (add implementation-internal namespace for globalasm)
 - #149274 (Fix invalid link generation for type alias methods)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Nov 25, 2025
Rollup of 8 pull requests

Successful merges:

 - #147736 (Stabilize `asm_cfg`)
 - #148652 (Cleanup and refactor FnCtxt::report_no_match_method_error)
 - #149167 (skip checking supertraits in object candidate for `NormalizesTo` goal)
 - #149210 (fix: Do not ICE on normalization failure of an extern static item)
 - #149268 (add implementation-internal namespace for globalasm)
 - #149274 (Fix invalid link generation for type alias methods)
 - #149302 (Fix comment wording in simplify_comparison_integral.rs)
 - #149305 (Simplify OnceCell Clone impl)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7c96106 into rust-lang:main Nov 25, 2025
11 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 25, 2025
rust-timer added a commit that referenced this pull request Nov 25, 2025
Rollup merge of #148652 - rperier:report_no_match_method_error-refactoring, r=lcnr

Cleanup and refactor FnCtxt::report_no_match_method_error

As discussed on zulip with ```@lcnr,``` this is a proposal for refactorizing this method.

See [#t-compiler/help > (PR #144674) Merge multiple suggestions into a single @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.28PR.20.23144674.29.20Merge.20multiple.20suggestions.20into.20a.20single/near/539991695)
github-actions bot pushed a commit to rust-lang/compiler-builtins that referenced this pull request Nov 27, 2025
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#147736 (Stabilize `asm_cfg`)
 - rust-lang/rust#148652 (Cleanup and refactor FnCtxt::report_no_match_method_error)
 - rust-lang/rust#149167 (skip checking supertraits in object candidate for `NormalizesTo` goal)
 - rust-lang/rust#149210 (fix: Do not ICE on normalization failure of an extern static item)
 - rust-lang/rust#149268 (add implementation-internal namespace for globalasm)
 - rust-lang/rust#149274 (Fix invalid link generation for type alias methods)
 - rust-lang/rust#149302 (Fix comment wording in simplify_comparison_integral.rs)
 - rust-lang/rust#149305 (Simplify OnceCell Clone impl)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

6 participants