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

Always emit unclosed delimiter diagnostics #58903

Merged
merged 11 commits into from Mar 8, 2019

Conversation

Projects
None yet
7 participants
@estebank
Copy link
Contributor

estebank commented Mar 3, 2019

Fix #58886.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Mar 3, 2019

r? @petrochenkov

(rust_highfive has picked a reviewer for you, use r? to override)

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Mar 3, 2019

@estebank Does this regression exist on the current beta compiler? If so we should beta backport.

@estebank

This comment has been minimized.

Copy link
Contributor Author

estebank commented Mar 4, 2019

@Centril I thought beta was spared, but alas, it wasn't.

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Mar 4, 2019

@estebank Aw; crap... 😭; At least we caught it before it went to stable 🎉!

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Mar 4, 2019

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:012dcdb5:start=1551661260287692129,finish=1551661332861818742,duration=72574126613
$ 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
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[01:07:27] ............................................ii...................................................... 3800/5430
[01:07:29] ..............................................................i..................................... 3900/5430
[01:07:31] .................................................................................................... 4000/5430
[01:07:33] ....................i............................................................................... 4100/5430
[01:07:36] .................F.................................................................................. 4200/5430
[01:07:50] .................................................................................................... 4400/5430
[01:07:53] .................................................................................................... 4500/5430
[01:07:57] ...............................................................................i.................... 4600/5430
[01:08:03] .................................................................................................... 4700/5430
---
[01:08:27] 1 error: incorrect close delimiter: `}`
[01:08:27] -   --> $DIR/unclosed_delim_mod.rs:6:1
[01:08:27] +   --> $DIR/unclosed_delim_mod.rs:5:1
[01:08:27] 3    |
[01:08:27] 4 LL | pub fn new() -> Result<Value, ()> {
[01:08:27] 
[01:08:27] 
[01:08:27] The actual stderr differed from the expected stderr.
[01:08:27] The actual stderr differed from the expected stderr.
[01:08:27] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/parser/unclosed-delimiter-in-dep/unclosed-delimiter-in-dep.stderr
[01:08:27] To update references, rerun the tests and pass the `--bless` flag
[01:08:27] To only update this specific test, also pass `--test-args parser/unclosed-delimiter-in-dep.rs`
[01:08:27] error: 1 errors occurred comparing output.
[01:08:27] status: exit code: 1
[01:08:27] status: exit code: 1
[01:08:27] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/parser/unclosed-delimiter-in-dep.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/busted_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: incorrect close delimiter: `}`\n  --> /checkout/src/test/ui/parser/unclosed_delim_mod.rs:5:1\n   |\nLL | pub fn new() -> Result<Value, ()> {\n   |                                   - close delimiter possibly meant for this\nLL |     Ok(Value {\n   |       - un-closed delimiter\nLL |     }\nLL | }\n   | ^ incorrect close delimiter\n\n"}
[01:08:27] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/parser/unclosed-delimiter-in-dep.rs","byte_start":56,"byte_end":81,"line_start":4,"line_end":4,"column_start":20,"column_end":45,"is_primary":true,"text":[{"text":"    let _: usize = unclosed_delim_mod::new();","highlight_start":20,"highlight_end":45}],"label":"expected usize, found enum `std::result::Result`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `usize`\n   found type `std::result::Result<unclosed_delim_mod::Value, ()>`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/parser/unclosed-delimiter-in-dep.rs:4:20\n   |\nLL |     let _: usize = unclosed_delim_mod::new();\n   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^ expected usize, found enum `std::result::Result`\n   |\n   = note: expected type `usize`\n              found type `std::result::Result<unclosed_delim_mod::Value, ()>`\n\n"}
[01:08:27] {"message":"For more information about this error, try `rustc --explain E0308`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0308`.\n"}
[01:08:27] 
[01:08:27] ------------------------------------------
[01:08:27] 
---
[01:08:27] 
[01:08:27] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:496:22
[01:08:27] 
[01:08:27] 
[01:08:27] 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:08:27] 
[01:08:27] 
[01:08:27] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:08:27] Build completed unsuccessfully in 0:04:07
[01:08:27] Build completed unsuccessfully in 0:04:07
[01:08:27] make: *** [check] Error 1
[01:08:27] Makefile:48: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:13eead92
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon Mar  4 02:10:48 UTC 2019
---
travis_time:end:05a36868:start=1551665449779969625,finish=1551665449784415889,duration=4446264
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0134459c
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:08f3b79d
travis_time:start:08f3b79d
$ 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:116be940
$ 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 estebank force-pushed the estebank:forgetful-delims branch 2 times, most recently from 5d4334c to 163191a Mar 4, 2019

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Mar 4, 2019

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:0949168d:start=1551669428319153791,finish=1551669501066998240,duration=72747844449
$ 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
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---

[00:03:29] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:30] tidy error: /checkout/src/test/ui/parser/unclosed_delim_mod.rs: missing trailing newline
[00:03:31] some tidy checks failed
[00:03:31] 
[00:03:31] 
[00:03:31] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:31] 
[00:03:31] 
[00:03:31] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:31] Build completed unsuccessfully in 0:00:44
[00:03:31] Build completed unsuccessfully in 0:00:44
[00:03:31] Makefile:68: recipe for target 'tidy' failed
[00:03:31] make: *** [tidy] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:062dae30
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon Mar  4 03:22:01 UTC 2019
---
travis_time:end:07e903a4:start=1551669721858809196,finish=1551669721863614885,duration=4805689
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:049553e0
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:08014208
travis_time:start:08014208
$ 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:01ca6aea
$ 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 estebank force-pushed the estebank:forgetful-delims branch from 163191a to a3da7da Mar 4, 2019

@estebank estebank changed the title Emit unclosed delimiter diagnostics or panic if this hasn't happened Emit unclosed delimiter diagnostics Mar 4, 2019

@estebank estebank changed the title Emit unclosed delimiter diagnostics Always emit unclosed delimiter diagnostics Mar 4, 2019

@estebank estebank force-pushed the estebank:forgetful-delims branch from 2efe0a8 to fdde883 Mar 4, 2019

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Mar 4, 2019

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:042f02b0:start=1551733367644004996,finish=1551733502759830753,duration=135115825757
$ 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
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[00:05:23]    Compiling rustc_errors v0.0.0 (/checkout/src/librustc_errors)
[00:06:30]    Compiling syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
[00:12:55]    Compiling rustc_typeck v0.0.0 (/checkout/src/librustc_typeck)
[00:12:55]    Compiling rustc_mir v0.0.0 (/checkout/src/librustc_mir)
[00:12:57] error[E0277]: the trait bound `syntax::tokenstream::TokenStream: std::convert::From<(syntax::tokenstream::TokenStream, std::vec::Vec<syntax::parse::lexer::UnmatchedBrace>)>` is not satisfied
[00:12:57]    --> src/librustc_metadata/cstore_impl.rs:460:30
[00:12:57] 460 |                 tokens: body.into(),
[00:12:57] 460 |                 tokens: body.into(),
[00:12:57]     |                              ^^^^ the trait `std::convert::From<(syntax::tokenstream::TokenStream, std::vec::Vec<syntax::parse::lexer::UnmatchedBrace>)>` is not implemented for `syntax::tokenstream::TokenStream`
[00:12:57]     = help: the following implementations were found:
[00:12:57]     = help: the following implementations were found:
[00:12:57]               <syntax::tokenstream::TokenStream as std::convert::From<syntax::parse::token::Token>>
[00:12:57]               <syntax::tokenstream::TokenStream as std::convert::From<syntax::tokenstream::TokenTree>>
[00:12:57]     = note: required because of the requirements on the impl of `std::convert::Into<syntax::tokenstream::TokenStream>` for `(syntax::tokenstream::TokenStream, std::vec::Vec<syntax::parse::lexer::UnmatchedBrace>)`
[00:12:58] error: aborting due to previous error
[00:12:58] 
[00:12:58] For more information about this error, try `rustc --explain E0277`.
[00:12:58] error: Could not compile `rustc_metadata`.

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 estebank force-pushed the estebank:forgetful-delims branch from fdde883 to cc077bc Mar 4, 2019

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Mar 5, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 5, 2019

📌 Commit cc077bc has been approved by petrochenkov

@estebank

This comment has been minimized.

Copy link
Contributor Author

estebank commented Mar 7, 2019

@bors p=52

@estebank estebank force-pushed the estebank:forgetful-delims branch from cc077bc to 551ea65 Mar 7, 2019

@estebank

This comment has been minimized.

Copy link
Contributor Author

estebank commented Mar 7, 2019

@petrochenkov subsuming #58863 into this PR to avoid merge conflict.

@estebank

This comment has been minimized.

Copy link
Contributor Author

estebank commented Mar 7, 2019

@bors r=petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 7, 2019

📌 Commit 551ea65 has been approved by petrochenkov

@Centril Centril added the T-compiler label Mar 7, 2019

LL | }
| - expected one of 11 possible tokens here
LL | }
| ^ unexpected token

This comment has been minimized.

@estebank

estebank Mar 7, 2019

Author Contributor

Finally identified what is causing these: when reaching the end of the current TokenTree, self.bump() will advance to a close token corresponding to the opening delimiter. There are two options: 1) attempt to rewrite the TokenTree representation that the Parser has once we suggest a close delim (high potential for bad lurking bugs), or 2) catch this specific case in expect_one_of, but that might be too magical.

@pietroalbini

This comment has been minimized.

Copy link
Member

pietroalbini commented Mar 8, 2019

@bors p=2

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 8, 2019

⌛️ Testing commit 551ea65 with merge b58a006...

bors added a commit that referenced this pull request Mar 8, 2019

Auto merge of #58903 - estebank:forgetful-delims, r=petrochenkov
Always emit unclosed delimiter diagnostics

Fix #58886.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 8, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: petrochenkov
Pushing b58a006 to master...

@bors bors added the merged-by-bors label Mar 8, 2019

@bors bors merged commit 551ea65 into rust-lang:master Mar 8, 2019

1 check passed

homu Test successful
Details
@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Mar 14, 2019

discussed at T-compiler meeting. beta-accepted.

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.