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

Fix #58270, fix off-by-one error in error diagnostics. #60160

Merged

Conversation

xldenis
Copy link
Contributor

@xldenis xldenis commented Apr 22, 2019

This fixes #58270 by checking if two diagnostics overlap completely when we're calculating the line offset for each message.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @matthewjasper (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 22, 2019
@xldenis xldenis force-pushed the fix-overlapping-zero-width-annotation branch from 439e7de to 6c34a8b Compare April 22, 2019 02:16
@xldenis
Copy link
Contributor Author

xldenis commented Apr 22, 2019

r? @estebank

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:227a7cca:start=1555899487790897001,finish=1555899574766109539,duration=86975212538
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[01:01:44] .................................................................................................... 1600/5549
[01:01:47] .............................................................i...................................... 1700/5549
[01:01:50] .................................................................................................... 1800/5549
[01:01:54] .................................................................................................... 1900/5549
[01:01:57] ........................................................F........................................... 2000/5549
[01:02:04] i................................................................................................... 2200/5549
[01:02:08] .................................................................................................... 2300/5549
[01:02:12] .................................................................................................... 2400/5549
[01:02:16] .................................................................................................... 2500/5549
---
[01:04:06] 12 LL |         let _ = if true {
[01:04:06] 13 LL |         });
[01:04:06] -    |           ^
[01:04:06] -    |           |
[01:04:06] -    |           help: `}` may belong here
[01:04:06] +    |           ^ help: `}` may belong here
[01:04:06] 18 error: expected identifier, found `;`
[01:04:06] 19   --> $DIR/issue-60075.rs:6:11
[01:04:06] 
[01:04:06] 
[01:04:06] 
[01:04:06] The actual stderr differed from the expected stderr.
[01:04:06] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-60075/issue-60075.stderr
[01:04:06] To update references, rerun the tests and pass the `--bless` flag
[01:04:06] To only update this specific test, also pass `--test-args issue-60075.rs`
[01:04:06] error: 1 errors occurred comparing output.
[01:04:06] status: exit code: 1
[01:04:06] status: exit code: 1
[01:04:06] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issue-60075.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-60075/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-60075/auxiliary" "-A" "unused"
[01:04:06] ------------------------------------------
[01:04:06] 
[01:04:06] ------------------------------------------
[01:04:06] stderr:
[01:04:06] stderr:
[01:04:06] ------------------------------------------
[01:04:06] error: expected one of `.`, `;`, `?`, `else`, or an operator, found `}`
[01:04:06]   --> /checkout/src/test/ui/issue-60075.rs:6:10
[01:04:06]    |
[01:04:06] LL |         });
[01:04:06]    |          ^ expected one of `.`, `;`, `?`, `else`, or an operator here
[01:04:06] 
[01:04:06] error: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `;`
[01:04:06]    |
[01:04:06]    |
[01:04:06] LL |     fn qux() -> Option<usize> {
[01:04:06] LL |         let _ = if true {
[01:04:06] LL |         });
[01:04:06] LL |         });
[01:04:06]    |           ^ help: `}` may belong here
[01:04:06] error: expected identifier, found `;`
[01:04:06]   --> /checkout/src/test/ui/issue-60075.rs:6:11
[01:04:06]    |
[01:04:06] LL |         });
[01:04:06] LL |         });
[01:04:06]    |           ^ expected identifier
[01:04:06] 
[01:04:06] error: missing `fn`, `type`, or `const` for trait-item declaration
[01:04:06]    |
[01:04:06] LL |           });
[01:04:06]    |  ____________^
[01:04:06]    |  ____________^
[01:04:06] LL | | //~^ ERROR expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `;`
[01:04:06] LL | | //~^^ ERROR expected one of `.`, `;`, `?`, `else`, or an operator, found `}`
[01:04:06] LL | | //~^^^ ERROR 6:11: 6:12: expected identifier, found `;`
[01:04:06] LL | | //~^^^^ ERROR missing `fn`, `type`, or `const` for trait-item declaration
[01:04:06] LL | |         Some(4)
[01:04:06]    | |________^ missing `fn`, `type`, or `const`
[01:04:06] error: aborting due to 4 previous errors
[01:04:06] 
[01:04:06] 
[01:04:06] ------------------------------------------
---
[01:04:06] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:517:22
[01:04:06] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:04:06] 
[01:04:06] 
[01:04:06] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:04:06] 
[01:04:06] 
[01:04:06] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:04:06] Build completed unsuccessfully in 0:04:12
[01:04:06] Build completed unsuccessfully in 0:04:12
[01:04:06] make: *** [check] Error 1
[01:04:06] Makefile:48: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:000820d7
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon Apr 22 03:23:51 UTC 2019
---
travis_time:end:0466e6d8:start=1555903432284424674,finish=1555903432291287735,duration=6863061
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1699aeb0
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:26fd3bd9
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@estebank
Copy link
Contributor

The change looks good. You'll have to rebase información top of latest master and rerun bless, but other than that r=me.

@xldenis xldenis force-pushed the fix-overlapping-zero-width-annotation branch from 6c34a8b to 69e20e6 Compare April 22, 2019 17:18
@xldenis xldenis changed the title [WIP] Fix #58270, fix off-by-one error in error diagnostics. Fix #58270, fix off-by-one error in error diagnostics. Apr 22, 2019
@xldenis xldenis force-pushed the fix-overlapping-zero-width-annotation branch from 69e20e6 to 4a073dd Compare April 22, 2019 23:14
@xldenis
Copy link
Contributor Author

xldenis commented Apr 24, 2019

r=estebank I rebased an ran bless (it updated one test case).

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Apr 24, 2019

📌 Commit 4a073dd has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 24, 2019
Centril added a commit to Centril/rust that referenced this pull request Apr 25, 2019
…annotation, r=estebank

Fix rust-lang#58270, fix off-by-one error in error diagnostics.

This fixes rust-lang#58270 by checking if two diagnostics overlap completely when we're calculating the line offset for each message.
bors added a commit that referenced this pull request Apr 25, 2019
Rollup of 6 pull requests

Successful merges:

 - #59560 (MIR generation cleanup)
 - #59697 (tweak unresolved label suggestion)
 - #60038 (Add codegen test for PGO instrumentation.)
 - #60160 (Fix #58270, fix off-by-one error in error diagnostics.)
 - #60185 (Reexport IntErrorKind in std)
 - #60243 (Add regression test for #53249.)

Failed merges:

r? @ghost
@bors bors merged commit 4a073dd into rust-lang:master Apr 25, 2019
@bors
Copy link
Contributor

bors commented Apr 25, 2019

⌛ Testing commit 4a073dd with merge 9aea116...

@mark-i-m mark-i-m mentioned this pull request Jun 26, 2019
Centril added a commit to Centril/rust that referenced this pull request Jun 27, 2019
Centril added a commit to Centril/rust that referenced this pull request Jun 27, 2019
Centril added a commit to Centril/rust that referenced this pull request Jun 27, 2019
Centril added a commit to Centril/rust that referenced this pull request Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Span off-by-one error in diagnostics
5 participants