Skip to content

regression 1.50: Borrow checker reports function param as not living long enough #80949

Closed
@rylev

Description

@rylev
Member

This might not actually be a regression an instead the code may have previously erroneously compiled. I cannot find an an open issue obviously related to this though.

As you can see here this code does not compile with a "borrowed value does not live long enough" where it did previously. This comes from a call to diff::diff which has this signature.

The error message states that n may be dropped while the borrow in the next param state is still active. This fails to compile on both 1.50 and 1.49 if the param state is move to a local variable.

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

Activity

added
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Jan 12, 2021
added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Jan 12, 2021
apiraino

apiraino commented on Jan 13, 2021

@apiraino
Contributor

Let's try to reduce it @rustbot ping cleanup

rustbot

rustbot commented on Jan 13, 2021

@rustbot
Collaborator
hellow554

hellow554 commented on Jan 13, 2021

@hellow554
Contributor

Still with dependency, but simplified code

use euca::diff;
use euca::dom::Dom;
use euca::vdom::DomIter;

#[test]
fn from_empty() {
    let new: Dom<(), (), &()> = Dom::elem("div");

    let n = new.dom_iter();
    let mut storage = vec![];
    let patch_set = diff::diff(std::iter::empty(), n, &mut storage);
}

let's see what I can get from there

hellow554

hellow554 commented on Jan 13, 2021

@hellow554
Contributor

searched nightlies: from nightly-2020-12-01 to nightly-2021-01-06
regressed nightly: nightly-2020-12-06
searched commits: from 3ff10e7 to e792288
regressed commit: 9122b76

bisected with cargo-bisect-rustc v0.6.0

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

cargo bisect-rustc 2021-01-06 --without-cargo --access github --regress error

The code I tested:

struct Dom;
impl Dom {
    fn dom_iter(&self) -> Box<dyn Iterator<Item = &()>> {
        todo!()
    }
}

fn diff<'a, M, O, N, S>(_: O, _: N, _: S)
where
    M: 'a,
    O: IntoIterator<Item = M>,
    N: IntoIterator<Item = &'a M>,
    S: IntoIterator<Item = &'a M>,
{
    todo!()
}

fn main() {
    let n = Dom.dom_iter();
    let storage = vec![];

    diff(std::iter::empty(), n, &storage);
}

cc #78373 @matthewjasper

rustbot

rustbot commented on Jan 13, 2021

@rustbot
Collaborator

Error: Label ICEBreaker-Cleanup-Crew can only be set by Rust team members

Please let @rust-lang/release know if you're having trouble with this bot.

matthewjasper

matthewjasper commented on Jan 14, 2021

@matthewjasper
Contributor

So #78373 resulted in MIR having one fewer block, which is making borrowck be less precise with how long the borrow lasts. There are a few possible fixes here for me to look at.

added
P-highHigh priority
and removed
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Jan 14, 2021

30 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-borrow-checkerArea: The borrow checkerP-highHigh priorityT-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

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @pnkfelix@hellow554@mzabaluev@rylev@jonas-schievink

      Issue actions

        regression 1.50: Borrow checker reports function param as not living long enough · Issue #80949 · rust-lang/rust