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 more information for HRTB lifetime errors involving closures #79588

Merged
merged 1 commit into from
Jan 13, 2021

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Dec 1, 2020

No description provided.

@rust-highfive
Copy link
Collaborator

r? @ecstatic-morse

(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 Dec 1, 2020
Comment on lines +14 to +18
note: the lifetime requirement is introduced here
--> $DIR/issue-79187-2.rs:5:21
|
LL | fn take_foo(_: impl Foo) {}
| ^^^
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hadn't considered this case in particular, but ideally we would (also) point at the where clause in impl<F> Foo for F where F: Fn(&i32) -> &i32 for this...

@estebank
Copy link
Contributor Author

estebank commented Dec 1, 2020

This is a mitigation of a stable to stable regression (#75791, older similar issue #41078), but not a fix.

@oli-obk
Copy link
Contributor

oli-obk commented Dec 2, 2020

r? @oli-obk

Comment on lines +5 to +8
| - - ^ returning this value requires that `'1` must outlive `'2`
| | |
| | return type of closure is &'2 i32
| let's call the lifetime of this reference `'1`
Copy link
Contributor

@oli-obk oli-obk Dec 2, 2020

Choose a reason for hiding this comment

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

Not sure if we have the information available anywhere, but could emit a diagnostic of this quality for the the required lifetime does not necessarily outlive the anonymous lifetime #1 defined on the body, too? This occurs in src/test/ui/generator/resume-arg-late-bound.stderr

@oli-obk
Copy link
Contributor

oli-obk commented Dec 2, 2020

The test diffs lgtm, but some of these new tests you added highlight some seriously unhelpful errors. Most of them have an independently emitted helpful error, but not all

@estebank
Copy link
Contributor Author

estebank commented Dec 2, 2020

The test diffs lgtm, but some of these new tests you added highlight some seriously unhelpful errors. Most of them have an independently emitted helpful error, but not all

Indeed. This is gonna be a rabbit-hole to clean up.

@oli-obk
Copy link
Contributor

oli-obk commented Dec 3, 2020

r=me with CI passing (probably just the missing newline). Let's address further improvements in other PRs, it's not necessary to do more in this one

@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 11, 2021
@estebank
Copy link
Contributor Author

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Jan 12, 2021

📌 Commit a8a9742 has been approved by oli-obk

@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, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 13, 2021
Rollup of 10 pull requests

Successful merges:

 - rust-lang#78901 (diagnostics: Note capturing closures can't be coerced to fns)
 - rust-lang#79588 (Provide more information for HRTB lifetime errors involving closures)
 - rust-lang#80232 (Remove redundant def_id lookups)
 - rust-lang#80662 (Added support for i386-unknown-linux-gnu and i486-unknown-linux-gnu)
 - rust-lang#80736 (use Once instead of Mutex to manage capture resolution)
 - rust-lang#80796 (Update to LLVM 11.0.1)
 - rust-lang#80859 (Fix --pretty=expanded with --remap-path-prefix)
 - rust-lang#80922 (Revert "Auto merge of rust-lang#76896 - spastorino:codegen-inline-fns2)
 - rust-lang#80924 (Fix rustdoc --test-builder argument parsing)
 - rust-lang#80935 (Rename `rustc_middle::lint::LevelSource` to `LevelAndSource`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 11bca6b into rust-lang:master Jan 13, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 13, 2021
@estebank estebank deleted the issue-79187 branch November 9, 2023 05:15
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants