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

Borrow checker error on nightly even when the type is 'static #106332

Closed
NobodyXu opened this issue Dec 31, 2022 · 12 comments · Fixed by #106759
Closed

Borrow checker error on nightly even when the type is 'static #106332

NobodyXu opened this issue Dec 31, 2022 · 12 comments · Fixed by #106759
Assignees
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@NobodyXu
Copy link
Contributor

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
@NobodyXu NobodyXu added the C-bug Category: This is a bug. label Dec 31, 2022
@clubby789
Copy link
Contributor

@rustbot modify labels: +regression-from-stable-to-beta

@rustbot rustbot added regression-from-stable-to-beta Performance or correctness regression from stable to beta. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 31, 2022
@albertlarsan68
Copy link
Member

albertlarsan68 commented Dec 31, 2022

@rustbot labels +E-needs-bisection

@rustbot rustbot added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc labels Dec 31, 2022
@clubby789

This comment was marked as outdated.

@lukas-code
Copy link
Contributor

lukas-code commented Dec 31, 2022

searched nightlies: from nightly-2022-12-09 to nightly-2022-12-27
regressed nightly: nightly-2022-12-10
searched commit range: 7632db0...dfe3fe7
regressed commit: 7701a7e (#105456)

bisected with cargo-bisect-rustc v0.6.4

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

cargo bisect-rustc --regress=error -- check 

Maybe its #105317?

@rustbot rustbot removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Dec 31, 2022
@clubby789

This comment was marked as outdated.

@rustbot rustbot added the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Dec 31, 2022
@lqd
Copy link
Member

lqd commented Dec 31, 2022

You can manually bisect the PRs in that rollup, #105456 (comment) contains the list of each of their artifacts.

I'd start by looking at #105255 though.

@rustbot rustbot removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Dec 31, 2022
@lukas-code
Copy link
Contributor

Yep, it's #105255. cc @cjgillot @compiler-errors

@cjgillot cjgillot self-assigned this Dec 31, 2022
@Mark-Simulacrum Mark-Simulacrum added this to the 1.67.0 milestone Jan 1, 2023
@NobodyXu
Copy link
Contributor Author

NobodyXu commented Jan 5, 2023

Any update on this?

I've tested the code on:

rustc 1.68.0-nightly (659e169d3 2023-01-04)
binary: rustc
commit-hash: 659e169d37990b9c730a59a96081f2ef7afbe8f1
commit-date: 2023-01-04
host: aarch64-apple-darwin
release: 1.68.0-nightly
LLVM version: 15.0.6

and it still failed.

@apiraino
Copy link
Contributor

apiraino commented Jan 6, 2023

@NobodyXu AFAICS your bug report has been acknowledged and has an assignee, looks like it's a regression in the beta channel (comment). The new stable will be out in a few weeks, might be fixed by then.

@NobodyXu
Copy link
Contributor Author

NobodyXu commented Jan 6, 2023

@NobodyXu AFAICS your bug report has been acknowledged and has an assignee, looks like it's a regression in the beta channel (comment). The new stable will be out in a few weeks, might be fixed by then.

Thanks, so looks like it's going to take quite some time.
I might go ahead and release cargo-binstall without waiting for this one.

@apiraino
Copy link
Contributor

apiraino commented Jan 10, 2023

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-high +T-compiler

@rustbot rustbot added P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jan 10, 2023
@bors bors closed this as completed in bbb2a22 Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
9 participants