-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Provide help on closures capturing self causing borrow checker errors #106641
Conversation
} | ||
|
||
for (span, suggest) in finder.closure_call_changes { | ||
if let Ok(span) = sm.span_extend_while(span, |c| c != '(') { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
2ce36de
to
80fb856
Compare
@bors r+ |
📌 Commit 80fb8561ccfb1bc721942a146a3e04d7c1ce89a5 has been approved by It is now in the queue for this repository. |
🌲 The tree is currently closed for pull requests below priority 999. This pull request will be tested once the tree is reopened. |
80fb856
to
eafbca9
Compare
@bors r+ |
…est-this, r=estebank Provide help on closures capturing self causing borrow checker errors Fixes rust-lang#105761 r? `@estebank`
…est-this, r=estebank Provide help on closures capturing self causing borrow checker errors Fixes rust-lang#105761 r? ``@estebank``
…est-this, r=estebank Provide help on closures capturing self causing borrow checker errors Fixes rust-lang#105761 r? ```@estebank```
…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
Fixes #105761
r? @estebank