Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

ices/93242-2.rs: fixed with errors #1595

Merged
merged 1 commit into from
Jun 4, 2023
Merged

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#93242

pub fn something(path: &[usize]) -> impl Fn() -> usize {
    || match path {
        [] => 0,
        _ => 1,
    }
}

fn main() {}
=== stdout ===
=== stderr ===
error[E0373]: closure may outlive the current function, but it borrows `path`, which is owned by the current function
 --> /home/runner/work/glacier/glacier/ices/93242-2.rs:2:5
  |
2 |     || match path {
  |     ^^       ---- `path` is borrowed here
  |     |
  |     may outlive borrowed value `path`
  |
note: closure is returned here
 --> /home/runner/work/glacier/glacier/ices/93242-2.rs:2:5
  |
2 | /     || match path {
3 | |         [] => 0,
4 | |         _ => 1,
5 | |     }
  | |_____^
help: to force the closure to take ownership of `path` (and any other referenced variables), use the `move` keyword
  |
2 |     move || match path {
  |     ++++

error[E0700]: hidden type for `impl Fn() -> usize` captures lifetime that does not appear in bounds
 --> /home/runner/work/glacier/glacier/ices/93242-2.rs:2:5
  |
1 |   pub fn something(path: &[usize]) -> impl Fn() -> usize {
  |                          --------     ------------------ opaque type defined here
  |                          |
  |                          hidden type `[closure@/home/runner/work/glacier/glacier/ices/93242-2.rs:2:5: 2:7]` captures the anonymous lifetime defined here
2 | /     || match path {
3 | |         [] => 0,
4 | |         _ => 1,
5 | |     }
  | |_____^
  |
help: to declare that `impl Fn() -> usize` captures `'_`, you can add an explicit `'_` lifetime bound
  |
1 | pub fn something(path: &[usize]) -> impl Fn() -> usize + '_ {
  |                                                        ++++

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0373, E0700.
For more information about an error, try `rustc --explain E0373`.
==============

=== stdout ===
=== stderr ===
error[E0373]: closure may outlive the current function, but it borrows `path`, which is owned by the current function
 --> /home/runner/work/glacier/glacier/ices/93242-2.rs:2:5
  |
2 |     || match path {
  |     ^^       ---- `path` is borrowed here
  |     |
  |     may outlive borrowed value `path`
  |
note: closure is returned here
 --> /home/runner/work/glacier/glacier/ices/93242-2.rs:2:5
  |
2 | /     || match path {
3 | |         [] => 0,
4 | |         _ => 1,
5 | |     }
  | |_____^
help: to force the closure to take ownership of `path` (and any other referenced variables), use the `move` keyword
  |
2 |     move || match path {
  |     ++++

error[E0700]: hidden type for `impl Fn() -> usize` captures lifetime that does not appear in bounds
 --> /home/runner/work/glacier/glacier/ices/93242-2.rs:2:5
  |
1 |   pub fn something(path: &[usize]) -> impl Fn() -> usize {
  |                          --------     ------------------ opaque type defined here
  |                          |
  |                          hidden type `[closure@/home/runner/work/glacier/glacier/ices/93242-2.rs:2:5: 2:7]` captures the anonymous lifetime defined here
2 | /     || match path {
3 | |         [] => 0,
4 | |         _ => 1,
5 | |     }
  | |_____^
  |
help: to declare that `impl Fn() -> usize` captures `'_`, you can add an explicit `'_` lifetime bound
  |
1 | pub fn something(path: &[usize]) -> impl Fn() -> usize + '_ {
  |                                                        ++++

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0373, E0700.
For more information about an error, try `rustc --explain E0373`.
==============
@JohnTitor JohnTitor merged commit 3ac9eb4 into master Jun 4, 2023
@JohnTitor JohnTitor deleted the autofix/ices/93242-2.rs branch June 4, 2023 08:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants