Skip to content

Nightly borrowck regression #29103

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

Closed
arcnmx opened this issue Oct 16, 2015 · 10 comments
Closed

Nightly borrowck regression #29103

arcnmx opened this issue Oct 16, 2015 · 10 comments
Assignees
Labels
P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@arcnmx
Copy link
Contributor

arcnmx commented Oct 16, 2015

The following code compiles on stable and beta but not on the current nightly:

#[derive(Clone)]
struct S;

impl S {
    fn borrow(&self) -> Vec<&Self> { vec![self] }

    fn borrow_mut(&mut self, _: &S) { }
}

fn main() {
    let mut s = S;
    for x in s.borrow().into_iter().cloned().collect::<Vec<_>>() {
        s.borrow_mut(&x)
    }
}
@alexcrichton
Copy link
Member

triage: I-nominated

@alexcrichton alexcrichton added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 16, 2015
@nikomatsakis
Copy link
Contributor

triage: P-high

@nikomatsakis nikomatsakis self-assigned this Oct 16, 2015
@rust-highfive rust-highfive added the P-high High priority label Oct 16, 2015
@nikomatsakis
Copy link
Contributor

Not sure what's going on here just yet.

@arielb1
Copy link
Contributor

arielb1 commented Oct 16, 2015

This fails on stable (1.3) too if you explicitly deref s.borrow() (either via *, .deref, or Deref::deref) rather than autderefing.

@arielb1
Copy link
Contributor

arielb1 commented Oct 16, 2015

Minified:

#[derive(Clone)]
struct S;

fn borrow<'a>(s: &'a S) -> Vec<&'a S> { vec![s] }

fn main() {
    let s = S;
    match <Vec<&S> as IntoIterator>::into_iter(borrow(&s)) {
        _ => drop(s)
    };
}

@nikomatsakis
Copy link
Contributor

/me actively investigating now

@nikomatsakis
Copy link
Contributor

I believe this will be fixed by @pnkfelix's PR here: #29186

@nikomatsakis
Copy link
Contributor

@pnkfelix can you confirm?

@pnkfelix
Copy link
Member

yes it looks to me like #29186 fixes this.

I also think the test that #29186 adds should suffice to cover this bug; does anyone disagree with that claim?

If no one disagrees then I'll close this as a dupe of #29166

@nikomatsakis
Copy link
Contributor

I agree. Closing as dup of #29166.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants