Skip to content
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

Provide help on closures capturing self causing borrow checker errors #106641

Merged
merged 2 commits into from
Jan 14, 2023

Conversation

chenyukang
Copy link
Member

Fixes #105761

r? @estebank

@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 Jan 9, 2023
}

for (span, suggest) in finder.closure_call_changes {
if let Ok(span) = sm.span_extend_while(span, |c| c != '(') {
Copy link
Member Author

Choose a reason for hiding this comment

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

Is there any better solution to get the span for suggestion when there is no argument for a call?

Copy link
Contributor

Choose a reason for hiding this comment

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

What you can do when there's no argument is get the span for the whole call

self.foo()
---- self span
     --- method path segment span
     ----- Method span segment
---------- expression span

for function calls is the same: you use the full span and then suggest, instead of "just" "self at this place, you suggest "(self) replacing the (). Does that make sense? It looks worse, but it is more resilient.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I updated the code.

@chenyukang chenyukang force-pushed the yukang/fix-105761-segguest-this branch 2 times, most recently from 2ce36de to 80fb856 Compare January 10, 2023 06:32
@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jan 10, 2023

📌 Commit 80fb8561ccfb1bc721942a146a3e04d7c1ce89a5 has been approved by estebank

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jan 10, 2023

🌲 The tree is currently closed for pull requests below priority 999. This pull request will be tested once the tree is reopened.

@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 Jan 10, 2023
@Noratrieb
Copy link
Member

Tests moved from src/tests to the tests directory in the root, can you rebase and move them?
@bors r-
@rustbot author

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 11, 2023
@bors bors removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 11, 2023
@chenyukang chenyukang force-pushed the yukang/fix-105761-segguest-this branch from 80fb856 to eafbca9 Compare January 12, 2023 12:28
@chenyukang
Copy link
Member Author

Tests moved from src/tests to the tests directory in the root, can you rebase and move them? @bors r- @rustbot author

Rebased to master.

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jan 12, 2023

📌 Commit eafbca9 has been approved by estebank

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 12, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 13, 2023
…est-this, r=estebank

Provide help on closures capturing self causing borrow checker errors

Fixes rust-lang#105761

r? `@estebank`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 13, 2023
…est-this, r=estebank

Provide help on closures capturing self causing borrow checker errors

Fixes rust-lang#105761

r? ``@estebank``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 13, 2023
…est-this, r=estebank

Provide help on closures capturing self causing borrow checker errors

Fixes rust-lang#105761

r? ```@estebank```
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 13, 2023
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#104645 (Add log-backtrace option to show backtraces along with logging)
 - rust-lang#106465 (Bump `IMPLIED_BOUNDS_ENTAILMENT` to Deny + ReportNow)
 - rust-lang#106489 (Fix linker detection for linker (drivers) with a version postfix (e.g. clang-12 instead of clang))
 - rust-lang#106585 (When suggesting writing a fully qualified path probe for appropriate types)
 - rust-lang#106641 (Provide help on closures capturing self causing borrow checker errors)
 - rust-lang#106678 (Warn when using panic-strategy abort for proc-macro crates)
 - rust-lang#106701 (Fix `mpsc::SyncSender` spinning behavior)
 - rust-lang#106793 (Normalize test output more thoroughly)
 - rust-lang#106797 (riscv: Fix ELF header flags)
 - rust-lang#106813 (Remove redundant session field)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 57b371a into rust-lang:master Jan 14, 2023
@rustbot rustbot added this to the 1.68.0 milestone Jan 14, 2023
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.

Provide help on closures capturing self causing borrow checker errors
5 participants