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

Nightly borrowck regression #29103

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

Comments

Projects
None yet
6 participants
@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

This comment has been minimized.

Copy link
Member

alexcrichton commented Oct 16, 2015

triage: I-nominated

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 16, 2015

triage: P-high

@nikomatsakis nikomatsakis self-assigned this Oct 16, 2015

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 16, 2015

Not sure what's going on here just yet.

@arielb1

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 20, 2015

/me actively investigating now

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 21, 2015

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

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 21, 2015

@pnkfelix can you confirm?

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Oct 21, 2015

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

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 21, 2015

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
You can’t perform that action at this time.