-
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 more information for HRTB lifetime errors involving closures #79588
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
note: the lifetime requirement is introduced here | ||
--> $DIR/issue-79187-2.rs:5:21 | ||
| | ||
LL | fn take_foo(_: impl Foo) {} | ||
| ^^^ |
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.
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...
r? @oli-obk |
| - - ^ 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` |
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.
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
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. |
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 |
@bors r=oli-obk |
📌 Commit a8a9742 has been approved by |
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
No description provided.