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 should exploit information provided by match alternatives #13956

Closed
zwarich opened this issue May 5, 2014 · 1 comment
Closed

Comments

@zwarich
Copy link

zwarich commented May 5, 2014

The following code gives a borrow checker error because the borrow of a in the result of a.foo() overlaps with the mutable borrow of a.bar():

struct A<S>;

impl<S> A<S> {
    fn foo<'a>(&'a self) -> Option<&'a uint> { None }
    fn bar(&mut self) { }
}

fn baz<S>(a: &mut A<S>) -> bool {
    match a.foo() {
        Some(i) => true,
        None => { a.bar(); false }
    }
}

The borrow checker should be able to recognize that the None alternative of matching an Option<&T> can't contain a borrowed pointer.

@huonw
Copy link
Member

huonw commented May 6, 2014

Thanks for filing, I believe this is covered by #6393 and/or #10390.

@huonw huonw closed this as completed May 6, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 13, 2023
Update command-group from 1.0.8 to 2.0.1

With rust-lang#13552 the depencency of on the command-group crate was introduced, which also introduced a dependency on nix. That version of nix does not build on Haiku. This change introduces a newer version of command-group, which also updates nix from 0.22.3 to 0.26.1, which is compatible on Haiku.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants