diff options
| author | bors <bors@rust-lang.org> | 2018-01-03 03:37:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-01-03 03:37:47 +0000 |
| commit | 0f4ebf9f0a3196420e25cf1558b49ea3f38643c4 (patch) | |
| tree | b9afbec5a28b4b2165f8895e7211ed369ae84d9e /src/rustllvm/RustWrapper.cpp | |
| parent | 687d3d15ba726dbb1ac6b85223ebe0e98c6820cc (diff) | |
| parent | 063607eecbbdff53ee0cbc4b3f9a8ff49448f741 (diff) | |
| download | rust-0f4ebf9f0a3196420e25cf1558b49ea3f38643c4.tar.gz rust-0f4ebf9f0a3196420e25cf1558b49ea3f38643c4.zip | |
Auto merge of #47146 - ereslibre:issue-42106, r=estebank
Only bump error count when we are sure that the diagnostic is not a repetition
This ensures that if we emit the same diagnostic twice, the error count will
match the real number of errors shown to the user.
Fixes #42106
This is a followup of https://github.com/rust-lang/rust/pull/45603 as stated in https://github.com/rust-lang/rust/issues/42106#issuecomment-345218473.
This program, for example:
```rust
fn do_something<T>(collection: &mut Vec<T>) {
let _a = &collection;
collection.swap(1, 2);
}
fn main() {}
```
without this patch, produces:
```
error[E0502]: cannot borrow `*collection` as mutable because `collection` is also borrowed as immutable
--> $DIR/issue-42106.rs:13:5
|
12 | let _a = &collection;
| ---------- immutable borrow occurs here
13 | collection.swap(1, 2); //~ ERROR also borrowed as immutable
| ^^^^^^^^^^ mutable borrow occurs here
14 | }
| - immutable borrow ends here
error: aborting due to 2 previous errors
```
The number of errors do not match the diagnostics reported. This PR fixes this problem. The output is now in this case:
```
error[E0502]: cannot borrow `*collection` as mutable because `collection` is also borrowed as immutable
--> $DIR/issue-42106.rs:13:5
|
12 | let _a = &collection;
| ---------- immutable borrow occurs here
13 | collection.swap(1, 2); //~ ERROR also borrowed as immutable
| ^^^^^^^^^^ mutable borrow occurs here
14 | }
| - immutable borrow ends here
error: aborting due to previous error
```
Also, some other tests outputs have been adapted because their count didn't really match the number of diagnostics reported.
As an aside, an outdated comment has been removed (`Handler::cancel` will only call to the `Diagnostic::cancel` method and will not decrease the count of errors).
All tests are passing with this PR (`x.py test` is successful).
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
