Skip to content

diagnostics: do not give Option::as_ref suggestion for complex match #95127

New issue

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

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

Already on GitHub? Sign in to your account

Conversation

notriddle
Copy link
Contributor

Fixes #82528

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

r? @estebank

(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 Mar 19, 2022
@estebank
Copy link
Contributor

I'm guessing it'd be difficult to find the correct span to suggest .as_ref() inside the tuple? It might also be reasonable to mention .as_ref() in a note instead.

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 22, 2022

📌 Commit 306dcd6 has been approved by estebank

@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 Mar 22, 2022
@notriddle
Copy link
Contributor Author

notriddle commented Mar 22, 2022

I'm guessing it'd be difficult to find the correct span to suggest .as_ref() inside the tuple?

Basically, there might not be a correct span.

I would have needed to go back to the THIR and walked the expr tree looking for it, with no guarantee of finding it, so no matter what happens we’ll need a fallback path eventually.

match me() {
    (a, Some(b)) => use(a, b)
}
fn me() -> (Foo, &Option<Bar>) {}
fn use(a: Foo, b: &Bar) {}

@bors
Copy link
Collaborator

bors commented Mar 22, 2022

⌛ Testing commit 306dcd6 with merge 2d15732...

@bors
Copy link
Collaborator

bors commented Mar 22, 2022

☀️ Test successful - checks-actions
Approved by: estebank
Pushing 2d15732 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 22, 2022
@bors bors merged commit 2d15732 into rust-lang:master Mar 22, 2022
@rustbot rustbot added this to the 1.61.0 milestone Mar 22, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2d15732): comparison url.

Summary: This benchmark run did not return any relevant results.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

@notriddle notriddle deleted the notriddle/option-content-move-from-tuple-match branch March 22, 2022 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

Invalid suggestion to consider borrowing Option's content in tuple
6 participants