about summary refs log tree commit diff
path: root/src/libstd/sys/unix
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-10-30 06:17:39 +0000
committerbors <bors@rust-lang.org>2017-10-30 06:17:39 +0000
commit86d117832042fa37b5831f8275e5f14b45938b55 (patch)
tree0a11e130f3b21e4c983f3dbe367d1e4447d8777d /src/libstd/sys/unix
parent875ec8d597eefbd1fb3c040d100ec03d8f66f445 (diff)
parentcf10bcfe4861ce01fe932300fa64dbb4484f3ef7 (diff)
downloadrust-86d117832042fa37b5831f8275e5f14b45938b55.tar.gz
rust-86d117832042fa37b5831f8275e5f14b45938b55.zip
Auto merge of #45603 - joshleeb:iss42106, r=estebank
Fix duplicate display of error E0502

Ref. Repeated "mutable/immutable borrow" error messages #42106.

This PR modifies the return type of [`report_error_if_loan_conflicts_with_restriction`](https://github.com/rust-lang/rust/blob/0f0f5db465de96b6c12e71f0c7d3e475f618b104/src/librustc_borrowck/borrowck/check_loans.rs#L398-L403) so the result can be checked in [`report_error_if_loans_conflict`](https://github.com/rust-lang/rust/blob/0f0f5db465de96b6c12e71f0c7d3e475f618b104/src/librustc_borrowck/borrowck/check_loans.rs#L377-L396). This is done to prevent displaying a duplicate of the error message E0502 which is referenced in #42106.

The output of compiling:

```rust
fn do_something<T>(collection: &mut Vec<T>) {
    let _a = &collection;
    collection.swap(1, 2);
}

fn main() {}
```

is now

```bash
$ rustc src/test/compile-fail/issue-42106.rs
error[E0502]: cannot borrow `*collection` as mutable because `collection` is also borrowed as immutable
  --> src/test/compile-fail/issue-42106.rs:13:5
   |
12 |     let _a = &collection;
   |               ---------- immutable borrow occurs here
13 |     collection.swap(1, 2);
   |     ^^^^^^^^^^ mutable borrow occurs here
14 | }
   | - immutable borrow ends here

error: aborting due to 2 previous errors
```

r? @estebank
Diffstat (limited to 'src/libstd/sys/unix')
0 files changed, 0 insertions, 0 deletions