- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant 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.Performance or correctness regression from stable to beta.
Milestone
Description
Compiling the binstalk from cargo-bins/cargo-binstall#646 failed on nightly due to lifetime error while it works on stable.
The code in question looks like this and is in taken from crates/binstalk/src/fetchers/gh_crate_meta.rs
pub struct GhCrateMeta {
    client: Client,
    data: Arc<Data>,
    target_data: Arc<TargetData>,
    resolution: OnceCell<(Url, PkgFmt)>,
}
type FindTaskRes = Result<Option<(Url, PkgFmt)>, BinstallError>;
impl GhCrateMeta {
    fn launch_baseline_find_tasks<'a>(
        &'a self,
        pkg_fmt: PkgFmt,
        pkg_url: &'a str,
        repo: Option<&'a str>,
    ) -> impl Iterator<Item = impl Future<Output = FindTaskRes> + 'static> + 'a {
        todo!()
    }
    fn find(self: Arc<Self>) -> AutoAbortJoinHandle<Result<bool, BinstallError>> {
        AutoAbortJoinHandle::spawn(async move {
            // ...
            let mut handles = FuturesUnordered::new();
            // Iterate over pkg_urls to avoid String::clone.
            for pkg_url in pkg_urls {
                //             Clone iter pkg_fmts to ensure all pkg_fmts is
                //             iterated over for each pkg_url, which is
                //             basically cartesian product.
                //             |
                for pkg_fmt in pkg_fmts.clone() {
                    handles.extend(this.launch_baseline_find_tasks(pkg_fmt, &pkg_url, repo));
                }
            }
            todo!()
        })
    }On nightly, this failed with:
error[E0597]: `pkg_url` does not live long enough
   --> crates/binstalk/src/fetchers/gh_crate_meta.rs:147:77
    |
147 |                     handles.extend(this.launch_baseline_find_tasks(pkg_fmt, &pkg_url, repo));
    |                                                                             ^^^^^^^^ borrowed value 
does not live long enough
148 |                 }
149 |             }
    |             - `pkg_url` dropped here while still borrowed
...
160 |         })
    |         - borrow might be used here, when `handles` is dropped and runs the `Drop` code for type `Fu
turesUnordered`
    |
    = note: values in a scope are dropped in the opposite order they are defined
For more information about this error, try `rustc --explain E0597`.
error: could not compile `binstalk` due to previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `binstalk` due to previous error
Meta
rustc +nightly --version --verbose:
rustc 1.68.0-nightly (ce85c9857 2022-12-30)
binary: rustc
commit-hash: ce85c98575e3016cf2007d90a85be321e592aa96
commit-date: 2022-12-30
host: aarch64-apple-darwin
release: 1.68.0-nightly
LLVM version: 15.0.6
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant 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.Performance or correctness regression from stable to beta.