Skip to content

regression: parameter type may not live long enough #123280

Closed

Description

@Mark-Simulacrum
[INFO] [stdout] error[E0310]: the parameter type `EWA` may not live long enough
[INFO] [stdout]    --> src/worker_pool.rs:109:1
[INFO] [stdout]     |
[INFO] [stdout] 109 | / {
[INFO] [stdout] 110 | |     let mut handle_vec = Vec::with_capacity(default_worker);
[INFO] [stdout] 111 | |
[INFO] [stdout] 112 | |     let mut worker_sender_vec = Vec::with_capacity(default_worker);
[INFO] [stdout] ...   |
[INFO] [stdout] 128 | |     }
[INFO] [stdout] 129 | | }
[INFO] [stdout]     | | ^
[INFO] [stdout]     | | |
[INFO] [stdout]     | |_the parameter type `EWA` must be valid for the static lifetime...
[INFO] [stdout]     |   ...so that the type `EWA` will meet its required lifetime bounds
[INFO] [stdout]     |
[INFO] [stdout] help: consider adding an explicit lifetime bound
[INFO] [stdout]     |
[INFO] [stdout] 108 |     EWA: Clone + 'static,
[INFO] [stdout]     |                +++++++++

Smells similar to #123279, but maybe not.

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Mar 31, 2024
  2. added this to the 1.78.0 milestone on Mar 31, 2024
  3. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 31, 2024
  4. compiler-errors commented on Apr 1, 2024

    @compiler-errors
    Contributor

    searched toolchains b6d2d84 through 7d3702e


    Regression in 09bc67b


    Attempting to search unrolled perf builds
    ERROR: couldn't find perf build comment

    searched nightlies: from nightly-2024-02-01 to nightly-2024-04-01
    regressed nightly: nightly-2024-03-07
    searched commit range: b6d2d84...7d3702e
    regressed commit: 09bc67b

    bisected with cargo-bisect-rustc v0.6.8

    Host triple: x86_64-unknown-linux-gnu
    Reproduce with:

    cargo bisect-rustc --start=2024-02-01 
  5. compiler-errors commented on Apr 1, 2024

    @compiler-errors
    Contributor

    I can't tell upon a quick search whether this was an expected regression from #121679/#115008. cc @lcnr @aliemjay

  6. aliemjay commented on Apr 1, 2024

    @aliemjay
    Contributor

    This is expected. This is the culprit bound:
    https://github.com/shishanyue/RW-RJR-Server/blob/0343d1021fbbd3282e29377491b531d5a7bc98eb/src/worker_pool.rs#L23

    Minimized:

    struct WorkerPool<D: 'static>(Option<D>);
    
    fn new_worker_pool<D>() -> impl Sized {
        async {
            WorkerPool(None::<D>)
        }
    }

    What is annoying though is the error span which points to the entire async block because, when inside the async block, we draw implied bounds from its output type, allowing us to assume D: 'static, which then fails to be proven in the parent fn. See #115173 for a partial fix.

  7. aliemjay commented on Apr 1, 2024

    @aliemjay
    Contributor

    Ironically, this is accepted now and since forever because the rvalue never get the chance to be checked for well-formedness:

    struct WorkerPool<D: 'static>(Option<D>);
    
    fn new_worker_pool<D>() {
        let _ = async {
            WorkerPool(None::<D>)
        };
    }
  8. riking commented on Apr 1, 2024

    @riking
  9. lcnr commented on Apr 2, 2024

    @lcnr
    Contributor

    closing as expected and we have provided a PR to fix the issue

  10. apiraino commented on Apr 2, 2024

    @apiraino
    Contributor

    @aliemjay @lcnr anything here that should be noted in the release notes?

  11. lcnr commented on Apr 2, 2024

    @lcnr
    Contributor

    added a comment to #121679 (comment)

  12. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Apr 3, 2024
  13. removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions